aboutsummaryrefslogtreecommitdiff
path: root/src/site/store/albums.js
diff options
context:
space:
mode:
authorZephyrrus <[email protected]>2020-07-05 04:17:09 +0300
committerZephyrrus <[email protected]>2020-07-05 04:17:09 +0300
commit04fdd63cee5327f49e5e11d5837a9031027c34ef (patch)
tree4e965af31eb08d230740dba7104a19124dce3a1e /src/site/store/albums.js
parentchore: change to vue recommended eslint rules + airbnb-base for js (diff)
downloadhost.fuwn.me-04fdd63cee5327f49e5e11d5837a9031027c34ef.tar.xz
host.fuwn.me-04fdd63cee5327f49e5e11d5837a9031027c34ef.zip
feat: refactor single album page to use vuex
Diffstat (limited to 'src/site/store/albums.js')
-rw-r--r--src/site/store/albums.js38
1 files changed, 17 insertions, 21 deletions
diff --git a/src/site/store/albums.js b/src/site/store/albums.js
index d5d45ce..f3d7bcf 100644
--- a/src/site/store/albums.js
+++ b/src/site/store/albums.js
@@ -5,26 +5,22 @@ export const state = () => ({
list: [],
isListLoading: false,
albumDetails: {},
- expandedAlbums: []
+ expandedAlbums: [],
});
export const getters = {
- isExpanded: state => id => state.expandedAlbums.indexOf(id) > -1,
- getDetails: state => id => state.albumDetails[id] || {}
+ isExpanded: (state) => (id) => state.expandedAlbums.indexOf(id) > -1,
+ getDetails: (state) => (id) => state.albumDetails[id] || {},
};
export const actions = {
- async fetch({ commit, dispatch }) {
- try {
- commit('albumsRequest');
- const response = await this.$axios.$get(`albums/mini`);
+ async fetch({ commit }) {
+ commit('albumsRequest');
+ const response = await this.$axios.$get('albums/mini');
- commit('setAlbums', response.albums);
+ commit('setAlbums', response.albums);
- return response;
- } catch (e) {
- dispatch('alert/set', { text: e.message, error: true }, { root: true });
- }
+ return response;
},
async fetchDetails({ commit }, albumId) {
@@ -33,15 +29,15 @@ export const actions = {
commit('setDetails', {
id: albumId,
details: {
- links: response.links
- }
+ links: response.links,
+ },
});
return response;
},
async createAlbum({ commit }, name) {
- const response = await this.$axios.$post(`album/new`, { name });
+ const response = await this.$axios.$post('album/new', { name });
commit('addAlbum', response.data);
@@ -57,7 +53,7 @@ export const actions = {
},
async createLink({ commit }, albumId) {
- const response = await this.$axios.$post(`album/link/new`, { albumId });
+ const response = await this.$axios.$post('album/link/new', { albumId });
commit('addAlbumLink', { albumId, data: response.data });
@@ -65,10 +61,10 @@ export const actions = {
},
async updateLinkOptions({ commit }, { albumId, linkOpts }) {
- const response = await this.$axios.$post(`album/link/edit`, {
+ const response = await this.$axios.$post('album/link/edit', {
identifier: linkOpts.identifier,
enableDownload: linkOpts.enableDownload,
- enabled: linkOpts.enabled
+ enabled: linkOpts.enabled,
});
commit('updateAlbumLinkOpts', { albumId, linkOpts: response.data });
@@ -82,7 +78,7 @@ export const actions = {
commit('removeAlbumLink', { albumId, identifier });
return response;
- }
+ },
};
export const mutations = {
@@ -109,7 +105,7 @@ export const mutations = {
},
updateAlbumLinkOpts(state, { albumId, linkOpts }) {
const foundIndex = state.albumDetails[albumId].links.findIndex(
- ({ identifier }) => identifier === linkOpts.identifier
+ ({ identifier }) => identifier === linkOpts.identifier,
);
const link = state.albumDetails[albumId].links[foundIndex];
state.albumDetails[albumId].links[foundIndex] = { ...link, ...linkOpts };
@@ -125,5 +121,5 @@ export const mutations = {
} else {
state.expandedAlbums.push(id);
}
- }
+ },
};