mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-04-20 00:29:11 +01:00
Fix issue where archival progress dialog never dismisses.
This commit is contained in:
@@ -14,7 +14,6 @@ import org.thoughtcrime.securesms.R
|
||||
*
|
||||
* @property message The text message to display in the snackbar.
|
||||
* @property actionState Optional action button configuration.
|
||||
* @property showProgress Whether to show a progress indicator in the snackbar.
|
||||
* @property duration How long the snackbar should be displayed.
|
||||
* @property hostKey The target host where this snackbar should be displayed. Defaults to [SnackbarHostKey.Global]
|
||||
* @property fallbackKey Optional host to fallback upon if the host key is not registered. Defaults to the Global key.
|
||||
@@ -22,7 +21,6 @@ import org.thoughtcrime.securesms.R
|
||||
data class SnackbarState(
|
||||
val message: String,
|
||||
val actionState: ActionState? = null,
|
||||
val showProgress: Boolean = false,
|
||||
val duration: Snackbars.Duration = Snackbars.Duration.SHORT,
|
||||
val hostKey: SnackbarHostKey = SnackbarHostKey.Global,
|
||||
val fallbackKey: SnackbarHostKey? = SnackbarHostKey.Global
|
||||
|
||||
@@ -8,7 +8,7 @@ package org.thoughtcrime.securesms.components.snackbars
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.DisposableEffect
|
||||
import androidx.compose.runtime.MutableState
|
||||
import androidx.compose.runtime.State
|
||||
import androidx.compose.runtime.Stable
|
||||
import androidx.compose.runtime.mutableStateOf
|
||||
import androidx.compose.runtime.remember
|
||||
import androidx.compose.runtime.staticCompositionLocalOf
|
||||
@@ -27,11 +27,30 @@ val LocalSnackbarStateConsumerRegistry = staticCompositionLocalOf<SnackbarStateC
|
||||
error("No SnackbarStateConsumerRegistry provided")
|
||||
}
|
||||
|
||||
/**
|
||||
* Holder for snackbar state that allows clearing the state after consumption.
|
||||
*/
|
||||
@Stable
|
||||
class SnackbarStateHolder(
|
||||
private val state: MutableState<SnackbarState?>
|
||||
) {
|
||||
val value: SnackbarState?
|
||||
get() = state.value
|
||||
|
||||
/**
|
||||
* Clears the current snackbar state. Should be called after the snackbar has been consumed/dismissed.
|
||||
*/
|
||||
fun clear() {
|
||||
state.value = null
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
fun rememberSnackbarState(
|
||||
key: SnackbarHostKey
|
||||
): State<SnackbarState?> {
|
||||
): SnackbarStateHolder {
|
||||
val state: MutableState<SnackbarState?> = remember(key) { mutableStateOf(null) }
|
||||
val holder = remember(key, state) { SnackbarStateHolder(state) }
|
||||
|
||||
val registry = LocalSnackbarStateConsumerRegistry.current
|
||||
DisposableEffect(registry, key) {
|
||||
@@ -44,7 +63,7 @@ fun rememberSnackbarState(
|
||||
}
|
||||
}
|
||||
|
||||
return state
|
||||
return holder
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user