mirror of
https://github.com/koreanbots/core.git
synced 2025-12-15 22:10:24 +00:00
fix: remove possiblity of duplicated instance of DataLoader (#688)
This commit is contained in:
parent
9aaf66018f
commit
843e4137cb
2
types/global.d.ts
vendored
2
types/global.d.ts
vendored
@ -2,6 +2,7 @@
|
|||||||
import * as Yup from 'yup'
|
import * as Yup from 'yup'
|
||||||
import { Client } from 'discord.js'
|
import { Client } from 'discord.js'
|
||||||
import NotificationManager from '@utils/NotificationManager'
|
import NotificationManager from '@utils/NotificationManager'
|
||||||
|
import { CacheManager } from '@utils/Query'
|
||||||
|
|
||||||
declare global {
|
declare global {
|
||||||
interface Window {
|
interface Window {
|
||||||
@ -14,6 +15,7 @@ declare global {
|
|||||||
var kodl: Client
|
var kodl: Client
|
||||||
var serverlist: Client
|
var serverlist: Client
|
||||||
var notification: NotificationManager
|
var notification: NotificationManager
|
||||||
|
var get: CacheManager
|
||||||
interface Navigator {
|
interface Navigator {
|
||||||
standalone?: boolean
|
standalone?: boolean
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1199,7 +1199,7 @@ async function viewBot(id: string) {
|
|||||||
await Bots.findByIdAndUpdate(id, { $push: { viewMetrix: { count: 0 } } }, { upsert: true })
|
await Bots.findByIdAndUpdate(id, { $push: { viewMetrix: { count: 0 } } }, { upsert: true })
|
||||||
}
|
}
|
||||||
|
|
||||||
export const get = {
|
const _get = {
|
||||||
discord: {
|
discord: {
|
||||||
user: new DataLoader(
|
user: new DataLoader(
|
||||||
async (ids: string[]) =>
|
async (ids: string[]) =>
|
||||||
@ -1414,6 +1414,14 @@ export const get = {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export type CacheManager = typeof _get
|
||||||
|
|
||||||
|
if (!global.get) {
|
||||||
|
global.get = _get
|
||||||
|
}
|
||||||
|
|
||||||
|
export const get = global.get
|
||||||
|
|
||||||
export const update = {
|
export const update = {
|
||||||
assignToken,
|
assignToken,
|
||||||
resetBotToken,
|
resetBotToken,
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user