Skip to content

Commit

Permalink
Fix infinite recursive populate
Browse files Browse the repository at this point in the history
  • Loading branch information
alexwohlbruck committed May 17, 2022
1 parent d8eed92 commit 9400157
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions client/src/store/groups.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,15 +45,17 @@ const mutations = {
}

const getters = {
group: (state: GroupsState, getters: any, _rootState: RootState, rootGetters: any) => (id: string) => {
group: (state: GroupsState, getters: any, _rootState: RootState, rootGetters: any) => (id: string, populateGroups = false) => {
const g = state.byId[id]
g.lamps = rootGetters.lampsByGroup(id)
if (populateGroups) {
g.lamps = rootGetters.lampsByGroup(id)
}
return g
},
groups: (state: GroupsState, getters: any) => (ids: string[]) => ids.map(id => getters.group(id)),
groups: (state: GroupsState, getters: any) => (ids: string[], populateGroups: boolean) => ids.map(id => getters.group(id, populateGroups)),
myGroups: (state: GroupsState, getters: any, _rootState: RootState, _rootGetters: any) => {
return getters
.groups(state.all)
.groups(state.all, true)
// .filter((lamp: Lamp) => lamp.user?._id === rootGetters.me?._id)
}
}
Expand Down

0 comments on commit 9400157

Please sign in to comment.