From c797bdc071e885eca046b5ba0ae31044c7854bf2 Mon Sep 17 00:00:00 2001 From: haliphax Date: Fri, 15 Jul 2022 13:08:10 -0500 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20add=20user=20to=20participants=20on?= =?UTF-8?q?=20load?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../scripts/components/participants.vue | 3 +++ .../scripts/store/modules/participants.ts | 20 ++++++++++++++++++- 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/src/front-end/scripts/components/participants.vue b/src/front-end/scripts/components/participants.vue index 9d15f421..f052d8df 100644 --- a/src/front-end/scripts/components/participants.vue +++ b/src/front-end/scripts/components/participants.vue @@ -10,6 +10,9 @@ const Participants: Component = { session(): sessionState { return this.$store.state.session; }, story(): storyState { return this.$store.state.story; } }, + created() { + this.$store.dispatch('addParticipant', this.session); + }, }; export default Participants; diff --git a/src/front-end/scripts/store/modules/participants.ts b/src/front-end/scripts/store/modules/participants.ts index 797fe2de..d0cde24e 100644 --- a/src/front-end/scripts/store/modules/participants.ts +++ b/src/front-end/scripts/store/modules/participants.ts @@ -1,7 +1,25 @@ -import { Module } from 'vuex'; +import { ActionContext, Module } from 'vuex'; import { participant, participantsState } from '../../types'; export const participantsModule: Module = { + actions: { + addParticipant( + ctx: ActionContext, + payload: participant, + ) { + const person: participant = { + id: payload.id, + name: payload.name, + }; + const people = ctx.state.people; + + if (people.hasOwnProperty(payload.id)) + person.value = people[payload.id].value; + + people[payload.id] = person; + ctx.commit('participants.people', people); + }, + }, mutations: { 'participants.people'( state: participantsState,