@@ -79,6 +79,22 @@ const Table = () => {
79
79
window . localStorage . setItem ( 'checkedAt' , JSON . stringify ( checkedAtList ) ) ;
80
80
}
81
81
82
+ let importantList =
83
+ JSON . parse ( localStorage . getItem ( 'importantProblems' ) ) ||
84
+ new Array ( questions . length ) . fill ( false ) ;
85
+
86
+ if ( importantList . length !== questions . length ) {
87
+ const resizedImportantList = new Array ( questions . length ) . fill ( false ) ;
88
+ for ( let i = 0 ; i < importantList . length ; i += 1 ) {
89
+ resizedImportantList [ i ] = importantList [ i ] ;
90
+ }
91
+ importantList = resizedImportantList ;
92
+ window . localStorage . setItem (
93
+ 'importantProblems' ,
94
+ JSON . stringify ( importantList ) ,
95
+ ) ;
96
+ }
97
+
82
98
const filteredByCheckbox = ( ) => {
83
99
const checkbox = localStorage . getItem ( 'checkbox' ) || '' ;
84
100
return questions . filter ( question => {
@@ -123,14 +139,6 @@ const Table = () => {
123
139
) ;
124
140
const [ starAnimation , setStarAnimation ] = useState ( { } ) ;
125
141
126
- // Returns an array of question objects that are starred
127
- const getStarredQuestions = ( ) => {
128
- return questions . filter ( ( q , idx ) => important [ idx ] ) ;
129
- } ;
130
- useEffect ( ( ) => {
131
- localStorage . setItem ( 'importantProblems' , JSON . stringify ( important ) ) ;
132
- } , [ important ] ) ;
133
-
134
142
useEffect ( ( ) => {
135
143
window . localStorage . setItem ( 'checked' , JSON . stringify ( checked ) ) ;
136
144
} , [ checked ] ) ;
@@ -143,6 +151,10 @@ const Table = () => {
143
151
window . localStorage . setItem ( 'showPatterns' , JSON . stringify ( showPatterns ) ) ;
144
152
} , [ showPatterns ] ) ;
145
153
154
+ useEffect ( ( ) => {
155
+ window . localStorage . setItem ( 'importantProblems' , JSON . stringify ( important ) ) ;
156
+ } , [ important ] ) ;
157
+
146
158
const defaultColumn = React . useMemo (
147
159
( ) => ( {
148
160
Filter : DefaultColumnFilter ,
@@ -619,11 +631,12 @@ const Table = () => {
619
631
const [ showOnlyStarred , setShowOnlyStarred ] = useState ( false ) ;
620
632
621
633
useEffect ( ( ) => {
634
+ // Always start from the full questions list
635
+ let filtered = filteredByCheckbox ( ) ;
622
636
if ( showOnlyStarred ) {
623
- setData ( getStarredQuestions ( ) ) ;
624
- } else {
625
- setData ( filteredByCheckbox ( ) ) ;
637
+ filtered = filtered . filter ( q => important [ q . id ] ) ;
626
638
}
639
+ setData ( filtered ) ;
627
640
// eslint-disable-next-line
628
641
} , [ showOnlyStarred , important , checked , resetCount ] ) ;
629
642
0 commit comments