mirror of
https://github.com/NapNeko/NapCatQQ.git
synced 2026-02-13 00:10:27 +00:00
build: 1.5.9 - test2
This commit is contained in:
@@ -1,12 +1,22 @@
|
||||
import { rawFriends } from '@/core/data';
|
||||
import BaseAction from '../BaseAction';
|
||||
import { ActionName } from '../types';
|
||||
import { BuddyCategoryType } from '@/core/entities/';
|
||||
import { FromSchema, JSONSchema } from 'json-schema-to-ts';
|
||||
import { NTQQFriendApi } from '@/core';
|
||||
|
||||
export class GetFriendWithCategory extends BaseAction<void, Array<BuddyCategoryType>> {
|
||||
const SchemaData = {
|
||||
type: 'object',
|
||||
properties: {
|
||||
no_cache: { type: ['boolean', 'string'] },
|
||||
}
|
||||
} as const satisfies JSONSchema;
|
||||
|
||||
type Payload = FromSchema<typeof SchemaData>;
|
||||
|
||||
export class GetFriendWithCategory extends BaseAction<Payload, BuddyCategoryType[]> {
|
||||
actionName = ActionName.GetFriendsWithCategory;
|
||||
|
||||
protected async _handle(payload: void) {
|
||||
return rawFriends;
|
||||
protected async _handle(payload: Payload) {
|
||||
return await NTQQFriendApi.getFriendsRaw(payload?.no_cache?.toString() === 'true');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import { OB11User } from '../../types';
|
||||
import { OB11Constructor } from '../../constructor';
|
||||
import { friends } from '@/core/data';
|
||||
import BaseAction from '../BaseAction';
|
||||
import { ActionName } from '../types';
|
||||
import { NTQQFriendApi } from '@/core';
|
||||
@@ -20,16 +19,6 @@ export default class GetFriendList extends BaseAction<Payload, OB11User[]> {
|
||||
actionName = ActionName.GetFriendList;
|
||||
PayloadSchema = SchemaData;
|
||||
protected async _handle(payload: Payload) {
|
||||
if (friends.size === 0 || payload?.no_cache === true || payload?.no_cache === 'true') {
|
||||
const _friends = await NTQQFriendApi.getFriends(true);
|
||||
// log('强制刷新好友列表,结果: ', _friends)
|
||||
if (_friends.length > 0) {
|
||||
friends.clear();
|
||||
for (const friend of _friends) {
|
||||
friends.set(friend.uid, friend);
|
||||
}
|
||||
}
|
||||
}
|
||||
return OB11Constructor.friends(Array.from(friends.values()));
|
||||
return OB11Constructor.friends(await NTQQFriendApi.getFriends(payload?.no_cache?.toString() === 'true'));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user