29 lines
802 B
Kotlin
29 lines
802 B
Kotlin
package core.notifications.data
|
|
|
|
import javax.inject.Inject
|
|
import javax.inject.Singleton
|
|
import kotlinx.coroutines.flow.MutableStateFlow
|
|
import kotlinx.coroutines.flow.StateFlow
|
|
import kotlinx.coroutines.flow.asStateFlow
|
|
|
|
@Singleton
|
|
class ActiveChatTracker @Inject constructor() {
|
|
private val _currentChatId = MutableStateFlow<String?>(null)
|
|
val currentChatId: StateFlow<String?> = _currentChatId.asStateFlow()
|
|
|
|
private val _totalUnreadCount = MutableStateFlow(0)
|
|
val totalUnreadCount: StateFlow<Int> = _totalUnreadCount.asStateFlow()
|
|
|
|
fun setChatId(chatId: String?) {
|
|
_currentChatId.value = chatId
|
|
}
|
|
|
|
fun setTotalUnreadCount(count: Int) {
|
|
_totalUnreadCount.value = count
|
|
}
|
|
|
|
fun incrementUnreadCount() {
|
|
_totalUnreadCount.value += 1
|
|
}
|
|
}
|