fix: show notifications when app backgrounded on active conversation#648
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 notifications for the active conversation were incorrectly suppressed even when the screen was locked or the app was backgrounded, by adding a Key changes:
Confidence Score: 3/5
Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[notifyMessageReceived called] --> B{Master toggle on?}
B -- No --> Z[return — no notification]
B -- Yes --> C{Message notifications enabled?}
C -- No --> Z
C -- Yes --> D{Has notification permission?}
D -- No --> Z
D -- Yes --> E{isAppInForeground\nAND\nactiveConversation == hash?}
E -- Yes → suppress --> Z
E -- No → allow --> F[Build & post notification]
|
app/src/main/java/com/lxmf/messenger/notifications/NotificationHelper.kt
Outdated
Show resolved
Hide resolved
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>
Summary
ProcessLifecycleOwnerforeground check so notifications are only suppressed when the app is actually visiblelifecycle-processdependency to the app moduleTest plan
🤖 Generated with Claude Code