Skip to content

Commit

Permalink
fix: Fixed compatibility with WhatsApp Web >= 2.2220.8
Browse files Browse the repository at this point in the history
  • Loading branch information
edgardmessias committed Jun 4, 2022
1 parent ce2ded5 commit 29a00fb
Show file tree
Hide file tree
Showing 8 changed files with 11 additions and 14 deletions.
2 changes: 1 addition & 1 deletion src/blocklist/functions/all.ts
Expand Up @@ -17,5 +17,5 @@
import { BlocklistStore, Wid } from '../../whatsapp';

export function all(): Wid[] {
return BlocklistStore.models.map((b) => b.id);
return BlocklistStore.getModelsArray().map((b) => b.id);
}
2 changes: 1 addition & 1 deletion src/chat/events/registerLiveLocationUpdateEvent.ts
Expand Up @@ -105,7 +105,7 @@ function registerLiveLocationUpdateEvent() {
* Start for all active chats
*/
ChatStore.once('collection_has_synced', () => {
const chats = ChatStore.models.slice(0, config.liveLocationLimit);
const chats = ChatStore.getModelsArray().slice(0, config.liveLocationLimit);
chats.forEach((chat) => {
LiveLocationStore.update(chat.id)
.then((liveLocation) => {
Expand Down
5 changes: 3 additions & 2 deletions src/chat/events/registerPresenceChange.ts
Expand Up @@ -32,7 +32,7 @@ internalEv.on('conn.main_ready', () => {
function register() {
PresenceStore.on('change:chatstate.type', (chatstate: ChatstateModel) => {
// Search precense model from chatstate
const presence = PresenceStore.models.find(
const presence = PresenceStore.getModelsArray().find(
(m) => m.chatstate === chatstate
);

Expand All @@ -58,7 +58,8 @@ function register() {
}

if (presence.isGroup) {
data.participants = presence.chatstates.models
data.participants = presence.chatstates
.getModelsArray()
.filter((c) => !!c.type)
.map((c) => {
const contact = ContactStore.get(c.id);
Expand Down
2 changes: 1 addition & 1 deletion src/chat/functions/list.ts
Expand Up @@ -40,7 +40,7 @@ export interface ChatListOptions {
* @category Chat
*/
export async function list(options: ChatListOptions): Promise<ChatModel[]> {
let models = ChatStore.models;
let models = ChatStore.getModelsArray();

if (options.onlyUsers) {
models = models.filter((c) => c.isUser);
Expand Down
2 changes: 1 addition & 1 deletion src/group/functions/getParticipants.ts
Expand Up @@ -27,5 +27,5 @@ import { ensureGroup } from './';
*/
export async function getParticipants(groupId: string | Wid) {
const groupChat = await ensureGroup(groupId);
return groupChat.groupMetadata!.participants.models;
return groupChat.groupMetadata!.participants.getModelsArray();
}
2 changes: 1 addition & 1 deletion src/labels/functions/getAllLabels.ts
Expand Up @@ -19,7 +19,7 @@ import { LabelModel, LabelStore } from '../../whatsapp';
import { Label } from '..';

export async function getAllLabels(): Promise<Label[]> {
const labels = LabelStore.models;
const labels = LabelStore.getModelsArray();
return labels.map((e: LabelModel) => {
return {
id: e.id!,
Expand Down
2 changes: 1 addition & 1 deletion src/status/functions/sendRawStatus.ts
Expand Up @@ -81,7 +81,7 @@ webpack.onInjected(() => {
return await func(...args);
}

const myContacts = ContactStore.models
const myContacts = ContactStore.getModelsArray()
.filter((c) => c.isMyContact && !c.isContactBlocked)
.map((c) => c.id);

Expand Down
8 changes: 2 additions & 6 deletions src/whatsapp/collections/Collection.ts
Expand Up @@ -50,6 +50,8 @@ export declare class Collection<M, A = M | M[]> extends EventEmitter {

constructor(e?: any, t?: { parent: any });

get length(): number;

add(value: A | WritableProperties<A>, options?: Option): A;

set(value: A, options?: Option): A;
Expand All @@ -70,12 +72,6 @@ export declare class Collection<M, A = M | M[]> extends EventEmitter {

at(position: number): M | undefined;

get length(): number;

get isCollection(): boolean;

get models(): M[];

serialize(): any[];

toJSON(): any[];
Expand Down

0 comments on commit 29a00fb

Please sign in to comment.