Skip to content

Commit a1ebde7

Browse files
fix: reload the window after emergency wipe (#7371)
1 parent c056c0a commit a1ebde7

1 file changed

Lines changed: 15 additions & 1 deletion

File tree

apps/cowswap-frontend/public/emergency.js

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,20 @@ if (window.location.pathname !== '/') {
2828

2929
;(async function () {
3030
const WIPE_KEY = 'emergencyWipe:v1'
31+
const RETURNING_USER_KEY = 'tokens:lastUpdateTimeAtom:v6'
32+
const hasVisitedBefore = localStorage.getItem(RETURNING_USER_KEY) !== null
3133

32-
if (localStorage.getItem(WIPE_KEY)) return
34+
if (localStorage.getItem(WIPE_KEY)) {
35+
console.log('[COW] Storage already clean')
36+
return
37+
}
38+
39+
if (!hasVisitedBefore) {
40+
console.log('[COW] New user, skipping storage wipe')
41+
localStorage.setItem(WIPE_KEY, '1')
42+
return
43+
}
44+
console.log('[COW] Performing emergency wipe')
3345

3446
// 1. localStorage (re-set wipe flag after)
3547
localStorage.clear()
@@ -123,6 +135,8 @@ if (window.location.pathname !== '/') {
123135
)
124136
}
125137
} catch {}
138+
139+
window.location.reload()
126140
})()
127141

128142
/**

0 commit comments

Comments
 (0)