From 8edaa7506438bd35fb0391e18ca540ab5c4cd01d Mon Sep 17 00:00:00 2001 From: Dragory <2606411+Dragory@users.noreply.github.com> Date: Wed, 18 Aug 2021 02:01:56 +0300 Subject: [PATCH] Temp fix for circular dependency --- backend/src/plugins/Logs/LogsPlugin.ts | 3 +- .../Logs/events/LogsGuildMemberAddEvt.ts | 53 ++++++++++--------- 2 files changed, 28 insertions(+), 28 deletions(-) diff --git a/backend/src/plugins/Logs/LogsPlugin.ts b/backend/src/plugins/Logs/LogsPlugin.ts index d324cb11..c01ab594 100644 --- a/backend/src/plugins/Logs/LogsPlugin.ts +++ b/backend/src/plugins/Logs/LogsPlugin.ts @@ -7,7 +7,6 @@ import { GuildSavedMessages } from "../../data/GuildSavedMessages"; import { LogType } from "../../data/LogType"; import { logger } from "../../logger"; import { discardRegExpRunner, getRegExpRunner } from "../../regExpRunners"; -import { CasesPlugin } from "../Cases/CasesPlugin"; import { TimeAndDatePlugin } from "../TimeAndDate/TimeAndDatePlugin"; import { zeppelinGuildPlugin } from "../ZeppelinPluginBlueprint"; import { LogsChannelCreateEvt, LogsChannelDeleteEvt, LogsChannelUpdateEvt } from "./events/LogsChannelModifyEvts"; @@ -140,7 +139,7 @@ export const LogsPlugin = zeppelinGuildPlugin()({ prettyName: "Logs", }, - dependencies: [TimeAndDatePlugin, CasesPlugin], + dependencies: [TimeAndDatePlugin], configSchema: ConfigSchema, defaultOptions, diff --git a/backend/src/plugins/Logs/events/LogsGuildMemberAddEvt.ts b/backend/src/plugins/Logs/events/LogsGuildMemberAddEvt.ts index 60d7036a..c86a1fc3 100644 --- a/backend/src/plugins/Logs/events/LogsGuildMemberAddEvt.ts +++ b/backend/src/plugins/Logs/events/LogsGuildMemberAddEvt.ts @@ -2,7 +2,6 @@ import humanizeDuration from "humanize-duration"; import moment from "moment-timezone"; import { LogType } from "../../../data/LogType"; import { memberToTemplateSafeMember } from "../../../utils/templateSafeObjects"; -import { CasesPlugin } from "../../Cases/CasesPlugin"; import { logsEvt } from "../types"; import { logMemberJoin } from "../logFunctions/logMemberJoin"; import { logMemberJoinWithPriorRecords } from "../logFunctions/logMemberJoinWithPriorRecords"; @@ -18,31 +17,33 @@ export const LogsGuildMemberAddEvt = logsEvt({ member, }); - const cases = (await pluginData.state.cases.with("notes").getByUserId(member.id)).filter(c => !c.is_hidden); - cases.sort((a, b) => (a.created_at > b.created_at ? -1 : 1)); + // TODO: Uncomment below once circular dependencies in Knub have been fixed - if (cases.length) { - const recentCaseLines: string[] = []; - const recentCases = cases.slice(0, 2); - const casesPlugin = pluginData.getPlugin(CasesPlugin); - for (const theCase of recentCases) { - recentCaseLines.push((await casesPlugin.getCaseSummary(theCase))!); - } - - let recentCaseSummary = recentCaseLines.join("\n"); - if (recentCases.length < cases.length) { - const remaining = cases.length - recentCases.length; - if (remaining === 1) { - recentCaseSummary += `\n*+${remaining} case*`; - } else { - recentCaseSummary += `\n*+${remaining} cases*`; - } - } - - logMemberJoinWithPriorRecords(pluginData, { - member, - recentCaseSummary, - }); - } + // const cases = (await pluginData.state.cases.with("notes").getByUserId(member.id)).filter(c => !c.is_hidden); + // cases.sort((a, b) => (a.created_at > b.created_at ? -1 : 1)); + // + // if (cases.length) { + // const recentCaseLines: string[] = []; + // const recentCases = cases.slice(0, 2); + // const casesPlugin = pluginData.getPlugin(CasesPlugin); + // for (const theCase of recentCases) { + // recentCaseLines.push((await casesPlugin.getCaseSummary(theCase))!); + // } + // + // let recentCaseSummary = recentCaseLines.join("\n"); + // if (recentCases.length < cases.length) { + // const remaining = cases.length - recentCases.length; + // if (remaining === 1) { + // recentCaseSummary += `\n*+${remaining} case*`; + // } else { + // recentCaseSummary += `\n*+${remaining} cases*`; + // } + // } + // + // logMemberJoinWithPriorRecords(pluginData, { + // member, + // recentCaseSummary, + // }); + // } }, });