fix: 新群/新联系人自动刷新联系人缓存

检测到消息的用户名不在联系人缓存中时,自动重新加载
contact.db,解决新建群聊一直显示 chatroom ID 的问题。

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
feat/daemon-cli
ylytdeng 2026-03-31 18:43:34 +08:00
parent 396d4b24e2
commit b80e7d1c14
1 changed files with 5 additions and 0 deletions

View File

@ -1275,6 +1275,11 @@ class SessionMonitor:
if is_new: if is_new:
display = self.contact_names.get(username, username) display = self.contact_names.get(username, username)
is_group = '@chatroom' in username is_group = '@chatroom' in username
# 新群/新联系人不在缓存中时,重新加载联系人
if display == username and username not in self.contact_names:
refreshed = load_contact_names()
self.contact_names.update(refreshed)
display = self.contact_names.get(username, username)
sender = '' sender = ''
if is_group: if is_group:
sender = self.contact_names.get(curr['sender'], curr['sender_name'] or curr['sender']) sender = self.contact_names.get(curr['sender'], curr['sender_name'] or curr['sender'])