forked from Qolzam/ts-websocket
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathactions.js
105 lines (90 loc) · 2 KB
/
actions.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
const setUserOffline = (userId) => ({
type: "SET_USER_OFFLINE",
payload: { userId: userId }
})
const setChatRequest = (userId) => ({
type: "ADD_CHAT_REQUEST",
payload: { userId: userId }
})
const setCallingUser = (userId) => ({
type: "ADD_CHAT_CALLING",
payload: { userId: userId }
})
const asyncAcceptChatRequest = (userId, roomId) => ({
type: "ASYNC_ACCEPT_CHAT_REQUEST",
payload: { userId: userId, roomId: roomId }
})
const asyncJoinChatRoom = (roomId) => ({
type: "ASYNC_JOIN_CHAT_ROOM",
payload: { roomId: roomId }
})
const addChatConnect = (userId, room) => ({
type: "ADD_CHAT_CONNECT",
payload: { userId: userId, room: room }
})
const removeChatConnect = (userId) => ({
type: "REMOVE_CHAT_CONNECT",
payload: { userId: userId }
})
/**
* Add user information
*/
const addUserInfo = (uid, info) => {
return {
type: "ADD_PLAIN_USER_INFO",
payload: { uid: uid, info: info }
}
}
/**
* Set current chat
*/
const setCurrentChat = ( userId) => {
return {
type: 'SET_CURRENT_CHAT', payload: {userId}
}
}
/**
* Remove chat request
*/
const removeChatRequest = (userId) => {
return {
type: "REMOVE_CHAT_REQUEST", payload: { userId: userId }
}
}
/**
* Add plain chat messages
*/
const addPlainChatRoomMessages = (messages, roomId) => {
return {
type: 'ADD_PLAIN_CHAT_ROOM_MESSAGES', payload: {messages, roomId}
}
}
/**
* Remove chat calling
*/
const removeChatCalling = (userId) => {
return {
type: 'REMOVE_CHAT_CALLING', payload: { userId: userId }
}
}
const showMessage = (message) => {
return {
type: "SHOW_MESSAGE_GLOBAL",
payload: { message }
}
}
module.exports = {
setUserOffline,
setChatRequest,
asyncAcceptChatRequest,
asyncJoinChatRoom,
setCallingUser,
setCurrentChat,
addUserInfo,
showMessage,
addChatConnect,
removeChatConnect,
removeChatRequest,
removeChatCalling,
addPlainChatRoomMessages
}