fix: remove possiblity of duplicated instance of DataLoader (#688)

This commit is contained in:
SKINMAKER 2025-06-30 08:55:44 +09:00 committed by GitHub
parent 9aaf66018f
commit 843e4137cb
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 11 additions and 1 deletions

2
types/global.d.ts vendored
View File

@ -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
} }

View File

@ -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,