Skip to content

Fix chat notification race condition that clears messages - Remove pr… #2462

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged

Conversation

temimedical
Copy link

Problem

Chat notifications clear existing messages when tapped, causing users to lose their conversation history.

Root Cause

A race condition in HomePageWrapper.initState() was prematurely resetting selectedChatAppId to null before notification route processing completed.

Solution

Remove the premature setSelectedChatAppId(null) call that was causing the race condition.

Testing

✅ Verified that tapping chat notifications now preserves existing messages
✅ No regressions in normal app functionality

Impact

Files changed: 1 file, 3 lines removed

Technical Details

The issue occurred because context.read<AppProvider>().setSelectedChatAppId(null) was being called in the initState() callback, which would execute before notification navigation completed. This caused the MessageProvider to clear messages when notifications tried to navigate to specific chats.

By removing this premature reset, notifications can now properly navigate to chat without interfering with existing message state.

…emature selectedChatAppId reset in HomePageWrapper.initState() - This was causing a race condition where notification navigation would clear chat messages - The app ID was being reset to null before notification route processing completed - Now notifications properly navigate to chat without clearing existing messages - Fixes BasedHardware#2442
Copy link

vercel bot commented May 28, 2025

Someone is attempting to deploy a commit to the kodjima33's projects Team on Vercel.

A member of the Team first needs to authorize it.

@mdmohsin7
Copy link
Member

Hi @temimedical pls set the line length to 120 in your code editor

…120-character line width as requested - Maintains the same functionality while improving code style consistency
@temimedical
Copy link
Author

Thanks for the feedback! I've configured my code editor to use 120-character line length as requested.

@mdmohsin7
Copy link
Member

This is not the complete fix, requires backend changes to save notifications sent through the /notifications route, but we can do that in another PR

@mdmohsin7 mdmohsin7 merged commit 9599e95 into BasedHardware:main Jun 1, 2025
1 check failed
@temimedical
Copy link
Author

Thanks for merging this!
I saw your note about needing backend changes to fully support /notifications. I’d definitely be up for helping with that in a follow-up PR.

Right now I’m using the provided backend URL for dev, so I can’t make backend changes directly. Should I spin up a local version, or is there a way I can contribute to the official backend?

Let me know how you’d like to handle it, happy to help however works best.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

chat clears on tapping an omi app notification
2 participants