fix default timer selection when changing disappearing messages type

pull/941/head
ryanzhao 2 years ago
parent afbb60b66d
commit 68c762781b

@ -17,14 +17,16 @@ class ThreadDisappearingMessagesViewModel: SessionTableViewModel<ThreadDisappear
public enum Section: SessionTableSection { public enum Section: SessionTableSection {
case type case type
case timer case timerDisappearAfterSend
case timerDisappearAfterRead
case noteToSelf case noteToSelf
case group case group
var title: String? { var title: String? {
switch self { switch self {
case .type: return "DISAPPERING_MESSAGES_TYPE_TITLE".localized() case .type: return "DISAPPERING_MESSAGES_TYPE_TITLE".localized()
case .timer: return "DISAPPERING_MESSAGES_TIMER_TITLE".localized() case .timerDisappearAfterSend: return "DISAPPERING_MESSAGES_TIMER_TITLE".localized()
case .timerDisappearAfterRead: return "DISAPPERING_MESSAGES_TIMER_TITLE".localized()
case .noteToSelf: return nil case .noteToSelf: return nil
case .group: return nil case .group: return nil
} }
@ -34,10 +36,8 @@ class ThreadDisappearingMessagesViewModel: SessionTableViewModel<ThreadDisappear
var footer: String? { var footer: String? {
switch self { switch self {
case .type: return nil
case .timer: return nil
case .noteToSelf: return nil
case .group: return "DISAPPERING_MESSAGES_GROUP_WARNING_ADMIN_ONLY".localized() case .group: return "DISAPPERING_MESSAGES_GROUP_WARNING_ADMIN_ONLY".localized()
default: return nil
} }
} }
} }
@ -237,7 +237,7 @@ class ThreadDisappearingMessagesViewModel: SessionTableViewModel<ThreadDisappear
].appending( ].appending(
(currentSelection.isEnabled == false) ? nil : (currentSelection.isEnabled == false) ? nil :
SectionModel( SectionModel(
model: .timer, model: currentSelection.type == .disappearAfterSend ? .timerDisappearAfterSend : .timerDisappearAfterRead,
elements: DisappearingMessagesConfiguration elements: DisappearingMessagesConfiguration
.validDurationsSeconds(currentSelection.type ?? .disappearAfterSend) .validDurationsSeconds(currentSelection.type ?? .disappearAfterSend)
.map { duration in .map { duration in

Loading…
Cancel
Save