Describe the bug
Can't get a list of unread messages.
Steps to Reproduce
As per indicated in the pest practices in the readme, one should be able to process new messages when wa-automate session is created.
The docs state that this could be accomplished by const unreadMessages = await client.getAllUnreadMessages();
However, as you can see from the attached screenshot, this is not working, as it returns empty arrays:

create() code
This is the code you use to create the client. e.g
const client = await wa.create(
`session_123`,
{
headless: false,
defaultViewport: false,
args: ['--start-maximized', '--window-size=1920,1080' ]
},
);
Trying to debug this, I followed the code path and noticed that WAPI.getAllNewMessages() works up until the filter of c.msgs._models, because even the new messages, still unread (haven't clicked it's chat window yet) are being returned with isNewMsg: undefined

Expected behavior
It should return new messages for processing.
DEBUG INFO
โโโโโค
โ WA_VERSION โ '2.2013.7' โ
โ PAGE_UA โ 'WhatsApp/0.4.613 Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.88 Safari/537.36' โ
โ WA_AUTOMATE_VERSION โ '1.8.44' โ
โ BROWSER_VERSION โ 'Chrome/80.0.3987.0'
Screenshots
If applicable, add screenshots to help explain your problem. Use headless: false to get screenshots
Host (please complete the following information):
Additional context
The documentation is not very clear about the difference between getAllUnreadMessages and getAllUnreadMessages and getAllNewMessages.
Hey @feliperaul,
Thanks for following the issue template.
The distinction is based on the actual properties of the messages - which may not get updated in real time.
ack: -1isNewMsg: trueSo although they're technically correct, it's not really what people expect (i.e the messages represented with the numbers in the chat list).
@github-actions run
โก Release! โก
(async () => {
function exec(cmd) {
console.log(execSync(cmd).toString());
}
// Config
const gitUserEmail = "github-actions[bot]@users.noreply.github.com";
const gitUserName = "github-actions[bot]";
exec(`echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" > .npmrc`);
exec(`git config --global user.email "${gitUserEmail}"`);
exec(`git config --global user.name "${gitUserName}"`);
exec(`npm i`);
exec(`npm run release-ci`);
var result = execSync(`npx auto-changelog -o ./tempchangelog.txt --commit-limit false --template ./compact-keepachangelog.hbs --stdout`).toString();
await postComment(result);
})();
@feliperaul Please try:
const newChatsWithNewMessages = await client.getIndicatedNewMessages()
It returns an array of objects:
[{
"id": "[email protected]", //the id of the chat with new messages
"indicatedNewMessages": [] //array of messages, not including any messages by the host phone
}]
@smashah Working great Shah! Thank you so much.
Just a correction, it was missing the function invocation:
const newChatsWithNewMessages = await client.getIndicatedNewMessages();
Most helpful comment
@feliperaul Please try:
It returns an array of objects: