[core] Fix groups sort by
Release / WEBJS - chrome - amd64 - chrome (push) Waiting to run
Release / WEBJS - chromium - amd64 - latest (push) Waiting to run
Release / WEBJS - chromium - linux/arm64 - arm (push) Waiting to run
Release / NOWEB - none - amd64 - noweb (push) Waiting to run
Release / NOWEB - none - linux/arm64 - noweb-arm (push) Waiting to run

This commit is contained in:
devlikepro committed 2024-12-09 11:30:39 +07:00
1 parent d55895389a
commit 703b0b4cde
2 files changed
+12 -1

No files matched your search

@@ -55,6 +55,7 @@ import {
} from '@waha/structures/enums.dto';
import {
CreateGroupRequest,
GroupSortField,
ParticipantsRequest,
SettingsSecurityChangeInfo,
} from '@waha/structures/groups.dto';
@@ -793,6 +794,16 @@ export class WhatsappSessionWebJSCore extends WhatsappSession {
public async getGroups(pagination: PaginationParams) {
const chats = await this.whatsapp.getChats();
const groups = lodash.filter(chats, (chat) => chat.isGroup);
switch (pagination.sortBy) {
case GroupSortField.ID:
pagination.sortBy = 'id._serialized';
break;
case GroupSortField.SUBJECT:
pagination.sortBy = 'groupMetadata.subject';
break;
}
const paginator = new PaginatorInMemory(pagination);
return paginator.apply(groups);
}
+1 -1
View File
@@ -57,7 +57,7 @@ export class CreateGroupRequest {
participants: Array<Participant>;
}
enum GroupSortField {
export enum GroupSortField {
ID = 'id',
SUBJECT = 'subject',
}