File tree Expand file tree Collapse file tree 2 files changed +22
-1
lines changed Expand file tree Collapse file tree 2 files changed +22
-1
lines changed Original file line number Diff line number Diff line change @@ -10,6 +10,9 @@ const Participants: Component = {
10
10
session(): sessionState { return this .$store .state .session ; },
11
11
story(): storyState { return this .$store .state .story ; }
12
12
},
13
+ created() {
14
+ this .$store .dispatch (' addParticipant' , this .session );
15
+ },
13
16
};
14
17
15
18
export default Participants ;
Original file line number Diff line number Diff line change 1
- import { Module } from 'vuex' ;
1
+ import { ActionContext , Module } from 'vuex' ;
2
2
import { participant , participantsState } from '../../types' ;
3
3
4
4
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
+ } ,
5
23
mutations : {
6
24
'participants.people' (
7
25
state : participantsState ,
You can’t perform that action at this time.
0 commit comments