mirror of
https://github.com/NapNeko/NapCatQQ.git
synced 2025-07-19 12:03:37 +00:00
refactor: recall get_group_list if groups is empty
This commit is contained in:
@@ -3,19 +3,24 @@ import { OB11Constructor } from '../../constructor';
|
||||
import BaseAction from '../BaseAction';
|
||||
import { ActionName } from '../types';
|
||||
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;
|
||||
|
||||
protected async _handle(payload: null) {
|
||||
if (groups.size === 0) {
|
||||
//todo: get groups
|
||||
// const groups = await NTQQGroupApi.getGroups(true)
|
||||
// log("get groups", groups)
|
||||
protected async _handle(payload: Payload) {
|
||||
let groupList: Group[] = Array.from(groups.values());
|
||||
if (groupList.length === 0) {
|
||||
groupList = await NTQQGroupApi.getGroups(payload.no_cache === true);
|
||||
// log('get groups', groups);
|
||||
}
|
||||
return OB11Constructor.groups(Array.from(groups.values()));
|
||||
return OB11Constructor.groups(groupList);
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user