refactor: Lazy load preferences to prevent crash (#993)

Without this the values are loaded from sharedPreferencesRepository
before the variable is initialised.
This commit is contained in:
Nik Clayton 2024-10-10 15:14:51 +02:00 committed by GitHub
parent e307796251
commit f3b11d0e81
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 3 additions and 2 deletions

View File

@ -66,6 +66,7 @@ import app.pachli.core.common.extensions.hide
import app.pachli.core.common.extensions.show import app.pachli.core.common.extensions.show
import app.pachli.core.common.extensions.viewBinding import app.pachli.core.common.extensions.viewBinding
import app.pachli.core.common.extensions.visible import app.pachli.core.common.extensions.visible
import app.pachli.core.common.util.unsafeLazy
import app.pachli.core.database.model.AccountEntity import app.pachli.core.database.model.AccountEntity
import app.pachli.core.designsystem.R as DR import app.pachli.core.designsystem.R as DR
import app.pachli.core.navigation.AccountActivityIntent import app.pachli.core.navigation.AccountActivityIntent
@ -151,8 +152,8 @@ class AccountActivity :
private var subscribing: Boolean = false private var subscribing: Boolean = false
private var loadedAccount: Account? = null private var loadedAccount: Account? = null
private var animateAvatar: Boolean = sharedPreferencesRepository.animateAvatars private val animateAvatar by unsafeLazy { sharedPreferencesRepository.animateAvatars }
private var animateEmojis: Boolean = sharedPreferencesRepository.animateEmojis private val animateEmojis by unsafeLazy { sharedPreferencesRepository.animateEmojis }
// fields for scroll animation // fields for scroll animation
private var hideFab: Boolean = false private var hideFab: Boolean = false