Skip to content

Commit

Permalink
fix: Fixed WPP.chat.openChatAt function (#2630)
Browse files Browse the repository at this point in the history
  • Loading branch information
opsJson authored Jan 28, 2025
1 parent f484647 commit f3ae21c
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 7 deletions.
10 changes: 7 additions & 3 deletions src/chat/functions/openChatAt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,11 @@ export async function openChatAt(

const msg = await getMessageById(messageId);

const result = getSearchContext(chat, msg);

return await Cmd.openChatAt(chat, result);
try {
const msgContext = getSearchContext(chat, msg);
return await Cmd.openChatAt(chat, msgContext);
} catch (e) {
const msgContext = getSearchContext(chat, msg.id._serialized);
return await Cmd.openChatAt({ chat, msgContext });
}
}
4 changes: 2 additions & 2 deletions src/whatsapp/functions/getSearchContext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ import { ChatModel, MsgModel } from '../models';
* @whatsapp 738599 >= 2.2242.5
*/
export declare function getSearchContext(
chat: ChatModel,
msg: MsgModel | MsgKey,
chat: ChatModel | string,
msg: MsgModel | MsgKey | string,
options?: {
isQuotedMsgAvailable: boolean;
}
Expand Down
6 changes: 5 additions & 1 deletion src/whatsapp/misc/Cmd.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,12 @@ export declare class CmdClass extends EventEmitter {
_openChat(e?: any, t?: any): void;
openChatAt(
chat: ChatModel,
context: ReturnType<typeof getSearchContext>
msgContext: ReturnType<typeof getSearchContext>
): Promise<boolean>;
openChatAt(params?: {
chat: ChatModel;
msgContext: ReturnType<typeof getSearchContext>;
}): Promise<boolean>;
openChatFromUnread(chat: ChatModel): Promise<boolean>;
openChatBottom(chat: ChatModel): Promise<boolean>;
scrollToPtt(e?: any): void;
Expand Down
3 changes: 2 additions & 1 deletion src/whatsapp/models/ChatModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,8 @@ export declare class ChatModel extends ModelChatBase {
isMostRecentCMC(e?: any): boolean;
loadRecentMsgs(e?: any): any;
getSearchContext?(
msg: MsgModel | MsgKey,
chat: ChatModel | string,
msg: MsgModel | MsgKey | string,
options?: {
isQuotedMsgAvailable: boolean;
}
Expand Down

0 comments on commit f3ae21c

Please sign in to comment.