Skip to content

Commit

Permalink
fix: toggle-by-tag throwing error if sortTags prop is missing (#2864)
Browse files Browse the repository at this point in the history
* fix: reward missing sort tags throws error (#2861)

* fix: command missing sort tags throws error (#2787)

* fix: time based missing sort tag throws error
  • Loading branch information
dennisrijsdijk authored Oct 21, 2024
1 parent db8aa59 commit 18c361c
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/backend/effects/builtin/cooldown-command.js
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}

Expand Down
2 changes: 1 addition & 1 deletion src/backend/effects/builtin/toggle-command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down
2 changes: 1 addition & 1 deletion src/backend/effects/builtin/toggle-scheduled-task.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down
2 changes: 1 addition & 1 deletion src/backend/effects/builtin/toggle-timer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion src/backend/effects/builtin/update-channel-reward.ts
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ const model: EffectType<EffectMeta> = {
}

const rewards = Object.values(channelRewardsManager.channelRewards as Record<string, RewardWithTags>)
.filter(reward => reward.sortTags.includes(effect.sortTagId) && reward.manageable);
.filter(reward => reward.sortTags?.includes(effect.sortTagId) && reward.manageable);

const promises: Promise<SavedChannelReward>[] = [];

Expand Down

0 comments on commit 18c361c

Please sign in to comment.