StaffPanel: Move staff loading to panel creation.
This commit is contained in:
parent
bbb977a044
commit
431b3f527d
3 changed files with 9 additions and 1 deletions
|
@ -215,7 +215,6 @@ const getAppSecret = async ({ store }) => {
|
||||||
|
|
||||||
const resolveStaffAccounts = ({ store, accounts }) => {
|
const resolveStaffAccounts = ({ store, accounts }) => {
|
||||||
const nicknames = accounts.map(uri => uri.split('/').pop())
|
const nicknames = accounts.map(uri => uri.split('/').pop())
|
||||||
nicknames.map(nickname => store.dispatch('fetchUser', nickname))
|
|
||||||
store.dispatch('setInstanceOption', { name: 'staffAccounts', value: nicknames })
|
store.dispatch('setInstanceOption', { name: 'staffAccounts', value: nicknames })
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2,6 +2,10 @@ import map from 'lodash/map'
|
||||||
import BasicUserCard from '../basic_user_card/basic_user_card.vue'
|
import BasicUserCard from '../basic_user_card/basic_user_card.vue'
|
||||||
|
|
||||||
const StaffPanel = {
|
const StaffPanel = {
|
||||||
|
created() {
|
||||||
|
const nicknames = this.$store.state.instance.staffAccounts
|
||||||
|
nicknames.forEach(nickname => this.$store.dispatch('fetchUserIfMissing', nickname))
|
||||||
|
},
|
||||||
components: {
|
components: {
|
||||||
BasicUserCard
|
BasicUserCard
|
||||||
},
|
},
|
||||||
|
|
|
@ -266,6 +266,11 @@ const users = {
|
||||||
mutations,
|
mutations,
|
||||||
getters,
|
getters,
|
||||||
actions: {
|
actions: {
|
||||||
|
fetchUserIfMissing (store, id) {
|
||||||
|
if (!store.getters.findUser(id)) {
|
||||||
|
store.dispatch('fetchUser', id)
|
||||||
|
}
|
||||||
|
},
|
||||||
fetchUser (store, id) {
|
fetchUser (store, id) {
|
||||||
return store.rootState.api.backendInteractor.fetchUser({ id })
|
return store.rootState.api.backendInteractor.fetchUser({ id })
|
||||||
.then((user) => {
|
.then((user) => {
|
||||||
|
|
Loading…
Reference in a new issue