mirror of
https://github.com/chrononeko/chronocat.git
synced 2024-11-16 12:51:39 +00:00
fix(api): fix invoke
This commit is contained in:
parent
b3589da439
commit
62030ddf7f
@ -1,16 +1,10 @@
|
||||
import type {
|
||||
Group,
|
||||
Profile,
|
||||
RedIpcData,
|
||||
RedIpcEvent,
|
||||
RedMessage,
|
||||
} from '@chronocat/red'
|
||||
import type { Group, Profile, RedIpcData, RedMessage } from '@chronocat/red'
|
||||
import { ChronoEventEmitter } from './emitter'
|
||||
|
||||
export const requestMethodMap: Record<string, string> = {}
|
||||
export const requestCallbackMap: Record<
|
||||
string,
|
||||
(this: RedIpcEvent, detail: RedIpcData) => void
|
||||
(/* this: RedIpcEvent, */ detail: RedIpcData) => void
|
||||
> = {}
|
||||
|
||||
export const groupMap: Record<string, Group> = {}
|
||||
|
@ -23,6 +23,7 @@ import {
|
||||
chronoEventEmitter,
|
||||
friendMap,
|
||||
groupMap,
|
||||
requestCallbackMap,
|
||||
requestMethodMap,
|
||||
richMediaDownloadMap,
|
||||
sendCallbackMap,
|
||||
@ -192,10 +193,15 @@ export const apply = async (ctx: ChronocatContext) => {
|
||||
}
|
||||
|
||||
case 'wrapped-response': {
|
||||
const res = requestCallbackMap[data.id]
|
||||
if (res) res(data.args[1] /* RedIpcDataResponse */)
|
||||
|
||||
const method = requestMethodMap[data.id]
|
||||
if (!method) return
|
||||
delete requestMethodMap[data.id]
|
||||
void dispatcher(method, data.args[1] /* RedIpcDataResponse */)
|
||||
if (method) {
|
||||
delete requestMethodMap[data.id]
|
||||
void dispatcher(method, data.args[1] /* RedIpcDataResponse */)
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
}
|
||||
|
@ -18,8 +18,8 @@ export const invoke = async (
|
||||
channel,
|
||||
{
|
||||
sender: {
|
||||
send: (...args: unknown[]) => {
|
||||
resolve(args)
|
||||
send: (..._args: unknown[]) => {
|
||||
// resolve(args)
|
||||
},
|
||||
},
|
||||
},
|
||||
|
Loading…
Reference in New Issue
Block a user