ActiveConversationTracker

Tracks which conversation the user is currently looking at, so the notification path does not buzz the phone for a message whose bubble is already animating onto the screen.

Only the message screen writes setActive/clearActive, on resume and pause. That is deliberately the only signal MessageAnnouncement.Suppress needs: backgrounding the app pauses the screen, which clears the key on its way out. appForeground is driven from the process lifecycle and only separates MessageAnnouncement.Silent from MessageAnnouncement.Alert.

Constructors

Link copied to clipboard
constructor()

Properties

Link copied to clipboard
val activeContactKey: StateFlow<String?>

Contact key of the conversation currently on screen, or null when no conversation is visible.

Link copied to clipboard
val appForeground: StateFlow<Boolean>

True while any part of the app is visible to the user.

Functions

Link copied to clipboard
Link copied to clipboard
fun clearActive(contactKey: String)

Call when a conversation stops being visible. Compares before clearing so that navigating straight from one conversation to another cannot have the outgoing screen's pause erase the incoming screen's key.

Link copied to clipboard
fun setActive(contactKey: String)

Call when a conversation becomes visible.

Link copied to clipboard
fun setAppForeground(foreground: Boolean)