mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Ensure that init can only be called once and catch errors
Signed-off-by: Sebastian Malton <sebastian@malton.name>
This commit is contained in:
parent
cdb129ea1e
commit
9a17097543
@ -44,10 +44,8 @@ export function createStorage<T>(key: string, defaultValue: T) {
|
|||||||
|
|
||||||
if (!storage.initialized) {
|
if (!storage.initialized) {
|
||||||
storage.initialized = true;
|
storage.initialized = true;
|
||||||
init(); // called once per cluster-view
|
|
||||||
}
|
|
||||||
|
|
||||||
async function init() {
|
(async () => {
|
||||||
const filePath = await StorageHelper.getLocalStoragePath();
|
const filePath = await StorageHelper.getLocalStoragePath();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@ -78,6 +76,8 @@ export function createStorage<T>(key: string, defaultValue: T) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
})()
|
||||||
|
.catch(error => logger.error(`${logPrefix} Failed to initialize storage: ${error}`));
|
||||||
}
|
}
|
||||||
|
|
||||||
return new StorageHelper<T>(key, {
|
return new StorageHelper<T>(key, {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user