Skip to content

Commit 70b99c1

Browse files
authored
fix: remove uncorrect use ctx and conditdion. (#612)
* update trigger const. * feat: implement more accurate progress. * optimize method implement. * update conversation List logic. * update method logic. * update conversation logic. * update BatchInsertMessageList. * update addProgress to private. * fix update loss contents. * update condition logic. * fix: remove uncorrect use ctx. * remove unnecesary content.
1 parent 722f0eb commit 70b99c1

File tree

2 files changed

+18
-7
lines changed

2 files changed

+18
-7
lines changed

internal/conversation_msg/conversation_msg.go

+17-6
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ import (
4040
"github.com/openimsdk/openim-sdk-core/v3/pkg/syncer"
4141
pbConversation "github.com/openimsdk/protocol/conversation"
4242
"github.com/openimsdk/protocol/sdkws"
43+
"github.com/openimsdk/tools/errs"
4344
"github.com/openimsdk/tools/log"
4445
"github.com/openimsdk/tools/utils/datautil"
4546

@@ -457,10 +458,15 @@ func (c *Conversation) doMsgSyncByReinstalled(c2v common.Cmd2Value) {
457458

458459
for conversationID, msgs := range allMsg {
459460
log.ZDebug(ctx, "parse message in one conversation", "conversationID",
460-
conversationID, "message length", msgLen)
461+
conversationID, "message length", len(msgs.Msgs))
461462
var insertMessage, selfInsertMessage, othersInsertMessage []*model_struct.LocalChatLog
462463
var latestMsg *sdk_struct.MsgStruct
464+
if len(msgs.Msgs) == 0 {
465+
log.ZWarn(ctx, "msg.Msgs is empty", errs.New("msg.Msgs is empty"), "conversationID", conversationID)
466+
continue
467+
}
463468
for _, v := range msgs.Msgs {
469+
464470
log.ZDebug(ctx, "parse message ", "conversationID", conversationID, "msg", v)
465471
msg := &sdk_struct.MsgStruct{}
466472
// TODO need replace when after.
@@ -502,11 +508,16 @@ func (c *Conversation) doMsgSyncByReinstalled(c2v common.Cmd2Value) {
502508
latestMsg = msg
503509
}
504510
}
505-
conversationList = append(conversationList, &model_struct.LocalConversation{
506-
LatestMsg: utils.StructToJsonString(latestMsg),
507-
LatestMsgSendTime: latestMsg.SendTime,
508-
ConversationID: conversationID,
509-
})
511+
512+
if latestMsg != nil {
513+
conversationList = append(conversationList, &model_struct.LocalConversation{
514+
LatestMsg: utils.StructToJsonString(latestMsg),
515+
LatestMsgSendTime: latestMsg.SendTime,
516+
ConversationID: conversationID,
517+
})
518+
} else {
519+
log.ZWarn(ctx, "latestMsg is nil", errs.New("latestMsg is nil"), "conversationID", conversationID)
520+
}
510521

511522
insertMsg[conversationID] = append(insertMessage, c.faceURLAndNicknameHandle(ctx, selfInsertMessage, othersInsertMessage, conversationID)...)
512523
}

internal/interaction/msg_sync.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -389,7 +389,7 @@ func (m *MsgSyncer) syncAndTriggerReinstallMsgs(ctx context.Context, seqMap map[
389389
total = len(seqMap)
390390
gr *errgroup.Group
391391
)
392-
gr, ctx = errgroup.WithContext(ctx)
392+
gr, _ = errgroup.WithContext(ctx)
393393
gr.SetLimit(pullMsgGoroutineLimit)
394394
for k, v := range seqMap {
395395
oneConversationSyncNum := min(v[1]-v[0]+1, syncMsgNum)

0 commit comments

Comments
 (0)