software caching thumbnails in javascript

This commit is contained in:
j3d1 2024-06-22 22:11:38 +02:00
parent facefc1cc7
commit e91b64ca97
5 changed files with 54 additions and 18 deletions

View file

@ -29,8 +29,9 @@ const store = createStore({
expiry: null,
},
showAddBoxModal: false,
thumbnailCache: {},
persistent_loaded: false,
showAddBoxModal: false,
},
getters: {
route: state => router.currentRoute.value,
@ -71,6 +72,12 @@ const store = createStore({
isLoggedIn(state) {
return state.user && state.user.username !== null && state.user.token !== null;
},
getThumbnail: (state) => (url) => {
if (!url) return null;
if (!(url in state.thumbnailCache))
return null;
return state.thumbnailCache[url];
},
},
mutations: {
updateLastEvent(state, slug) {
@ -162,6 +169,9 @@ const store = createStore({
user.permissions = null;
state.user = user;
},
setThumbnail(state, {url, data}) {
state.thumbnailCache[url] = data;
},
},
actions: {
async login({commit}, {username, password, remember}) {