Skip to content

Commit c797bdc

Browse files
committed
✨ add user to participants on load
1 parent 025d6ba commit c797bdc

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

src/front-end/scripts/components/participants.vue

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ const Participants: Component = {
1010
session(): sessionState { return this.$store.state.session; },
1111
story(): storyState { return this.$store.state.story; }
1212
},
13+
created() {
14+
this.$store.dispatch('addParticipant', this.session);
15+
},
1316
};
1417
1518
export default Participants;

src/front-end/scripts/store/modules/participants.ts

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,25 @@
1-
import { Module } from 'vuex';
1+
import { ActionContext, Module } from 'vuex';
22
import { participant, participantsState } from '../../types';
33

44
export const participantsModule: Module<participantsState, any> = {
5+
actions: {
6+
addParticipant(
7+
ctx: ActionContext<participantsState, any>,
8+
payload: participant,
9+
) {
10+
const person: participant = {
11+
id: payload.id,
12+
name: payload.name,
13+
};
14+
const people = ctx.state.people;
15+
16+
if (people.hasOwnProperty(payload.id))
17+
person.value = people[payload.id].value;
18+
19+
people[payload.id] = person;
20+
ctx.commit('participants.people', people);
21+
},
22+
},
523
mutations: {
624
'participants.people'(
725
state: participantsState,

0 commit comments

Comments
 (0)