-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add monthly backup reminder #1280
Conversation
navigator.navigate(Destination.BackupPassword(vaultId!!)) | ||
} | ||
} | ||
|
||
fun dismissBackupReminder() = viewModelScope.launch { | ||
uiState.update { it.copy(showMonthlyBackupReminder = false) } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
update is not a suspend method, so it doesn't need to be inside of launch
@@ -201,8 +216,17 @@ internal class VaultAccountsViewModel @Inject constructor( | |||
@Suppress("ReplaceNotNullAssertionWithElvisReturn") | |||
fun backupVault() { | |||
viewModelScope.launch { | |||
uiState.update { it.copy(showMonthlyBackupReminder = false) } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i suggest reusing dismissBackupReminder() method for all of the code which hides reminder (after launch will be removed from dismiss)
@@ -61,6 +64,8 @@ internal class VaultAccountsViewModel @Inject constructor( | |||
private val vaultDataStoreRepository: VaultDataStoreRepository, | |||
private val accountsRepository: AccountsRepository, | |||
private val balanceVisibilityRepository: BalanceVisibilityRepository, | |||
private val getGlobalBackupReminderStatus: GetGlobalBackupReminderStatus, | |||
private val neverShowGlobalBackupReminder: NeverShowGlobalBackupReminder, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
private val neverShowGlobalBackupReminder: NeverShowGlobalBackupReminder, | |
private val setNeverShowGlobalBackupReminder: NeverShowGlobalBackupReminder, |
actions require imperative names
onDismiss: () -> Unit, | ||
onBackup: () -> Unit, | ||
onDoNotRemind: () -> Unit, | ||
){ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
){ | |
) { |
👾
|
||
object VultiDate { | ||
fun getEpochMonth(): Int { | ||
val localDate = java.time.LocalDate.now() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use kotlinx.datetime
object VultiDate { | ||
fun getEpochMonth(): Int { | ||
val localDate = java.time.LocalDate.now() | ||
return localDate.minusYears(1970).year * 12 + localDate.monthValue |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is rather weird, look into kotlinx.datetime
import kotlinx.coroutines.flow.first | ||
import javax.inject.Inject | ||
|
||
interface GetGlobalBackupReminderStatus : suspend () -> Boolean |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
status, which is boolean, is not really informative about what that status means. if you use boolean as return, prefer to name a check somehow e.g. IsGlobalBackupReminderRequired (UseCase)
also, do not forget to postfix that with UseCase
when (shownMonth) { | ||
0 -> { | ||
vaultDataStoreRepository.setGlobalBackupReminderStatus(currentEpochMonth) | ||
return true | ||
} | ||
-1 -> { | ||
return false | ||
} | ||
currentEpochMonth -> { | ||
vaultDataStoreRepository.setGlobalBackupReminderStatus(currentEpochMonth) | ||
return false | ||
} | ||
else -> { | ||
vaultDataStoreRepository.setGlobalBackupReminderStatus(currentEpochMonth) | ||
return true | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i actually do not understand what happens here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here logic that do 2 things
- depends on record in ds should we show reminder
- rewrite ds if needed
interface NeverShowGlobalBackupReminder : suspend () -> Unit | ||
|
||
internal class NeverShowGlobalBackupReminderImpl @Inject constructor( | ||
val vaultDataStoreRepository: VaultDataStoreRepository, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
val vaultDataStoreRepository: VaultDataStoreRepository, | |
private val vaultDataStoreRepository: VaultDataStoreRepository, |
val vaultDataStoreRepository: VaultDataStoreRepository, | ||
) : NeverShowGlobalBackupReminder { | ||
override suspend fun invoke() { | ||
vaultDataStoreRepository.setGlobalBackupReminderStatus(-1) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
-1 is a magic constant
Fixes #1266