minor refactor and clean up

pull/731/head
Ryan Zhao 8 months ago
parent 928d7f2b1e
commit 99d5620536

@ -55,16 +55,14 @@ class ThreadDisappearingMessagesSettingsViewModel: SessionTableViewModel, Naviga
public enum Section: SessionTableSection { public enum Section: SessionTableSection {
case type case type
case timerDisappearAfterSend case timer
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 .timerDisappearAfterSend: return "DISAPPERING_MESSAGES_TIMER_TITLE".localized() case .timer: 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
} }
@ -258,12 +256,12 @@ class ThreadDisappearingMessagesSettingsViewModel: SessionTableViewModel, Naviga
), ),
(currentSelection.isEnabled == false ? nil : (currentSelection.isEnabled == false ? nil :
SectionModel( SectionModel(
model: (currentSelection.type == .disappearAfterSend ? model: .timer,
.timerDisappearAfterSend :
.timerDisappearAfterRead
),
elements: DisappearingMessagesConfiguration elements: DisappearingMessagesConfiguration
.validDurationsSeconds(currentSelection.type ?? .disappearAfterSend) .validDurationsSeconds({
guard Features.useNewDisappearingMessagesConfig else { return .disappearAfterSend }
return currentSelection.type ?? .disappearAfterSend
}())
.map { duration in .map { duration in
let title: String = duration.formatted(format: .long) let title: String = duration.formatted(format: .long)
@ -371,12 +369,7 @@ class ThreadDisappearingMessagesSettingsViewModel: SessionTableViewModel, Naviga
(!Features.useNewDisappearingMessagesConfig && currentSelection.isEnabled == false ? nil : (!Features.useNewDisappearingMessagesConfig && currentSelection.isEnabled == false ? nil :
SectionModel( SectionModel(
model: { model: {
guard Features.useNewDisappearingMessagesConfig else { guard Features.useNewDisappearingMessagesConfig else { return .timer }
return (currentSelection.type == .disappearAfterSend ?
.timerDisappearAfterSend :
.timerDisappearAfterRead
)
}
return (isNoteToSelf ? .noteToSelf : .group) return (isNoteToSelf ? .noteToSelf : .group)
}(), }(),

Loading…
Cancel
Save