From c083a4266f242cd6a9692d918e9e2796039d1097 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Ulrik=20R=C3=B8sby?= <ulrik@rosby.no>
Date: Sat, 2 Oct 2021 22:17:25 +0200
Subject: [PATCH] fix: Remove uneeded remove func from useStorage

---
 src/helpers/hooks.ts                      | 12 ++++--------
 src/pages/FeatsVsFixesPage/index.tsx      |  4 ++--
 src/pages/TimePerIssueLabelPage/index.tsx |  1 -
 3 files changed, 6 insertions(+), 11 deletions(-)

diff --git a/src/helpers/hooks.ts b/src/helpers/hooks.ts
index 29d6abb..43e7110 100644
--- a/src/helpers/hooks.ts
+++ b/src/helpers/hooks.ts
@@ -1,4 +1,4 @@
-import { Dispatch, SetStateAction, useCallback, useEffect, useState } from 'react';
+import { Dispatch, SetStateAction, useEffect, useState } from 'react';
 
 type StorageObject = typeof window.localStorage | typeof window.sessionStorage;
 // useStorage, useLocalStorage and useSessionStorage is taken from:
@@ -14,8 +14,8 @@ function useStorage<ValueType>(
   key: string,
   defaultValue: ValueType,
   storageObject: StorageObject,
-): [ValueType | undefined, Dispatch<SetStateAction<ValueType | undefined>>, () => void] {
-  const [value, setValue] = useState<ValueType | undefined>(() => {
+): [ValueType, Dispatch<SetStateAction<ValueType>>] {
+  const [value, setValue] = useState<ValueType>(() => {
     const jsonValue = storageObject.getItem(key);
     if (jsonValue != null) return JSON.parse(jsonValue);
     return defaultValue;
@@ -26,11 +26,7 @@ function useStorage<ValueType>(
     storageObject.setItem(key, JSON.stringify(value));
   }, [key, value, storageObject]);
 
-  const remove = useCallback(() => {
-    setValue(undefined);
-  }, []);
-
-  return [value, setValue, remove];
+  return [value, setValue];
 }
 
 /**
diff --git a/src/pages/FeatsVsFixesPage/index.tsx b/src/pages/FeatsVsFixesPage/index.tsx
index d00a16f..9d11212 100644
--- a/src/pages/FeatsVsFixesPage/index.tsx
+++ b/src/pages/FeatsVsFixesPage/index.tsx
@@ -27,7 +27,7 @@ export default function FeatsVsFixesPage() {
   ];
 
   for (let i = 0; i < authorData.length; i++) {
-    if (selectedAuthors?.[i]) {
+    if (selectedAuthors[i]) {
       featsFixesGraphData[0].val += authorData[i].feats;
       featsFixesGraphData[1].val += authorData[i].fixes;
       additionsDeletionsGraphData[0].val += authorData[i].additions;
@@ -54,7 +54,7 @@ export default function FeatsVsFixesPage() {
             <div key={JSON.stringify(m)}>
               Person {i + 1}
               <Checkbox
-                checked={selectedAuthors?.[i]}
+                checked={selectedAuthors[i]}
                 onChange={() => {
                   if (!selectedAuthors) return; // selectedAuthors will never be undefined
                   const tempList = [...selectedAuthors];
diff --git a/src/pages/TimePerIssueLabelPage/index.tsx b/src/pages/TimePerIssueLabelPage/index.tsx
index 3b2f22e..dcf7c8c 100644
--- a/src/pages/TimePerIssueLabelPage/index.tsx
+++ b/src/pages/TimePerIssueLabelPage/index.tsx
@@ -37,7 +37,6 @@ export default function TimePerIssueLabelPage() {
   useEffect(() => {
     // If allIssueData or selected is null, something is not selected and or the data is not
     if (allIssueData == null) return;
-    if (selected == null) return;
 
     // Find the average time used to close an issue with one of the selected labels
     const selectedArray = JSON.parse(selected);
-- 
GitLab