Skip to content

Commit 843e413

Browse files
fix: remove possiblity of duplicated instance of DataLoader (#688)
1 parent 9aaf660 commit 843e413

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

types/global.d.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import * as Yup from 'yup'
33
import { Client } from 'discord.js'
44
import NotificationManager from '@utils/NotificationManager'
5+
import { CacheManager } from '@utils/Query'
56

67
declare global {
78
interface Window {
@@ -14,6 +15,7 @@ declare global {
1415
var kodl: Client
1516
var serverlist: Client
1617
var notification: NotificationManager
18+
var get: CacheManager
1719
interface Navigator {
1820
standalone?: boolean
1921
}

utils/Query.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1199,7 +1199,7 @@ async function viewBot(id: string) {
11991199
await Bots.findByIdAndUpdate(id, { $push: { viewMetrix: { count: 0 } } }, { upsert: true })
12001200
}
12011201

1202-
export const get = {
1202+
const _get = {
12031203
discord: {
12041204
user: new DataLoader(
12051205
async (ids: string[]) =>
@@ -1414,6 +1414,14 @@ export const get = {
14141414
},
14151415
}
14161416

1417+
export type CacheManager = typeof _get
1418+
1419+
if (!global.get) {
1420+
global.get = _get
1421+
}
1422+
1423+
export const get = global.get
1424+
14171425
export const update = {
14181426
assignToken,
14191427
resetBotToken,

0 commit comments

Comments
 (0)