Skip to content

Commit

Permalink
fix: Improved speed of WPP.contact.queryExists to use local contact l…
Browse files Browse the repository at this point in the history
…ist first
  • Loading branch information
edgardmessias committed Nov 17, 2021
1 parent 61e8d45 commit fb0bd95
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/contact/Contact.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import Emittery from 'emittery';

import { assertWid } from '../assert';
import * as webpack from '../webpack';
import { Wid } from '../whatsapp';
import { ContactStore, Wid } from '../whatsapp';
import { sendQueryExists } from '../whatsapp/functions';
import { ContactEventTypes } from './types';

Expand All @@ -38,6 +38,15 @@ export class Contact extends Emittery<ContactEventTypes> {
async queryExists(contactId: string | Wid) {
const wid = assertWid(contactId);

const contact = ContactStore.get(wid);

if (contact) {
return {
wid,
biz: contact.isBusiness,
};
}

return await sendQueryExists(wid).catch(() => null);
}
}

0 comments on commit fb0bd95

Please sign in to comment.