Skip to content

Commit 95a9043

Browse files
committed
refactoring
1 parent ebf76c5 commit 95a9043

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

dotcom-rendering/src/components/SignInGateSelector.importable.tsx

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -375,16 +375,23 @@ const decideShowDefaultGate = (): ShowGateValues => {
375375
};
376376

377377
const getGateDisplayCount = (): number => {
378-
// TODO: retrieve the number of time the page has been displayed
379-
const count = storage.local.get('gate_display_count') as number;
378+
const rawValue = storage.local.getRaw('gate_display_count');
379+
const count = parseInt(rawValue ?? '0', 10);
380380
return count;
381381
};
382382

383383
const incrementGateDisplayCount = () => {
384384
const count = getGateDisplayCount();
385385
const now = new Date();
386386
const oneYearFromNow = new Date(now.getTime() + 365 * 86400);
387-
storage.local.set('gate_display_count', count + 1, oneYearFromNow);
387+
const newCount = count + 1;
388+
// Using `storage.local.set`, instead of `storage.local.setRaw`
389+
// because `setRaw` doesn't allow for specifying the duration.
390+
storage.local.set(
391+
'gate_display_count',
392+
newCount.toString(),
393+
oneYearFromNow,
394+
);
388395
};
389396

390397
const buildAuxiaGateDisplayData = async (

0 commit comments

Comments
 (0)