Skip to content

Commit

Permalink
✨ add user to participants on load
Browse files Browse the repository at this point in the history
  • Loading branch information
haliphax committed Jul 15, 2022
1 parent 025d6ba commit c797bdc
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
3 changes: 3 additions & 0 deletions src/front-end/scripts/components/participants.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
20 changes: 19 additions & 1 deletion src/front-end/scripts/store/modules/participants.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,25 @@
import { Module } from 'vuex';
import { ActionContext, Module } from 'vuex';
import { participant, participantsState } from '../../types';

export const participantsModule: Module<participantsState, any> = {
actions: {
addParticipant(
ctx: ActionContext<participantsState, any>,
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,
Expand Down

0 comments on commit c797bdc

Please sign in to comment.