Add support for separate story view receipt control.

This reverts commit 1046265d23.
fork-5.53.8
Alex Hart 2022-10-13 12:46:13 -03:00 zatwierdzone przez Cody Henthorne
rodzic 9941ffe79c
commit dfdf68b7b5
3 zmienionych plików z 15 dodań i 8 usunięć

Wyświetl plik

@ -3,6 +3,7 @@ package org.thoughtcrime.securesms.components
import android.view.View
import androidx.fragment.app.Fragment
import androidx.lifecycle.DefaultLifecycleObserver
import androidx.lifecycle.Lifecycle
import androidx.lifecycle.LifecycleOwner
import androidx.viewbinding.ViewBinding
import kotlin.reflect.KProperty
@ -17,14 +18,13 @@ open class ViewBinderDelegate<T : ViewBinding>(
) : DefaultLifecycleObserver {
private var binding: T? = null
private var isBindingDestroyed = false
operator fun getValue(thisRef: Fragment, property: KProperty<*>): T {
if (isBindingDestroyed) {
error("Binding has been destroyed.")
}
if (binding == null) {
if (!thisRef.viewLifecycleOwner.lifecycle.currentState.isAtLeast(Lifecycle.State.INITIALIZED)) {
error("Invalid state to create a binding.")
}
thisRef.viewLifecycleOwner.lifecycle.addObserver(this@ViewBinderDelegate)
binding = bindingFactory(thisRef.requireView())
}
@ -38,6 +38,5 @@ open class ViewBinderDelegate<T : ViewBinding>(
}
binding = null
isBindingDestroyed = true
}
}
}

Wyświetl plik

@ -67,7 +67,9 @@ internal class StoryValues(store: KeyValueStore) : SignalStoreValues(store) {
HAS_DOWNLOADED_ONBOARDING_STORY,
USER_HAS_SEEN_BETA_DIALOG,
STORY_VIEWED_RECEIPTS,
USER_HAS_READ_ONBOARDING_STORY
USER_HAS_READ_ONBOARDING_STORY,
USER_HAS_SEEN_BETA_DIALOG,
STORY_VIEWED_RECEIPTS
)
var isFeatureDisabled: Boolean by booleanValue(MANUAL_FEATURE_DISABLE, false)

Wyświetl plik

@ -188,6 +188,12 @@ public final class StorageSyncHelper {
SignalStore.storyValues().setViewedReceiptsEnabled(update.getNew().getStoryViewReceiptsState() == OptionalBool.ENABLED);
}
if (update.getNew().getStoryViewReceiptsState() == OptionalBool.UNSET) {
SignalStore.storyValues().setViewedReceiptsEnabled(update.getNew().isReadReceiptsEnabled());
} else {
SignalStore.storyValues().setViewedReceiptsEnabled(update.getNew().getStoryViewReceiptsState() == OptionalBool.ENABLED);
}
if (update.getNew().isSubscriptionManuallyCancelled()) {
SignalStore.donationsValues().updateLocalStateForManualCancellation();
} else {