From 5528010cc53eca7d832f205603b31bfa67b4afe8 Mon Sep 17 00:00:00 2001 From: Dark <7890309+DarkView@users.noreply.github.com> Date: Fri, 19 Mar 2021 01:57:29 +0100 Subject: [PATCH] Allow -r switch to reverse all filtering i.e. only show mutes --- backend/src/plugins/ModActions/commands/CasesUserCmd.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/backend/src/plugins/ModActions/commands/CasesUserCmd.ts b/backend/src/plugins/ModActions/commands/CasesUserCmd.ts index 2c15e392..c1869748 100644 --- a/backend/src/plugins/ModActions/commands/CasesUserCmd.ts +++ b/backend/src/plugins/ModActions/commands/CasesUserCmd.ts @@ -20,6 +20,7 @@ import { CaseTypes } from "../../../data/CaseTypes"; const opts = { expand: ct.bool({ option: true, isSwitch: true, shortcut: "e" }), hidden: ct.bool({ option: true, isSwitch: true, shortcut: "h" }), + reverseFilters: ct.switchOption({ shortcut: "r" }), onlyNotes: ct.switchOption({ shortcut: "n" }), onlyWarns: ct.switchOption({ shortcut: "w" }), onlyMutes: ct.switchOption({ shortcut: "m" }), @@ -57,7 +58,12 @@ export const CasesUserCmd = modActionsCmd({ if (args.onyUnmutes) typesToShow.push(CaseTypes.Unmute); if (args.onlyBans) typesToShow.push(CaseTypes.Ban); if (args.onyUnbans) typesToShow.push(CaseTypes.Unban); - if (typesToShow.length > 0) cases = cases.filter(c => typesToShow.includes(c.type)); + + if (typesToShow.length > 0) { + if (args.reverseFilters) cases = cases.filter(c => !typesToShow.includes(c.type)); + // Reversed: Hide specified types + else cases = cases.filter(c => typesToShow.includes(c.type)); // Normal: Show only specified types + } const normalCases = cases.filter(c => !c.is_hidden); const hiddenCases = cases.filter(c => c.is_hidden);