Skip to content

Commit

Permalink
fix: Fixed chat.list with onlyUnreadMessages is true
Browse files Browse the repository at this point in the history
  • Loading branch information
icleitoncosta committed Nov 16, 2024
1 parent 3d7b803 commit 3d3aff2
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/chat/patch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ function applyPatchModel() {
isPSA: functions.getIsPSA,
previewMessage: functions.getPreviewMessage,
showChangeNumberNotification: functions.getShowChangeNumberNotification,
hasUnread: functions.getHasUnread,
};

for (const attr in funcs) {
Expand Down
13 changes: 13 additions & 0 deletions src/whatsapp/functions/getShouldAppearInList.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ export declare function getShowChangeNumberNotification(
chat: ChatModel
): boolean;
export declare function getShouldShowUnreadDivider(chat: ChatModel): boolean;
export declare function getHasUnread(chat: ChatModel): boolean;

exportModule(
exports,
Expand All @@ -43,10 +44,22 @@ exportModule(
m.getShouldShowUnreadDivider
);

exportModule(
exports,
{
getHasUnread: 'getHasUnread',
},
(m) => m.getHasUnread
);

injectFallbackModule('getShouldAppearInList', {
getShouldAppearInList: (chat: ChatModel) => chat.shouldAppearInList,
getPreviewMessage: (chat: ChatModel) => chat.previewMessage,
getShowChangeNumberNotification: (chat: ChatModel) =>
chat.showChangeNumberNotification,
getShouldShowUnreadDivider: (chat: ChatModel) => chat.shouldShowUnreadDivider,
});

injectFallbackModule('getHasUnread', {
getHasUnread: (chat: ChatModel) => chat.hasUnread,
});
4 changes: 4 additions & 0 deletions src/whatsapp/models/ChatModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,10 @@ interface Derived {
isBroadcast: boolean;
isNewsletter: boolean;
canUnread: boolean;
/**
* Deprecated in favor of getHasUnread
* @deprecated
*/
hasUnread: boolean;
optimisticUnreadCount?: any;
/**
Expand Down

0 comments on commit 3d3aff2

Please sign in to comment.