fix: zombie mode (#126)

This commit is contained in:
Diego Beraldin 2023-11-11 22:58:00 +01:00 committed by GitHub
parent 157ffcf563
commit 5e4003aa66
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 13 additions and 10 deletions

View File

@ -153,7 +153,10 @@ class CommunityDetailViewModel(
is CommunityDetailMviModel.Intent.StartZombieMode -> {
mvi.updateState { it.copy(zombieModeActive = true) }
zombieModeHelper.start(intent.index)
zombieModeHelper.start(
initialValue = intent.index,
interval = settingsRepository.currentSettings.value.zombieModeInterval,
)
}
}
}

View File

@ -31,12 +31,9 @@ class DurationBottomSheet(
private val values: List<Duration> = listOf(
1.seconds,
2.seconds,
2.5.seconds,
3.seconds,
3.5.seconds,
4.seconds,
4.5.seconds,
5.seconds,
10.seconds,
),
) : Screen {

View File

@ -29,6 +29,6 @@ data class SettingsModel(
val autoLoadImages: Boolean = true,
val autoExpandComments: Boolean = true,
val hideNavigationBarWhileScrolling: Boolean = true,
val zombieModeInterval: Duration = 2.5.seconds,
val zombieModeInterval: Duration = 2.seconds,
val zombieModeScrollAmount: Float = 100f,
) : JavaSerializable

View File

@ -109,7 +109,7 @@ internal class DefaultSettingsRepository(
upvoteColor = if (!keyStore.containsKey(KeyStoreKeys.UpvoteColor)) null else keyStore[KeyStoreKeys.UpvoteColor, 0],
downvoteColor = if (!keyStore.containsKey(KeyStoreKeys.DownVoteColor)) null else keyStore[KeyStoreKeys.DownVoteColor, 0],
hideNavigationBarWhileScrolling = keyStore[KeyStoreKeys.HideNavigationBarWhileScrolling, true],
zombieModeInterval = keyStore[KeyStoreKeys.ZombieModeInterval, 2500].milliseconds,
zombieModeInterval = keyStore[KeyStoreKeys.ZombieModeInterval, 2000].milliseconds,
zombieModeScrollAmount = keyStore[KeyStoreKeys.ZombieModeScrollAmount, 100f],
)
} else {

View File

@ -23,7 +23,7 @@ CREATE TABLE SettingsEntity (
upvoteColor INTEGER DEFAULT NULL,
downvoteColor INTEGER DEFAULT NULL,
hideNavigationBarWhileScrolling INTEGER NOT NULL DEFAULT 1,
zombieModeInterval INTEGER NOT NULL DEFAULT 2500,
zombieModeInterval INTEGER NOT NULL DEFAULT 2000,
zombieModeScrollAmount REAL NOT NULL DEFAULT 100,
account_id INTEGER,
FOREIGN KEY (account_id) REFERENCES AccountEntity(id) ON DELETE CASCADE,

View File

@ -2,4 +2,4 @@ ALTER TABLE SettingsEntity
ADD COLUMN hideNavigationBarWhileScrolling INTEGER NOT NULL DEFAULT 1;
ALTER TABLE SettingsEntity
ADD COLUMN zombieModeInterval INTEGER NOT NULL DEFAULT 2500;
ADD COLUMN zombieModeInterval INTEGER NOT NULL DEFAULT 2000;

View File

@ -206,7 +206,10 @@ class PostListViewModel(
is PostListMviModel.Intent.StartZombieMode -> {
mvi.updateState { it.copy(zombieModeActive = true) }
zombieModeHelper.start(intent.index)
zombieModeHelper.start(
initialValue = intent.index,
interval = settingsRepository.currentSettings.value.zombieModeInterval,
)
}
}
}