mirror of
https://github.com/NapNeko/NapCatQQ.git
synced 2024-11-16 13:01:14 +00:00
chore: clean code for friend.ts
This commit is contained in:
parent
9c5f3f1946
commit
03c056702c
@ -16,47 +16,42 @@ export class NTQQFriendApi {
|
|||||||
// }
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
async getBuddyV2(refresh = false): Promise<FriendV2[]> {
|
async getBuddyV2SimpleInfoMap(refresh = false) {
|
||||||
const uids: string[] = [];
|
|
||||||
const buddyService = this.context.session.getBuddyService();
|
const buddyService = this.context.session.getBuddyService();
|
||||||
const buddyListV2 = refresh ? await buddyService.getBuddyListV2('0', BuddyListReqType.KNOMAL) : await buddyService.getBuddyListV2('0', BuddyListReqType.KNOMAL);
|
const buddyListV2 = refresh ? await buddyService.getBuddyListV2('0', BuddyListReqType.KNOMAL) : await buddyService.getBuddyListV2('0', BuddyListReqType.KNOMAL);
|
||||||
uids.push(...buddyListV2.data.flatMap(item => item.buddyUids));
|
const uids = buddyListV2.data.flatMap(item => item.buddyUids);
|
||||||
const data = await this.core.eventWrapper.callNoListenerEvent(
|
return await this.core.eventWrapper.callNoListenerEvent(
|
||||||
'NodeIKernelProfileService/getCoreAndBaseInfo', 'nodeStore', uids,
|
'NodeIKernelProfileService/getCoreAndBaseInfo',
|
||||||
|
'nodeStore',
|
||||||
|
uids,
|
||||||
);
|
);
|
||||||
return Array.from(data.values());
|
}
|
||||||
|
|
||||||
|
async getBuddyV2(refresh = false): Promise<FriendV2[]> {
|
||||||
|
return Array.from((await this.getBuddyV2SimpleInfoMap(refresh)).values());
|
||||||
}
|
}
|
||||||
|
|
||||||
async getBuddyIdMap(refresh = false): Promise<LimitedHashTable<string, string>> {
|
async getBuddyIdMap(refresh = false): Promise<LimitedHashTable<string, string>> {
|
||||||
const uids: string[] = [];
|
|
||||||
const retMap: LimitedHashTable<string, string> = new LimitedHashTable<string, string>(5000);
|
const retMap: LimitedHashTable<string, string> = new LimitedHashTable<string, string>(5000);
|
||||||
const buddyService = this.context.session.getBuddyService();
|
const data = await this.getBuddyV2SimpleInfoMap(refresh);
|
||||||
const buddyListV2 = refresh ? await buddyService.getBuddyListV2('0', BuddyListReqType.KNOMAL) : await buddyService.getBuddyListV2('0', BuddyListReqType.KNOMAL);
|
data.forEach((value) => retMap.set(value.uin!, value.uid!));
|
||||||
uids.push(...buddyListV2.data.flatMap(item => item.buddyUids));
|
|
||||||
const data = await this.core.eventWrapper.callNoListenerEvent(
|
|
||||||
'NodeIKernelProfileService/getCoreAndBaseInfo', 'nodeStore', uids,
|
|
||||||
);
|
|
||||||
data.forEach((value) => {
|
|
||||||
retMap.set(value.uin!, value.uid!);
|
|
||||||
});
|
|
||||||
//console.log('getBuddyIdMap', retMap.getValue);
|
|
||||||
return retMap;
|
return retMap;
|
||||||
}
|
}
|
||||||
|
|
||||||
async getBuddyV2ExWithCate(refresh = false) {
|
async getBuddyV2ExWithCate(refresh = false) {
|
||||||
const uids: string[] = [];
|
|
||||||
const categoryMap: Map<string, any> = new Map();
|
const categoryMap: Map<string, any> = new Map();
|
||||||
const buddyService = this.context.session.getBuddyService();
|
const buddyService = this.context.session.getBuddyService();
|
||||||
const buddyListV2 = refresh ? (await buddyService.getBuddyListV2('0', BuddyListReqType.KNOMAL)).data : (await buddyService.getBuddyListV2('0', BuddyListReqType.KNOMAL)).data;
|
const buddyListV2 = refresh ? (await buddyService.getBuddyListV2('0', BuddyListReqType.KNOMAL)).data : (await buddyService.getBuddyListV2('0', BuddyListReqType.KNOMAL)).data;
|
||||||
uids.push(
|
const uids = buddyListV2.flatMap(item => {
|
||||||
...buddyListV2.flatMap(item => {
|
item.buddyUids.forEach(uid => {
|
||||||
item.buddyUids.forEach(uid => {
|
categoryMap.set(uid, { categoryId: item.categoryId, categoryName: item.categroyName });
|
||||||
categoryMap.set(uid, { categoryId: item.categoryId, categoryName: item.categroyName });
|
});
|
||||||
});
|
return item.buddyUids;
|
||||||
return item.buddyUids;
|
});
|
||||||
}));
|
|
||||||
const data = await this.core.eventWrapper.callNoListenerEvent(
|
const data = await this.core.eventWrapper.callNoListenerEvent(
|
||||||
'NodeIKernelProfileService/getCoreAndBaseInfo', 'nodeStore', uids,
|
'NodeIKernelProfileService/getCoreAndBaseInfo',
|
||||||
|
'nodeStore',
|
||||||
|
uids,
|
||||||
);
|
);
|
||||||
return buddyListV2.map(category => ({
|
return buddyListV2.map(category => ({
|
||||||
categoryId: category.categoryId,
|
categoryId: category.categoryId,
|
||||||
|
Loading…
Reference in New Issue
Block a user