mirror of
https://github.com/NapNeko/NapCatQQ.git
synced 2026-01-14 04:00:35 +00:00
refactor: recall get_group_list if groups is empty
This commit is contained in:
parent
031932f41c
commit
871b3a102b
@ -3,19 +3,24 @@ import { OB11Constructor } from '../../constructor';
|
|||||||
import BaseAction from '../BaseAction';
|
import BaseAction from '../BaseAction';
|
||||||
import { ActionName } from '../types';
|
import { ActionName } from '../types';
|
||||||
import { groups } from '@/common/data';
|
import { groups } from '@/common/data';
|
||||||
import {NTQQGroupApi} from "@/core/qqnt/apis";
|
import { NTQQGroupApi } from '@/core/qqnt/apis';
|
||||||
|
import { Group } from '@/core/qqnt/entities';
|
||||||
|
import { log } from '@/common/utils/log';
|
||||||
|
|
||||||
|
interface Payload {
|
||||||
|
no_cache: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
class GetGroupList extends BaseAction<null, OB11Group[]> {
|
class GetGroupList extends BaseAction<Payload, OB11Group[]> {
|
||||||
actionName = ActionName.GetGroupList;
|
actionName = ActionName.GetGroupList;
|
||||||
|
|
||||||
protected async _handle(payload: null) {
|
protected async _handle(payload: Payload) {
|
||||||
if (groups.size === 0) {
|
let groupList: Group[] = Array.from(groups.values());
|
||||||
//todo: get groups
|
if (groupList.length === 0) {
|
||||||
// const groups = await NTQQGroupApi.getGroups(true)
|
groupList = await NTQQGroupApi.getGroups(payload.no_cache === true);
|
||||||
// log("get groups", groups)
|
// log('get groups', groups);
|
||||||
}
|
}
|
||||||
return OB11Constructor.groups(Array.from(groups.values()));
|
return OB11Constructor.groups(groupList);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user