Skip to content

Commit

Permalink
fix: Fixed getAllUnreadMessages with beta MD (fix #643)
Browse files Browse the repository at this point in the history
  • Loading branch information
edgardmessias committed Nov 11, 2021
1 parent 5f8ac35 commit c70f44d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 31 deletions.
5 changes: 2 additions & 3 deletions src/lib/wapi/functions/get-all-unread-messages.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,8 @@ import { getAllChatsWithNewMessages } from './get-chats-with-new-messages';
*/
export const getAllUnreadMessages = async function () {
const queries = getAllChatsWithNewMessages().map((c) =>
Store.Msg.findQuery({
remote: c.id,
count: c.unreadCount - 1,
WPP.chat.getMessages(c.id, {
count: c.unreadCount,
})
);

Expand Down
35 changes: 7 additions & 28 deletions src/lib/wapi/serializers/serialize-message.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,32 +19,15 @@ export const _serializeMessageObj = (obj) => {
if (obj == undefined) {
return null;
}
if (obj.quotedMsg) obj.quotedMsgObj();
if (obj.quotedMsg && obj.quotedMsgObj) obj.quotedMsgObj();
return Object.assign(window.WAPI._serializeRawObj(obj), {
id: obj.id._serialized,
from: obj.from._serialized,
quotedParticipant: obj.quotedParticipant
? obj.quotedParticipant._serialized
? obj.quotedParticipant._serialized
: undefined
: undefined,
author: obj.author
? obj.author._serialized
? obj.author._serialized
: undefined
: undefined,
chatId:
obj.id && obj.id.remote
? obj.id.remote
: obj.chatId && obj.chatId._serialized
? obj.chatId._serialized
: undefined,
to: obj.to
? obj.to._serialized
? obj.to._serialized
: undefined
: undefined,
fromMe: obj.id.fromMe,
quotedParticipant: obj?.quotedParticipant?._serialized,
author: obj?.author?._serialized,
chatId: obj?.id?.remote || obj?.chatId?._serialized,
to: obj?.to?._serialized,
fromMe: obj?.id?.fromMe,
sender: obj['senderObj']
? WAPI._serializeContactObj(obj['senderObj'])
: null,
Expand All @@ -57,11 +40,7 @@ export const _serializeMessageObj = (obj) => {
isNotification: obj.isNotification,
isPSA: obj.isPSA,
type: obj.type,
quotedMsgId: obj._quotedMsgObj
? obj._quotedMsgObj.id
? obj._quotedMsgObj.id._serialized
: obj._quotedMsgObj.id._serialized
: undefined,
quotedMsgId: obj?._quotedMsgObj?.id?._serialized,
mediaData: window.WAPI._serializeRawObj(obj['mediaData']),
});
};

0 comments on commit c70f44d

Please sign in to comment.