fix: show notifications when app backgrounded on active conversation#649
Conversation
Notifications were suppressed for the active conversation even when the screen was off or the app was in the background, because the ViewModel (and its active conversation state) survives those lifecycle events. Now checks ProcessLifecycleOwner to confirm the app is actually in the foreground before suppressing. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Greptile SummaryThis PR fixes a bug where message notifications were incorrectly suppressed while a conversation was open but the device screen was off or the app was backgrounded — because the ViewModel's active-conversation state persists across those lifecycle events. The fix wraps the suppression guard with a
Confidence Score: 4/5
Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[notifyMessageReceived called] --> B{Master toggle\nenabled?}
B -- No --> Z[return — no notification]
B -- Yes --> C{Message notifications\nenabled?}
C -- No --> Z
C -- Yes --> D{Has notification\npermission?}
D -- No --> Z
D -- Yes --> E{isAppInForeground?}
E -- No --> G[Post notification]
E -- Yes --> F{activeConversation\n== destinationHash?}
F -- Yes --> Z
F -- No --> G
|
app/src/main/java/com/lxmf/messenger/notifications/NotificationHelper.kt
Outdated
Show resolved
Hide resolved
Extract foreground check into @VisibleForTesting property so tests can control it. Update existing suppression test to simulate foreground state and add new test verifying notifications fire when app is backgrounded. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
Summary
ProcessLifecycleOwnerforeground check so notifications are only suppressed when the app is actually visiblelifecycle-processdependency to the app moduleTest plan
🤖 Generated with Claude Code