mirror of
https://github.com/ae-utbm/sith.git
synced 2026-05-14 04:58:06 +00:00
fix: QuotaExceededError on user pictures load
This commit is contained in:
@@ -35,8 +35,23 @@ document.addEventListener("alpine:init", () => {
|
|||||||
// biome-ignore lint/style/useNamingConvention: from python api
|
// biome-ignore lint/style/useNamingConvention: from python api
|
||||||
query: { users_identified: [config.userId] },
|
query: { users_identified: [config.userId] },
|
||||||
} as PicturesFetchPicturesData);
|
} as PicturesFetchPicturesData);
|
||||||
|
try {
|
||||||
localStorage.setItem(localStorageInvalidationKey, config.nbPictures.toString());
|
localStorage.setItem(localStorageInvalidationKey, config.nbPictures.toString());
|
||||||
localStorage.setItem(localStorageKey, JSON.stringify(pictures));
|
localStorage.setItem(localStorageKey, JSON.stringify(pictures));
|
||||||
|
} catch {
|
||||||
|
// an exception is raised if the localstorage is entirely filled
|
||||||
|
// so just delete all cached user pictures.
|
||||||
|
// A cache hit is not worth the page breaking.
|
||||||
|
Object.keys(localStorage)
|
||||||
|
.filter(
|
||||||
|
(key) =>
|
||||||
|
key.startsWith("user") &&
|
||||||
|
(key.endsWith("Pictures") || key.endsWith("PicturesNumber")),
|
||||||
|
)
|
||||||
|
.forEach((key) => {
|
||||||
|
localStorage.removeItem(key);
|
||||||
|
});
|
||||||
|
}
|
||||||
return pictures;
|
return pictures;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user