forked from signalapp/Signal-Android
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixes signalapp#13331: Make toggle button update lifecycle-aware
- Loading branch information
1 parent
e17b07b
commit ae7e2ef
Showing
2 changed files
with
46 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
app/src/main/java/org/thoughtcrime/securesms/conversation/v2/ToggleUpdateViewModel.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
/* | ||
* Copyright 2023 Signal Messenger, LLC | ||
* SPDX-License-Identifier: AGPL-3.0-only | ||
*/ | ||
|
||
package org.thoughtcrime.securesms.conversation.v2 | ||
|
||
import androidx.lifecycle.ViewModel | ||
import androidx.lifecycle.viewModelScope | ||
import kotlinx.coroutines.flow.MutableSharedFlow | ||
import kotlinx.coroutines.flow.asSharedFlow | ||
import kotlinx.coroutines.launch | ||
|
||
class ToggleUpdateViewModel : ViewModel() { | ||
|
||
private val _state = MutableSharedFlow<Unit>(replay = 1) | ||
val state = _state.asSharedFlow() | ||
|
||
fun update() = viewModelScope.launch { | ||
_state.emit(Unit) | ||
} | ||
} |