Problem: If a user receives a text message, but has never opened the message conversation before, they will not receive a notification on their phone.
Fixes issue: https://github.com/project-error/npwd/issues/1017
Repro steps:
PlayerA just logs in and never opens their phone
PlayerB sends a text msg to PlayerA
Actual: PlayerA does not receive a notification
Expected: PlayerA should receive a notification
The reason this is happening is because of the following error. We are trying to read id from activeMessageConversation which is undefined.
Fix:
Instead of trying to read from activeMessageConversation we can use the convId that is already passed to the addNotification function. This is sufficient as it will always pass the id of the conversation that the msg was for and doesn't have a need to rely on the active conversation.
Additionally in the handleUpdateMessages function, there is a comparison to the activeConversation.id, which also throws a can't read id from undefined error because activeConversation could be undefined. Fixed this error by using optional chaining (?.) to make sure the variable is defined before trying to access variables from it.
Pull Request Description
Problem: If a user receives a text message, but has never opened the message conversation before, they will not receive a notification on their phone. Fixes issue: https://github.com/project-error/npwd/issues/1017
Repro steps:
The reason this is happening is because of the following error. We are trying to read
id
fromactiveMessageConversation
which is undefined.Fix: Instead of trying to read from
activeMessageConversation
we can use theconvId
that is already passed to theaddNotification
function. This is sufficient as it will always pass the id of the conversation that the msg was for and doesn't have a need to rely on the active conversation.Additionally in the
handleUpdateMessages
function, there is a comparison to theactiveConversation.id
, which also throws acan't read id from undefined
error becauseactiveConversation
could be undefined. Fixed this error by using optional chaining (?.
) to make sure the variable is defined before trying to access variables from it.Demo: https://github.com/project-error/npwd/assets/18689469/bf6751ff-c222-4304-a21d-7fb685e6aba8
Pull Request Checklist: