mirror of
https://github.com/logos-messaging/js-waku.git
synced 2026-01-05 23:33:08 +00:00
feat: Conditionally set default history storage to localStorage for improved compatibility.
This commit is contained in:
parent
a0bc652791
commit
d320c753cf
@ -31,6 +31,8 @@ type StoredContentMessage = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const HISTORY_STORAGE_PREFIX = "waku:sds:history:";
|
const HISTORY_STORAGE_PREFIX = "waku:sds:history:";
|
||||||
|
const DEFAULT_HISTORY_STORAGE: HistoryStorage | undefined =
|
||||||
|
typeof localStorage !== "undefined" ? localStorage : undefined;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Persists the SDS local history in a browser/localStorage compatible backend.
|
* Persists the SDS local history in a browser/localStorage compatible backend.
|
||||||
@ -44,7 +46,7 @@ export class PersistentHistory implements ILocalHistory {
|
|||||||
|
|
||||||
public constructor(options: PersistentHistoryOptions) {
|
public constructor(options: PersistentHistoryOptions) {
|
||||||
this.memory = new MemLocalHistory();
|
this.memory = new MemLocalHistory();
|
||||||
this.storage = options.storage || localStorage;
|
this.storage = options.storage ?? DEFAULT_HISTORY_STORAGE;
|
||||||
this.storageKey = `${HISTORY_STORAGE_PREFIX}${options.channelId}`;
|
this.storageKey = `${HISTORY_STORAGE_PREFIX}${options.channelId}`;
|
||||||
this.load();
|
this.load();
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user