mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-04-22 01:40:07 +01:00
Fix bug when changing schedule end time and end is before start.
This commit is contained in:
@@ -76,12 +76,11 @@ class EditNotificationProfileScheduleViewModel(
|
||||
repository.updateSchedule(schedule)
|
||||
.toSingleDefault(SaveScheduleResult.Success)
|
||||
.flatMap { r ->
|
||||
if (createMode && schedule.enabled && schedule.coversTime(System.currentTimeMillis())) {
|
||||
repository.manuallyToggleProfile(profileId, schedule)
|
||||
if (schedule.enabled && schedule.coversTime(System.currentTimeMillis())) {
|
||||
repository.manuallyEnableProfileForSchedule(profileId, schedule)
|
||||
.toSingleDefault(r)
|
||||
} else {
|
||||
repository.updateManuallyEnabledDataIfNecessary(profileId, schedule)
|
||||
.toSingleDefault(r)
|
||||
Single.just(r)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -133,17 +133,12 @@ class NotificationProfilesRepository {
|
||||
.subscribeOn(Schedulers.io())
|
||||
}
|
||||
|
||||
fun updateManuallyEnabledDataIfNecessary(profileId: Long, schedule: NotificationProfileSchedule, now: Long = System.currentTimeMillis()): Completable {
|
||||
fun manuallyEnableProfileForSchedule(profileId: Long, schedule: NotificationProfileSchedule, now: Long = System.currentTimeMillis()): Completable {
|
||||
return Completable.fromAction {
|
||||
val profiles = database.getProfiles()
|
||||
val activeProfile = NotificationProfiles.getActiveProfile(profiles, now)
|
||||
|
||||
if (profileId == activeProfile?.id) {
|
||||
val inScheduledWindow = schedule.isCurrentlyActive(now)
|
||||
SignalStore.notificationProfileValues().manuallyEnabledProfile = if (inScheduledWindow) profileId else 0
|
||||
SignalStore.notificationProfileValues().manuallyEnabledUntil = if (inScheduledWindow) schedule.endDateTime(now.toLocalDateTime()).toMillis() else Long.MAX_VALUE
|
||||
SignalStore.notificationProfileValues().manuallyDisabledAt = if (inScheduledWindow) now else 0
|
||||
}
|
||||
val inScheduledWindow = schedule.isCurrentlyActive(now)
|
||||
SignalStore.notificationProfileValues().manuallyEnabledProfile = if (inScheduledWindow) profileId else 0
|
||||
SignalStore.notificationProfileValues().manuallyEnabledUntil = if (inScheduledWindow) schedule.endDateTime(now.toLocalDateTime()).toMillis() else Long.MAX_VALUE
|
||||
SignalStore.notificationProfileValues().manuallyDisabledAt = if (inScheduledWindow) now else 0
|
||||
}
|
||||
.doOnComplete { ApplicationDependencies.getDatabaseObserver().notifyNotificationProfileObservers() }
|
||||
.subscribeOn(Schedulers.io())
|
||||
|
||||
Reference in New Issue
Block a user