diff options
| author | Zephyrrus <[email protected]> | 2020-12-24 13:57:09 +0200 |
|---|---|---|
| committer | Zephyrrus <[email protected]> | 2020-12-24 13:57:09 +0200 |
| commit | 587f7d69e80cfa1d94cc4730dc26834c389f574d (patch) | |
| tree | 92247c85f995728ad8b49967af6ae984dcc10f1b /src/site/store/images.js | |
| parent | bug: Thumbs are stored as webp and not as png anymore (diff) | |
| download | host.fuwn.me-587f7d69e80cfa1d94cc4730dc26834c389f574d.tar.xz host.fuwn.me-587f7d69e80cfa1d94cc4730dc26834c389f574d.zip | |
bug: fix showlist resetting itself every time the page is changed
bug: fix store not commiting search results
Diffstat (limited to 'src/site/store/images.js')
| -rw-r--r-- | src/site/store/images.js | 21 |
1 files changed, 18 insertions, 3 deletions
diff --git a/src/site/store/images.js b/src/site/store/images.js index 7cf25ce..69b4f5e 100644 --- a/src/site/store/images.js +++ b/src/site/store/images.js @@ -9,6 +9,7 @@ export const getDefaultState = () => ({ totalFiles: 0 }, search: '', + showList: false, albumName: null, albumDownloadEnabled: false, fileExtraInfoMap: {}, // information about the selected file @@ -108,11 +109,22 @@ export const actions = { return response; }, - async search({ commit }, { q, albumId }) { + async search({ commit, dispatch }, { q, albumId, page }) { const optionalAlbum = albumId ? `&albumId=${albumId}` : ''; - const response = await this.$axios.$get(`search/?q=${encodeURI(q)}${optionalAlbum}`); - return response; + page = page || 1; + + try { + const response = await this.$axios.$get(`search/?q=${encodeURI(q)}${optionalAlbum}`); + + commit('setFilesAndMeta', { ...response, page }); + + return response; + } catch (e) { + dispatch('alert/set', { text: e.message, error: true }, { root: true }); + } + + return null; } }; @@ -172,6 +184,9 @@ export const mutations = { state.fileTagsMap[fileId].splice(foundIndex, 1); } }, + setShowList(state, showList) { + state.showList = showList; + }, resetState(state) { Object.assign(state, getDefaultState()); } |