修复礼包领取弹窗重复显示

This commit is contained in:
pllx
2026-05-05 21:48:51 +08:00
parent 11a882bd8e
commit 725a38eac3
3 changed files with 39 additions and 7 deletions
+18
View File
@@ -70,6 +70,20 @@ function runWhenDomReady(callback) {
callback();
}
/**
* 判断 Toast 通知是否需要对当前用户隐藏。
*
* @param {Record<string, any>} toastNotification 右下角通知载荷
* @returns {boolean}
*/
function shouldSkipToastForCurrentUser(toastNotification) {
if (!toastNotification?.skip_for_actor) {
return false;
}
return String(toastNotification.actor_username || "") === String(window.chatContext?.username || "");
}
// ── 禁言逻辑 ──
function handleMutedEvent(e) {
const state = getState();
@@ -417,6 +431,10 @@ export function bindChatEvents() {
// 若消息携带 toast_notification 字段且当前用户是接收者或为公屏广播或为欢迎动作,弹右下角小卡片
if (msg.toast_notification && (msg.to_user === window.chatContext?.username || msg.to_user === '大家' || msg.action === '欢迎')) {
const t = msg.toast_notification;
if (shouldSkipToastForCurrentUser(t)) {
return;
}
window.chatToast?.show({
title: t.title || "通知",
message: t.message || "",