refactor: get_group_list

This commit is contained in:
手瓜一十雪 2024-08-04 20:56:49 +08:00
parent e203abae85
commit 31824c0504

View File

@ -2,10 +2,8 @@ import { OB11Group } from '../../types';
import { OB11Constructor } from '../../constructor';
import BaseAction from '../BaseAction';
import { ActionName } from '../types';
import { groups } from '@/core/data';
import { NTQQGroupApi } from '@/core/apis';
import { Group } from '@/core/entities';
import { log } from '@/common/utils/log';
import { FromSchema, JSONSchema } from 'json-schema-to-ts';
// no_cache get时传字符串
const SchemaData = {
@ -21,11 +19,7 @@ class GetGroupList extends BaseAction<Payload, OB11Group[]> {
actionName = ActionName.GetGroupList;
PayloadSchema = SchemaData;
protected async _handle(payload: Payload) {
let groupList: Group[] = Array.from(groups.values());
if (groupList.length === 0 || payload?.no_cache === true || payload.no_cache === 'true') {
groupList = await NTQQGroupApi.getGroups(true);
// log('get groups', groups);
}
let groupList: Group[] = await NTQQGroupApi.getGroups(payload?.no_cache === true || payload.no_cache === 'true');
return OB11Constructor.groups(groupList);
}
}