fix notice display
This commit is contained in:
+19
-7
@@ -966,16 +966,28 @@ function createApp({
|
||||
const notificationId = String(event.notificationId || "");
|
||||
if (!notificationId) return { success: false, errMsg: "缺少 notificationId" };
|
||||
return store.update((database) => {
|
||||
const exists = database.panelNotifications.some((item) =>
|
||||
const exactMatch = database.panelNotifications.find((item) =>
|
||||
item.deviceId === deviceId && item.notificationId === notificationId
|
||||
);
|
||||
if (!exists) {
|
||||
return { success: false, errMsg: "Panel 通知不存在" };
|
||||
if (exactMatch) {
|
||||
database.panelNotifications = database.panelNotifications.filter((item) => item !== exactMatch);
|
||||
return { success: true, notificationId, deleted: 1 };
|
||||
}
|
||||
database.panelNotifications = database.panelNotifications.filter((item) =>
|
||||
!(item.deviceId === deviceId && item.notificationId === notificationId)
|
||||
);
|
||||
return { success: true, notificationId, deleted: 1 };
|
||||
|
||||
// 兼容:客户端 deviceId 切换或重连后,允许仅凭 notificationId 完成幂等关闭。
|
||||
const fallbackMatch = database.panelNotifications.find((item) => item.notificationId === notificationId);
|
||||
if (fallbackMatch) {
|
||||
database.panelNotifications = database.panelNotifications.filter((item) => item !== fallbackMatch);
|
||||
return {
|
||||
success: true,
|
||||
notificationId,
|
||||
deleted: 1,
|
||||
idempotent: true,
|
||||
reassignedDeviceId: fallbackMatch.deviceId
|
||||
};
|
||||
}
|
||||
|
||||
return { success: true, notificationId, deleted: 0, idempotent: true };
|
||||
});
|
||||
}
|
||||
case "ackPanelFile": {
|
||||
|
||||
Reference in New Issue
Block a user