Skip to content

Commit

Permalink
localCache was being cleared on every new deployment
Browse files Browse the repository at this point in the history
  • Loading branch information
wighawag committed Nov 29, 2023
1 parent 8b7486e commit 8607244
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions web/src/lib/utils/localCache.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
import {version} from '$app/environment';
import {base} from '$app/paths';

class LocalCache {
private _prefix: string;
constructor(version?: string) {
this._prefix = base.startsWith('/ipfs/') || base.startsWith('/ipns/') ? base.slice(6) : ''; // ensure local storage is not conflicting across web3w-based apps on ipfs gateways (require encryption for sensitive data)

const lastVersion = this.getItem('_version');
if (lastVersion !== version) {
this.clear();
if (version) {
this.setItem('_version', version);
if (version) {
const lastVersion = this.getItem('_version');
if (lastVersion !== version) {
this.clear();
if (version) {
this.setItem('_version', version);
}
}
}
}
Expand Down Expand Up @@ -47,4 +48,5 @@ class LocalCache {
}
}

export default new LocalCache(version);
// can force version change
export default new LocalCache();

0 comments on commit 8607244

Please sign in to comment.