@@ -67,7 +67,7 @@ export const switchConverse = createAction(
67
67
export const switchToConverse = function switchToConverse (
68
68
converseUUID : string
69
69
) : TRPGAction {
70
- return function ( dispatch , getState ) {
70
+ return function ( dispatch , getState ) {
71
71
dispatch ( hideProfileCard ( ) ) ;
72
72
dispatch ( switchMenuPannel ( 0 ) ) ;
73
73
dispatch ( switchConverse ( converseUUID ) ) ;
@@ -87,7 +87,7 @@ export const updateConversesMsglist = function updateConversesMsglist(
87
87
convUUID : string ,
88
88
list : any [ ]
89
89
) : TRPGAction {
90
- return function ( dispatch , getState ) {
90
+ return function ( dispatch , getState ) {
91
91
for ( const item of list ) {
92
92
if ( item . sender_uuid ) {
93
93
checkUser ( item . sender_uuid ) ;
@@ -103,10 +103,10 @@ export const updateConversesMsglist = function updateConversesMsglist(
103
103
104
104
// 获取多人会话
105
105
export const getConverses = function getConverses ( cb ?: ( ) => void ) : TRPGAction {
106
- return function ( dispatch , getState ) {
106
+ return function ( dispatch , getState ) {
107
107
dispatch ( { type : GET_CONVERSES_REQUEST } ) ;
108
108
// 获取会话列表
109
- return api . emit ( 'chat::getConverses' , { } , function ( data ) {
109
+ return api . emit ( 'chat::getConverses' , { } , function ( data ) {
110
110
cb && cb ( ) ;
111
111
if ( data . result ) {
112
112
const list = data . list ;
@@ -125,7 +125,7 @@ export const getConverses = function getConverses(cb?: () => void): TRPGAction {
125
125
api . emit (
126
126
'chat::getConverseChatLog' ,
127
127
{ converse_uuid : convUUID } ,
128
- function ( data ) {
128
+ function ( data ) {
129
129
if ( data . result ) {
130
130
dispatch ( updateConversesMsglist ( convUUID , data . list ) ) ;
131
131
} else {
@@ -149,15 +149,15 @@ export const createConverse = function createConverse(
149
149
type ,
150
150
isSwitchToConv = true
151
151
) : TRPGAction {
152
- return function ( dispatch , getState ) {
152
+ return function ( dispatch , getState ) {
153
153
if ( ! ! getState ( ) . chat . converses [ uuid ] ) {
154
154
console . log ( '已存在该会话' ) ;
155
155
if ( isSwitchToConv ) {
156
156
dispatch ( switchToConverse ( uuid ) ) ;
157
157
}
158
158
return ;
159
159
}
160
- return api . emit ( 'chat::createConverse' , { uuid, type } , function ( data ) {
160
+ return api . emit ( 'chat::createConverse' , { uuid, type } , function ( data ) {
161
161
console . log ( 'chat::createConverse' , data ) ;
162
162
if ( data . result ) {
163
163
const conv = data . data ;
@@ -172,7 +172,7 @@ export const createConverse = function createConverse(
172
172
api . emit (
173
173
'chat::getConverseChatLog' ,
174
174
{ converse_uuid : convUUID } ,
175
- function ( data ) {
175
+ function ( data ) {
176
176
if ( data . result ) {
177
177
const list = data . list ;
178
178
dispatch ( updateConversesMsglist ( convUUID , list ) ) ;
@@ -195,8 +195,8 @@ export const createConverse = function createConverse(
195
195
export const removeConverse = function removeConverse (
196
196
converseUUID : string
197
197
) : TRPGAction {
198
- return function ( dispatch , getState ) {
199
- return api . emit ( 'chat::removeConverse' , { converseUUID } , function ( data ) {
198
+ return function ( dispatch , getState ) {
199
+ return api . emit ( 'chat::removeConverse' , { converseUUID } , function ( data ) {
200
200
if ( data . result ) {
201
201
dispatch ( { type : REMOVE_CONVERSES_SUCCESS , converseUUID } ) ;
202
202
} else {
@@ -229,7 +229,7 @@ export const removeUserConverse = (userConverseUUID: string): TRPGAction => {
229
229
export const addUserConverse = function addUserConverse (
230
230
senders : string [ ]
231
231
) : TRPGAction {
232
- return function ( dispatch , getState ) {
232
+ return function ( dispatch , getState ) {
233
233
if ( typeof senders === 'string' ) {
234
234
senders = [ senders ] ;
235
235
}
@@ -280,7 +280,7 @@ export const addUserConverse = function addUserConverse(
280
280
} ) ;
281
281
282
282
// 更新消息列表
283
- api . emit ( 'chat::getUserChatLog' , { user_uuid : uuid } , function ( data ) {
283
+ api . emit ( 'chat::getUserChatLog' , { user_uuid : uuid } , function ( data ) {
284
284
if ( data . result ) {
285
285
const list = data . list ;
286
286
dispatch ( updateConversesMsglist ( uuid , list ) ) ;
@@ -291,7 +291,7 @@ export const addUserConverse = function addUserConverse(
291
291
}
292
292
293
293
// 更新系统消息
294
- api . emit ( 'chat::getUserChatLog' , { user_uuid : 'trpgsystem' } , function (
294
+ api . emit ( 'chat::getUserChatLog' , { user_uuid : 'trpgsystem' } , function (
295
295
data
296
296
) {
297
297
if ( data . result ) {
@@ -307,8 +307,10 @@ export const addUserConverse = function addUserConverse(
307
307
export const getOfflineUserConverse = function getOfflineUserConverse (
308
308
lastLoginDate : string
309
309
) : TRPGAction {
310
- return function ( dispatch , getState ) {
311
- api . emit ( 'chat::getOfflineUserConverse' , { lastLoginDate } , function ( data ) {
310
+ return function ( dispatch , getState ) {
311
+ api . emit ( 'chat::getOfflineUserConverse' , { lastLoginDate } , function (
312
+ data
313
+ ) {
312
314
if ( data . result === true ) {
313
315
dispatch ( addUserConverse ( data . senders ) ) ;
314
316
} else {
@@ -319,8 +321,8 @@ export const getOfflineUserConverse = function getOfflineUserConverse(
319
321
} ;
320
322
321
323
export const getAllUserConverse = function getAllUserConverse ( ) : TRPGAction {
322
- return function ( dispatch , getState ) {
323
- api . emit ( 'chat::getAllUserConverse' , { } , function ( data ) {
324
+ return function ( dispatch , getState ) {
325
+ api . emit ( 'chat::getAllUserConverse' , { } , function ( data ) {
324
326
if ( data . result === true ) {
325
327
dispatch ( addUserConverse ( data . senders ) ) ;
326
328
} else {
@@ -335,12 +337,12 @@ export const getAllUserConverse = function getAllUserConverse(): TRPGAction {
335
337
export const reloadConverseList = function reloadConverseList (
336
338
cb ?: ( ) => void
337
339
) : TRPGAction {
338
- return function ( dispatch , getState ) {
340
+ return function ( dispatch , getState ) {
339
341
const userInfo = getState ( ) . user . info ;
340
342
const userUUID = userInfo . uuid ! ;
341
343
342
344
dispatch ( getConverses ( cb ) ) ; // 从服务端获取多人会话列表
343
- rnStorage . get ( getUserConversesHash ( userUUID ) ) . then ( function ( converse ) {
345
+ rnStorage . get ( getUserConversesHash ( userUUID ) ) . then ( function ( converse ) {
344
346
console . log ( '缓存中的用户会话列表:' , converse ) ;
345
347
if ( converse && converse . length > 0 ) {
346
348
// 如果本地缓存有存在用户会话,则根据上次登录时间获取这段时间内新建的用户会话
@@ -416,7 +418,7 @@ export const sendMsg = function sendMsg(
416
418
toUUID : string | null ,
417
419
payload : SendMsgPayload
418
420
) : TRPGAction {
419
- return function ( dispatch , getState ) {
421
+ return function ( dispatch , getState ) {
420
422
const info = getState ( ) . user . info ;
421
423
const localUUID = getLocalUUID ( ) ;
422
424
const pkg = {
@@ -432,11 +434,10 @@ export const sendMsg = function sendMsg(
432
434
data : payload . data ,
433
435
uuid : localUUID ,
434
436
} ;
435
- console . log ( 'send msg pkg:' , pkg ) ;
436
437
437
438
const converseUUID = payload . converse_uuid || toUUID ;
438
439
dispatch ( addMsg ( converseUUID , pkg ) ) ;
439
- return api . emit ( 'chat::message' , pkg , function ( data ) {
440
+ return api . emit ( 'chat::message' , pkg , function ( data ) {
440
441
if ( data . result ) {
441
442
// TODO: 待实现SEND_MSG_COMPLETED的数据处理方法(用于送达提示)
442
443
dispatch ( {
@@ -457,10 +458,10 @@ export const sendMsg = function sendMsg(
457
458
export const sendFile = function sendFile ( toUUID , payload , file ) : TRPGAction {
458
459
if ( ! file ) {
459
460
console . error ( '发送文件错误。没有找到要发送的文件' ) ;
460
- return function ( dispatch , getState ) { } ;
461
+ return function ( dispatch , getState ) { } ;
461
462
}
462
463
463
- return function ( dispatch , getState ) {
464
+ return function ( dispatch , getState ) {
464
465
const info = getState ( ) . user . info ;
465
466
const selfUserUUID = info . uuid ! ;
466
467
const localUUID = getLocalUUID ( ) ;
@@ -494,7 +495,7 @@ export const sendFile = function sendFile(toUUID, payload, file): TRPGAction {
494
495
const filedata = Object . assign ( { } , pkg . data , fileinfo , { progress : 1 } ) ;
495
496
pkg = Object . assign ( { } , pkg , { data : filedata } ) ;
496
497
// 文件上传完毕。正式发送文件消息
497
- api . emit ( 'chat::message' , pkg , function ( data ) {
498
+ api . emit ( 'chat::message' , pkg , function ( data ) {
498
499
dispatch ( {
499
500
type : SEND_MSG_COMPLETED ,
500
501
payload : data ,
@@ -543,7 +544,7 @@ export const addFakeMsg = function addFakeMsg(
543
544
pkg : Partial < MsgPayload > ,
544
545
callback ?: ( localUUID : string ) => void
545
546
) : TRPGAction {
546
- return function ( dispatch , getState ) {
547
+ return function ( dispatch , getState ) {
547
548
const info = getState ( ) . user . info ;
548
549
const localUUID = getLocalUUID ( ) ;
549
550
pkg . uuid = localUUID ;
@@ -587,7 +588,7 @@ export const addLoadingMsg = function addLoadingMsg(
587
588
converseUUID : string ,
588
589
cb : ( event : LoadingCallbackEvent ) => void
589
590
) : TRPGAction {
590
- return function ( dispatch , getState ) {
591
+ return function ( dispatch , getState ) {
591
592
const fakeMsgPayload : Partial < MsgPayload > = {
592
593
message : '[处理中...]' ,
593
594
type : 'loading' ,
@@ -630,12 +631,12 @@ export const getMoreChatLog = function getMoreChatLog(
630
631
offsetDate : string ,
631
632
isUserChat = true
632
633
) : TRPGAction {
633
- return function ( dispatch , getState ) {
634
+ return function ( dispatch , getState ) {
634
635
if ( isUserChat ) {
635
636
api . emit (
636
637
'chat::getUserChatLog' ,
637
638
{ user_uuid : converseUUID , offsetDate } ,
638
- function ( data ) {
639
+ function ( data ) {
639
640
if ( data . result === true ) {
640
641
dispatch ( updateConversesMsglist ( converseUUID , data . list ) ) ;
641
642
dispatch ( {
@@ -652,7 +653,7 @@ export const getMoreChatLog = function getMoreChatLog(
652
653
api . emit (
653
654
'chat::getConverseChatLog' ,
654
655
{ converse_uuid : converseUUID , offsetDate } ,
655
- function ( data ) {
656
+ function ( data ) {
656
657
if ( data . result === true ) {
657
658
dispatch ( updateConversesMsglist ( converseUUID , data . list ) ) ;
658
659
dispatch ( {
@@ -669,35 +670,37 @@ export const getMoreChatLog = function getMoreChatLog(
669
670
} ;
670
671
} ;
671
672
672
- export const updateCardChatData = function ( chatUUID , newData ) : TRPGAction {
673
- return function ( dispatch , getState ) {
674
- return api . emit ( 'chat::updateCardChatData' , { chatUUID, newData } , function (
675
- data
676
- ) {
677
- if ( data . result ) {
678
- dispatch ( {
679
- type : UPDATE_SYSTEM_CARD_CHAT_DATA ,
680
- chatUUID,
681
- payload : data . log ,
682
- } ) ;
683
- } else {
684
- console . error ( data . msg ) ;
673
+ export const updateCardChatData = function ( chatUUID , newData ) : TRPGAction {
674
+ return function ( dispatch , getState ) {
675
+ return api . emit (
676
+ 'chat::updateCardChatData' ,
677
+ { chatUUID, newData } ,
678
+ function ( data ) {
679
+ if ( data . result ) {
680
+ dispatch ( {
681
+ type : UPDATE_SYSTEM_CARD_CHAT_DATA ,
682
+ chatUUID,
683
+ payload : data . log ,
684
+ } ) ;
685
+ } else {
686
+ console . error ( data . msg ) ;
687
+ }
685
688
}
686
- } ) ;
689
+ ) ;
687
690
} ;
688
691
} ;
689
692
690
693
const getWriteHash = ( type : string , uuid : string , groupUUID ?: string ) => {
691
694
return [ type , uuid , groupUUID ] . join ( '#' ) ;
692
695
} ;
693
- export const startWriting = function (
696
+ export const startWriting = function (
694
697
type = 'user' ,
695
698
uuid : string ,
696
699
groupUUID ?: string ,
697
700
channelUUID ?: string ,
698
701
currentText ?: string
699
702
) : TRPGAction {
700
- return function ( dispatch , getState ) {
703
+ return function ( dispatch , getState ) {
701
704
dispatch ( {
702
705
type : UPDATE_WRITING_STATUS ,
703
706
payload : {
@@ -712,14 +715,14 @@ export const startWriting = function(
712
715
713
716
renewableDelayTimer (
714
717
getWriteHash ( type , uuid , groupUUID ) ,
715
- function ( ) {
718
+ function ( ) {
716
719
dispatch ( stopWriting ( type , uuid , groupUUID ) ) ; // 如果在规定时间后没有再次收到正在输入的信号,则视为已经停止输入了
717
720
} ,
718
721
config . chat . isWriting . timeout
719
722
) ;
720
723
} ;
721
724
} ;
722
- export const stopWriting = function (
725
+ export const stopWriting = function (
723
726
type = 'user' ,
724
727
uuid : string ,
725
728
groupUUID ?: string ,
@@ -739,9 +742,11 @@ export const stopWriting = function(
739
742
} ;
740
743
} ;
741
744
742
- export const getUserEmotion = function ( ) : TRPGAction {
743
- return function ( dispatch , getState ) {
744
- return api . emit ( 'chatemotion::getUserEmotionCatalog' , null , function ( data ) {
745
+ export const getUserEmotion = function ( ) : TRPGAction {
746
+ return function ( dispatch , getState ) {
747
+ return api . emit ( 'chatemotion::getUserEmotionCatalog' , null , function (
748
+ data
749
+ ) {
745
750
if ( data . result ) {
746
751
dispatch ( {
747
752
type : UPDATE_USER_CHAT_EMOTION_CATALOG ,
@@ -758,17 +763,17 @@ export const getUserEmotion = function(): TRPGAction {
758
763
* 根据表情包暗号添加用户表情包
759
764
* @param {string } code 表情包暗号
760
765
*/
761
- export const addUserEmotionCatalogWithSecretSignal = function (
766
+ export const addUserEmotionCatalogWithSecretSignal = function (
762
767
code : string
763
768
) : TRPGAction {
764
- return function ( dispatch , getState ) {
769
+ return function ( dispatch , getState ) {
765
770
code = String ( code ) . toUpperCase ( ) ;
766
771
return api . emit (
767
772
'chatemotion::addUserEmotionWithSecretSignal' ,
768
773
{
769
774
code,
770
775
} ,
771
- function ( data ) {
776
+ function ( data ) {
772
777
if ( data . result ) {
773
778
const catalog = data . catalog ;
774
779
dispatch ( {
@@ -789,7 +794,7 @@ export const addUserEmotionCatalogWithSecretSignal = function(
789
794
* 设定某一会话为已读
790
795
* @param converseUUID 会话UUID
791
796
*/
792
- export const setConverseIsRead = function ( converseUUID : string ) : TRPGAction {
797
+ export const setConverseIsRead = function ( converseUUID : string ) : TRPGAction {
793
798
return { type : SET_CONVERSE_ISREAD , converseUUID } ;
794
799
} ;
795
800
0 commit comments