Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit eea14d36 authored by Alejandro Nijamkin's avatar Alejandro Nijamkin Committed by Ale Nijamkin
Browse files

Use no-op snapshot store in restorers (2/2).

When the revamped UI flag is off, the undo system doesn't start a
session, which means it doesn't hand a "store" to its restorers. By
having all restorers start off with a safe-to-use no-op store, we
circumvent a lot of crashes.

Fix: 272157475
Fix: 271967027
Test: manually verified that the crashes no longer occur with the flag
on or off and that the undo system (reset button) still works.

Change-Id: I0a6e709d569ace7b2e8468e3f4810ae4f67a3b7d
parent f9429e4f
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -27,7 +27,7 @@ class GridSnapshotRestorer(
    private val interactor: GridInteractor,
) : SnapshotRestorer {

    private lateinit var store: SnapshotStore
    private var store: SnapshotStore = SnapshotStore.NOOP
    private var originalOption: GridOptionItemModel? = null

    override suspend fun setUpSnapshotRestorer(store: SnapshotStore): RestorableSnapshot {
+1 −1
Original line number Diff line number Diff line
@@ -33,7 +33,7 @@ class DarkModeSnapshotRestorer : SnapshotRestorer {
    private val isActive: () -> Boolean
    private val setActive: suspend (Boolean) -> Unit

    private lateinit var store: SnapshotStore
    private var store: SnapshotStore = SnapshotStore.NOOP

    constructor(
        context: Context,
+1 −1
Original line number Diff line number Diff line
@@ -27,7 +27,7 @@ class ThemedIconSnapshotRestorer(
    private val interactor: ThemedIconInteractor,
) : SnapshotRestorer {

    private lateinit var store: SnapshotStore
    private var store: SnapshotStore = SnapshotStore.NOOP

    override suspend fun setUpSnapshotRestorer(store: SnapshotStore): RestorableSnapshot {
        this.store = store
+1 −1
Original line number Diff line number Diff line
@@ -28,7 +28,7 @@ class ColorPickerSnapshotRestorer(
    private val interactor: ColorPickerInteractor,
) : SnapshotRestorer {

    private lateinit var snapshotStore: SnapshotStore
    private var snapshotStore: SnapshotStore = SnapshotStore.NOOP
    private var originalOption: ColorOptionModel? = null

    fun storeSnapshot(colorOptionModel: ColorOptionModel) {
+1 −1
Original line number Diff line number Diff line
@@ -27,7 +27,7 @@ class NotificationsSnapshotRestorer(
    private val interactor: NotificationsInteractor,
) : SnapshotRestorer {

    private lateinit var snapshotStore: SnapshotStore
    private var snapshotStore: SnapshotStore = SnapshotStore.NOOP

    fun storeSnapshot(model: NotificationSettingsModel) {
        snapshotStore.store(snapshot(model))
Loading