Skip to content

Commit 3721851

Browse files
committed
Bugfixes, return null as usersettings if no user
...given
1 parent 1b3cbd8 commit 3721851

File tree

2 files changed

+18
-8
lines changed

2 files changed

+18
-8
lines changed

pages/auth/settings/blacklist.vue

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,22 +14,31 @@
1414

1515
<script>
1616
import Author from '~/components/Author/Author.vue'
17+
import { mapGetters } from 'vuex'
18+
1719
export default {
1820
components: {
19-
Author
21+
'author': Author
2022
},
2123
data() {
2224
return {
2325
blacklistedUsers: [],
2426
}
2527
},
26-
async asyncData ({store}) {
27-
const { blacklist } = store.getters['feathers-vuex-usersettings/current'];
28-
if (!blacklist) return {}
29-
const res = await store.dispatch('feathers-vuex-users/find', { query: {_id: { $in: blacklist } } } );
30-
return {
31-
blacklistedUsers: res.data
32-
}
28+
computed: {
29+
...mapGetters({
30+
loggedInUser: 'auth/user',
31+
userSettings: 'feathers-vuex-usersettings/current'
32+
})
33+
},
34+
async mounted(){
35+
const { blacklist = [] } = this.userSettings || {}
36+
const res = await this.$store.dispatch('feathers-vuex-users/find', {
37+
query: {
38+
_id: { $in: blacklist },
39+
}
40+
})
41+
this.blacklistedUsers = res.data
3342
}
3443
};
3544
</script>

store/services/usersettings.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ let servicePlugin = (feathersClient) => {
2929
actions: {
3030
async loadCurrent ({commit, dispatch, state}, user) {
3131
let userId = user._id
32+
if (!userId) return null
3233
let { data } = await dispatch('find', {
3334
query: { userId }
3435
})

0 commit comments

Comments
 (0)