修复刷新/深链进入已解散的群聊时显示错乱,改成直接跳回消息列表
用户实机截图报告:一个群被解散后,如果直接刷新页面(或深链)停留在这个群的
URL上,标题栏/侧边栏显示原始topic id(不是群名)、"1970/1/1"的时间戳、
"0人"成员数,而不是跳转离开。
这跟已有的"正在查看时被实时解散"处理(subscribeTopicGone/onDeleteTopic)
不是同一条路径——那个只覆盖"已经订阅成功、活跃看着的时候被解散",覆盖不了
"这次页面加载压根没订阅成功过"的情况。实机复现确认:openConversation()对
一个已解散群的{sub}请求会正确收到404 CommError拒绝,但ConversationView
原来的catch只弹一个通用的"加载会话失败,请重试"提示,不会跳转,会话视图就
停留在一个半初始化的空壳状态。
修复:新增isTopicGone()识别这个404,命中后跟"实时解散"走一样的用户体验
(toast提示+跳转回/messages)。同时发现并修复了一个连带的清理问题——单纯
调用getTinode().getTopic(name)(openConversation内部一开始就会调,不管
后面订阅成不成功)就已经在SDK本地缓存里留下一个空壳对象,光是这个空壳存在
就足以让侧边栏显示出这条错乱的记录;而清理这个空壳时又跟ConversationView
自己卸载时的closeConversation()清理逻辑(它自己也会重新调用getTopic())
产生竞态——直接删除后又被重新创建。改成维护一个"确认已消失"的名单,让聊天
列表的过滤逻辑直接按名字永久排除,不再依赖谁先执行、谁后执行。
实机验证:真实解散一个群后,直接deep-link/刷新回这个群的URL——确认页面
立即跳转回/messages,且侧边栏不再出现这条已解散群的残留记录。
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 5
parent
c53e6552eb
commit
df22f26628
@@ -39,6 +39,23 @@ export function isTenantMismatch(err: unknown): boolean {
|
||||
return raw.replace(/\s*\(\d+\)\s*$/, '').trim().toLowerCase() === 'tenant mismatch';
|
||||
}
|
||||
|
||||
/**
|
||||
* `openConversation()`'s `{sub}` genuinely rejects with a clean `CommError` (code 404, message
|
||||
* "topic not found (404)") for a topic that no longer exists -- confirmed live: a group dissolved
|
||||
* by its owner, then deep-linked/refreshed into directly by a former member (not the "I'm actively
|
||||
* watching it get dissolved right now" case subscribeTopicGone already covers), reproducibly 404s
|
||||
* exactly like this. Before this check existed, ConversationView's generic catch just showed
|
||||
* "加载会话失败,请重试" and left the screen sitting on a half-initialized topic stub (raw topic id
|
||||
* as the name, "1970/1/1" for `touched`, "0" members -- `getTinode().getTopic()` lazily creates that
|
||||
* stub the moment anything asks for the name, whether or not the subscribe behind it ever succeeds),
|
||||
* a real reported bug ("当打开的群聊被删除后, 刷新还在群聊中 但是显示的不对"). 404 alone is treated
|
||||
* as sufficiently unambiguous for "this topic doesn't exist" -- there's no other real reason a
|
||||
* `{sub}` would come back with this exact code.
|
||||
*/
|
||||
export function isTopicGone(err: unknown): boolean {
|
||||
return (err as { code?: number })?.code === 404;
|
||||
}
|
||||
|
||||
export function loginErrorMessage(err: unknown): string {
|
||||
const known = translateCtrlError(err);
|
||||
if (known) return known;
|
||||
|
||||
Reference in New Issue
Block a user