When encountering a new contact's message, no notification is sent, and no message badge appears.
After running the source code, I found the following issue: new message notifications are obtained via threadsById, but when a new contact joins the session for the first time, threadsById = {}, causing the following code to return. Ultimately, this results in no notification for new contacts' messages.

When encountering a new contact's message, no notification is sent, and no message badge appears.
After running the source code, I found the following issue: new message notifications are obtained via
threadsById, but when a new contact joins the session for the first time,threadsById = {}, causing the following code to return. Ultimately, this results in no notification for new contacts' messages.