Skip to content

Commit d540152

Browse files
committed
Address review comments
1 parent 0ef9bdc commit d540152

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

client/src/utils/storage.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import { useRef } from 'react';
21
import defaults from '../constants/defaults';
32
import migrateThemes from './migrations/colourTheme';
43
import migratePrimaryTimetables from './migrations/primaryTimetables';
@@ -9,7 +8,7 @@ const STORAGE_KEY = 'data';
98
// Something is not playing nice and causing local storage to corrupt across signing in/out
109
// We are in the process of migrating data to the backend, so this fix should catch people
1110
// for now and prevent them from seeing a blank page.
12-
const hasRunArrayCheck = useRef(false);
11+
let hasRunArrayCheck = false;
1312

1413
const storage = {
1514
get: (key: string): any => {
@@ -70,7 +69,7 @@ const storage = {
7069
}
7170

7271
// Un-break an existing issue with migrated data
73-
if (!hasRunArrayCheck.current) {
72+
if (!hasRunArrayCheck) {
7473
Object.entries(migrated.timetables).forEach(([term, timetables]) => {
7574
if (
7675
!Array.isArray(timetables) ||
@@ -80,7 +79,8 @@ const storage = {
8079
}
8180
});
8281

83-
hasRunArrayCheck.current = true;
82+
storage.save(migrated);
83+
hasRunArrayCheck = true;
8484
}
8585

8686
// only do this if version does not exist

0 commit comments

Comments
 (0)