aboutsummaryrefslogtreecommitdiff
path: root/src/site/pages/dashboard/albums
diff options
context:
space:
mode:
authorPitu <[email protected]>2021-01-20 14:09:06 +0900
committerPitu <[email protected]>2021-01-20 14:09:06 +0900
commita3bf693d30d3c1c1d9e4073830522554c3f1c4e8 (patch)
treec1902391d0eb2f059030c2c41a08f91422d80eed /src/site/pages/dashboard/albums
parentfeat: enable ssr and serve it with the api (diff)
downloadhost.fuwn.me-a3bf693d30d3c1c1d9e4073830522554c3f1c4e8.tar.xz
host.fuwn.me-a3bf693d30d3c1c1d9e4073830522554c3f1c4e8.zip
chore: switch to asyncData where needed
Diffstat (limited to 'src/site/pages/dashboard/albums')
-rw-r--r--src/site/pages/dashboard/albums/_id.vue4
-rw-r--r--src/site/pages/dashboard/albums/index.vue11
2 files changed, 7 insertions, 8 deletions
diff --git a/src/site/pages/dashboard/albums/_id.vue b/src/site/pages/dashboard/albums/_id.vue
index faaf27c..446d3ac 100644
--- a/src/site/pages/dashboard/albums/_id.vue
+++ b/src/site/pages/dashboard/albums/_id.vue
@@ -76,7 +76,6 @@ export default {
},
middleware: ['auth', ({ route, store }) => {
store.commit('images/resetState');
- store.dispatch('images/fetchByAlbumId', { id: route.params.id });
}],
data() {
return {
@@ -101,6 +100,9 @@ export default {
watch: {
current: 'fetchPaginate'
},
+ async asyncData({ app, params }) {
+ await app.store.dispatch('images/fetchByAlbumId', { id: params.id });
+ },
methods: {
...mapActions({
fetch: 'images/fetchByAlbumId'
diff --git a/src/site/pages/dashboard/albums/index.vue b/src/site/pages/dashboard/albums/index.vue
index 2ebfb3f..686edc3 100644
--- a/src/site/pages/dashboard/albums/index.vue
+++ b/src/site/pages/dashboard/albums/index.vue
@@ -55,13 +55,7 @@ export default {
Sidebar,
AlbumEntry
},
- middleware: ['auth', ({ store }) => {
- try {
- store.dispatch('albums/fetch');
- } catch (e) {
- this.alert({ text: e.message, error: true });
- }
- }],
+ middleware: ['auth'],
data() {
return {
newAlbumName: null,
@@ -69,6 +63,9 @@ export default {
};
},
computed: mapState(['config', 'albums']),
+ async asyncData({ app }) {
+ await app.store.dispatch('albums/fetch');
+ },
methods: {
...mapActions({
alert: 'alert/set'