diff options
| author | Zephyrrus <[email protected]> | 2021-01-17 18:26:01 +0200 |
|---|---|---|
| committer | Zephyrrus <[email protected]> | 2021-01-17 18:26:01 +0200 |
| commit | cf513f2ebeca4b3837df144ae82de63af3aee532 (patch) | |
| tree | 6920cdde972f435b3328d7a77eaa8231191fd9a2 | |
| parent | Merge pull request #252 from WeebDev/fix/docker (diff) | |
| download | host.fuwn.me-cf513f2ebeca4b3837df144ae82de63af3aee532.tar.xz host.fuwn.me-cf513f2ebeca4b3837df144ae82de63af3aee532.zip | |
fix: trying to fetch tags and albums on a public album link
| -rw-r--r-- | src/site/components/grid/Grid.vue | 62 | ||||
| -rw-r--r-- | src/site/plugins/handler.js | 12 |
2 files changed, 18 insertions, 56 deletions
diff --git a/src/site/components/grid/Grid.vue b/src/site/components/grid/Grid.vue index 9e1ce6f..3a0045b 100644 --- a/src/site/components/grid/Grid.vue +++ b/src/site/components/grid/Grid.vue @@ -227,17 +227,14 @@ export default { showList: 'displayTypeChange' }, created() { - // TODO: Create a middleware for this - this.getAlbums(); - this.getTags(); + if (!this.isPublic) { + this.$handler.executeAction('albums/getTinyDetails', null, false); + this.$handler.executeAction('tags/fetch', null, false); + } this.showList = this.images.showList; }, methods: { - async search() { - const data = await this.$search.do(this.searchTerm, ['name', 'original', 'type', 'albums:name']); - console.log('> Search result data', data); // eslint-disable-line no-console - }, deleteFile(file) { // this.$emit('delete', file); this.$buefy.dialog.confirm({ @@ -246,13 +243,7 @@ export default { confirmText: 'Delete File', type: 'is-danger', onConfirm: async () => { - try { - const response = await this.$store.dispatch('images/deleteFile', file.id); - - this.$buefy.toast.open(response.message); - } catch (e) { - this.$store.dispatch('alert/set', { text: e.message, error: true }, { root: true }); - } + await this.$handler.executeAction('images/deleteFile', file.id); } }); }, @@ -266,41 +257,17 @@ export default { this.showingModalForFile = file; this.showingModalForFile.albums = []; - try { - await this.$store.dispatch('images/getFileAlbums', id); - } catch (e) { - this.$store.dispatch('alert/set', { text: e.message, error: true }, { root: true }); - } + await this.$handler.executeAction('images/getFileAlbums', id, false); + this.showingModalForFile.albums = this.images.fileAlbumsMap[id]; this.isAlbumsModalActive = true; }, async albumCheckboxClicked(add, id) { - try { - let response; - if (add) { - response = await this.$store.dispatch('images/addToAlbum', { - albumId: id, - fileId: this.showingModalForFile.id - }); - } else { - response = await this.$store.dispatch('images/removeFromAlbum', { - albumId: id, - fileId: this.showingModalForFile.id - }); - } - - this.$buefy.toast.open(response.message); - } catch (e) { - this.$store.dispatch('alert/set', { text: e.message, error: true }, { root: true }); - } - }, - async getAlbums() { - try { - await this.$store.dispatch('albums/getTinyDetails'); - } catch (e) { - this.$store.dispatch('alert/set', { text: e.message, error: true }, { root: true }); - } + await this.$handler.executeAction(add ? 'images/addToAlbum' : 'images/removeFromAlbum', { + albumId: id, + fileId: this.showingModalForFile.id + }); }, async handleFileModal(file) { const { id } = file; @@ -316,13 +283,6 @@ export default { this.isAlbumsModalActive = true; }, - async getTags() { - try { - await this.$store.dispatch('tags/fetch'); - } catch (e) { - this.$store.dispatch('alert/set', { text: e.message, error: true }, { root: true }); - } - }, mouseOver(id) { const foundIndex = this.hoveredItems.indexOf(id); if (foundIndex > -1) return; diff --git a/src/site/plugins/handler.js b/src/site/plugins/handler.js index 7933eab..f4be79c 100644 --- a/src/site/plugins/handler.js +++ b/src/site/plugins/handler.js @@ -2,14 +2,16 @@ import AlertTypes from '~/constants/alertTypes'; export default ({ store }, inject) => { inject('handler', { - async executeAction(action, param) { + async executeAction(action, param, showSuccess = true) { try { const response = await store.dispatch(action, param); - store.commit('alert/set', { - message: response?.message ?? 'Executed sucesfully', - type: AlertTypes.SUCCESS - }); + if (showSuccess) { + store.commit('alert/set', { + message: response?.message ?? 'Executed sucesfully', + type: AlertTypes.SUCCESS + }); + } return response; } catch (e) { |