From 18c361c2bc540e18b6fa8dd62c9349d4f1e360af Mon Sep 17 00:00:00 2001 From: Dennis Rijsdijk <70665154+dennisrijsdijk@users.noreply.github.com> Date: Mon, 21 Oct 2024 09:51:14 +0200 Subject: [PATCH] fix: toggle-by-tag throwing error if sortTags prop is missing (#2864) * fix: reward missing sort tags throws error (#2861) * fix: command missing sort tags throws error (#2787) * fix: time based missing sort tag throws error --- src/backend/effects/builtin/cooldown-command.js | 2 +- src/backend/effects/builtin/toggle-command.ts | 2 +- src/backend/effects/builtin/toggle-scheduled-task.ts | 2 +- src/backend/effects/builtin/toggle-timer.ts | 2 +- src/backend/effects/builtin/update-channel-reward.ts | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/backend/effects/builtin/cooldown-command.js b/src/backend/effects/builtin/cooldown-command.js index 71fc44582..ba6166bd2 100644 --- a/src/backend/effects/builtin/cooldown-command.js +++ b/src/backend/effects/builtin/cooldown-command.js @@ -215,7 +215,7 @@ const model = { if (effect.sortTagId != null && effect.selectionType === "sortTag") { const commandManager = require("../../chat/commands/command-manager"); - const commands = commandManager.getAllCustomCommands().filter(c => c.sortTags.includes(effect.sortTagId)); + const commands = commandManager.getAllCustomCommands().filter(c => c.sortTags?.includes(effect.sortTagId)); commands.forEach(c => commandIds.push(c.id)); } diff --git a/src/backend/effects/builtin/toggle-command.ts b/src/backend/effects/builtin/toggle-command.ts index 7ada0b340..bec6f2954 100644 --- a/src/backend/effects/builtin/toggle-command.ts +++ b/src/backend/effects/builtin/toggle-command.ts @@ -120,7 +120,7 @@ const effect: EffectType<{ commandManager.saveCustomCommand(customCommand, "System"); } else if (commandType === "tag") { let commands = commandManager.getAllCustomCommands(); - commands = commands.filter(c => c.sortTags.includes(sortTagId)); + commands = commands.filter(c => c.sortTags?.includes(sortTagId)); commands.forEach((customCommand) => { customCommand.active = toggleType === "toggle" ? !customCommand.active : toggleType === "enable"; diff --git a/src/backend/effects/builtin/toggle-scheduled-task.ts b/src/backend/effects/builtin/toggle-scheduled-task.ts index e237ea077..328f26ed2 100644 --- a/src/backend/effects/builtin/toggle-scheduled-task.ts +++ b/src/backend/effects/builtin/toggle-scheduled-task.ts @@ -103,7 +103,7 @@ const model: EffectType<{ return true; } - const tasks = scheduledTaskManager.getAllItems().filter(task => task.sortTags.includes(effect.sortTagId)); + const tasks = scheduledTaskManager.getAllItems().filter(task => task.sortTags?.includes(effect.sortTagId)); tasks.forEach((scheduledTask) => { scheduledTask.enabled = effect.toggleType === "toggle" ? !scheduledTask.enabled : effect.toggleType === "enable"; diff --git a/src/backend/effects/builtin/toggle-timer.ts b/src/backend/effects/builtin/toggle-timer.ts index 8b79613f3..570363160 100644 --- a/src/backend/effects/builtin/toggle-timer.ts +++ b/src/backend/effects/builtin/toggle-timer.ts @@ -102,7 +102,7 @@ const model: EffectType<{ return true; } - const timers = timerManager.getAllItems().filter(timer => timer.sortTags.includes(effect.sortTagId)); + const timers = timerManager.getAllItems().filter(timer => timer.sortTags?.includes(effect.sortTagId)); timers.forEach((timer) => { const isActive = effect.toggleType === "toggle" ? !timer.active : effect.toggleType === "enable"; timerManager.updateTimerActiveStatus(timer.id, isActive); diff --git a/src/backend/effects/builtin/update-channel-reward.ts b/src/backend/effects/builtin/update-channel-reward.ts index 1dc168e34..77c402323 100644 --- a/src/backend/effects/builtin/update-channel-reward.ts +++ b/src/backend/effects/builtin/update-channel-reward.ts @@ -295,7 +295,7 @@ const model: EffectType = { } const rewards = Object.values(channelRewardsManager.channelRewards as Record) - .filter(reward => reward.sortTags.includes(effect.sortTagId) && reward.manageable); + .filter(reward => reward.sortTags?.includes(effect.sortTagId) && reward.manageable); const promises: Promise[] = [];