File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff 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
1518export default Participants ;
Original file line number Diff line number Diff line change 1- import { Module } from 'vuex' ;
1+ import { ActionContext , Module } from 'vuex' ;
22import { participant , participantsState } from '../../types' ;
33
44export 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 ,
You can’t perform that action at this time.
0 commit comments