mirror of
https://github.com/ae-utbm/sith.git
synced 2026-05-13 20:48:06 +00:00
Merge pull request #1373 from ae-utbm/localsorage-pictures
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
|
||||
query: { users_identified: [config.userId] },
|
||||
} as PicturesFetchPicturesData);
|
||||
localStorage.setItem(localStorageInvalidationKey, config.nbPictures.toString());
|
||||
localStorage.setItem(localStorageKey, JSON.stringify(pictures));
|
||||
try {
|
||||
localStorage.setItem(localStorageInvalidationKey, config.nbPictures.toString());
|
||||
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;
|
||||
},
|
||||
|
||||
|
||||
Reference in New Issue
Block a user