@@ -81,6 +81,7 @@ type Conversation struct {
81
81
full * full.Full
82
82
maxSeqRecorder MaxSeqRecorder
83
83
IsExternalExtensions bool
84
+ msgOffset int
84
85
progress int
85
86
86
87
startTime time.Time
@@ -119,6 +120,7 @@ func NewConversation(ctx context.Context, longConnMgr *interaction.LongConnMgr,
119
120
messageController : NewMessageController (db , ch ),
120
121
IsExternalExtensions : info .IsExternalExtensions (),
121
122
maxSeqRecorder : NewMaxSeqRecorder (),
123
+ msgOffset : 0 ,
122
124
progress : 0 ,
123
125
}
124
126
n .typing = newTyping (n )
@@ -448,12 +450,13 @@ func (c *Conversation) doMsgSyncByReinstalled(c2v common.Cmd2Value) {
448
450
allMsg := c2v .Value .(sdk_struct.CmdMsgSyncInReinstall ).Msgs
449
451
ctx := c2v .Ctx
450
452
msgLen := len (allMsg )
453
+ c .msgOffset += msgLen
451
454
total := c2v .Value .(sdk_struct.CmdMsgSyncInReinstall ).Total
452
455
453
456
insertMsg := make (map [string ][]* model_struct.LocalChatLog , 10 )
454
457
conversationList := make ([]* model_struct.LocalConversation , 0 )
455
458
456
- log .ZDebug (ctx , "message come here conversation ch" , "conversation length" , msgLen )
459
+ log .ZDebug (ctx , "message come here conversation ch in reinstalled " , "conversation length" , msgLen )
457
460
b := time .Now ()
458
461
459
462
for conversationID , msgs := range allMsg {
@@ -497,7 +500,7 @@ func (c *Conversation) doMsgSyncByReinstalled(c2v common.Cmd2Value) {
497
500
log .ZDebug (ctx , "decode message" , "msg" , msg )
498
501
if v .SendID == c .loginUserID {
499
502
// Messages sent by myself //if sent through this terminal
500
- log .ZInfo (ctx , "sync message" , "msg" , msg )
503
+ log .ZInfo (ctx , "sync message in reinstalled " , "msg" , msg )
501
504
502
505
latestMsg = msg
503
506
@@ -531,21 +534,17 @@ func (c *Conversation) doMsgSyncByReinstalled(c2v common.Cmd2Value) {
531
534
}
532
535
log .ZDebug (ctx , "before trigger msg" , "cost time" , time .Since (b ).Seconds (), "len" , len (allMsg ))
533
536
534
- c . addProgress (( msgLen * 90 ) / total )
535
- c .ConversationListener ().OnSyncServerProgress (c . getProgress () )
537
+ // log.ZDebug(ctx, "progress is", " msgLen", msgLen, "msgOffset", c.msgOffset, " total", total, "now progress is", (c.msgOffset*(100-InitSyncProgress))/total + InitSyncProgress )
538
+ c .ConversationListener ().OnSyncServerProgress (( c . msgOffset * ( 100 - InitSyncProgress )) / total + InitSyncProgress )
536
539
}
537
540
538
- func (c * Conversation ) addProgress (progress int ) {
541
+ func (c * Conversation ) addInitProgress (progress int ) {
539
542
c .progress += progress
540
543
if c .progress > 100 {
541
544
c .progress = 100
542
545
}
543
546
}
544
547
545
- func (c * Conversation ) getProgress () int {
546
- return c .progress
547
- }
548
-
549
548
func listToMap (list []* model_struct.LocalConversation , m map [string ]* model_struct.LocalConversation ) {
550
549
for _ , v := range list {
551
550
m [v .ConversationID ] = v
0 commit comments