This commit is contained in:
aozhiwei 2020-12-10 13:48:09 +08:00
parent 22da1c6a3d
commit a52e491c35
2 changed files with 11 additions and 2 deletions

View File

@ -32,8 +32,14 @@ void ChatMgr::FillSMUpdateChatRedPointNotify(Player* hum, cs::SMUpdateChatRedPoi
} }
} }
ChatedUserRec* chated_user = GetChatedUser(hum->AccountId()); ChatedUserRec* chated_user = GetChatedUser(hum->AccountId());
if (chated_user && chated_user->has_unread_msg) { if (chated_user) {
msg.add_has_unread_msg_channels(kCCPrivate); if (chated_user->dirty) {
chated_user->has_unread_msg = false;
chated_user->dirty = false;
}
if (chated_user->has_unread_msg) {
msg.add_has_unread_msg_channels(kCCPrivate);
}
} }
} }
@ -251,6 +257,7 @@ void ChatMgr::SyncPrivateChatMsg(Player* hum)
if (chat_msg->msg_uuid() > itr->second.curr_id) { if (chat_msg->msg_uuid() > itr->second.curr_id) {
*notifymsg.add_msg_list() = *chat_msg; *notifymsg.add_msg_list() = *chat_msg;
itr->second.curr_id = chat_msg->msg_uuid(); itr->second.curr_id = chat_msg->msg_uuid();
chated_user->dirty = true;
} }
} }
} }
@ -295,6 +302,7 @@ void ChatMgr::AddChatedUser(const std::string& sender_id, const std::string& rec
private_chated_users_[sender_id] = ChatedUserRec(); private_chated_users_[sender_id] = ChatedUserRec();
itr = private_chated_users_.find(sender_id); itr = private_chated_users_.find(sender_id);
} }
itr->second.dirty = false;
itr->second.has_unread_msg = true; itr->second.has_unread_msg = true;
auto itr2 = itr->second.users.find(receiver_id); auto itr2 = itr->second.users.find(receiver_id);
if (itr2 == itr->second.users.end()) { if (itr2 == itr->second.users.end()) {

View File

@ -30,6 +30,7 @@ struct ChatMsgRec
struct ChatedUserRec struct ChatedUserRec
{ {
bool has_unread_msg = false; bool has_unread_msg = false;
bool dirty = false;
std::map<std::string, ChatMsgRec> users; std::map<std::string, ChatMsgRec> users;
}; };