diff --git a/Session/Conversations/Settings/ThreadDisappearingMessagesViewModel.swift b/Session/Conversations/Settings/ThreadDisappearingMessagesViewModel.swift index 5c7057581..0e491f50a 100644 --- a/Session/Conversations/Settings/ThreadDisappearingMessagesViewModel.swift +++ b/Session/Conversations/Settings/ThreadDisappearingMessagesViewModel.swift @@ -17,6 +17,7 @@ class ThreadDisappearingMessagesViewModel: SessionTableViewModel 1671062400 // 15/12/2022 + public static var databaseTableName: String { "disappearingMessagesConfiguration" } internal static let threadForeignKey = ForeignKey([Columns.threadId], to: [SessionThread.Columns.id]) private static let thread = belongsTo(SessionThread.self, using: threadForeignKey) @@ -21,22 +23,27 @@ public struct DisappearingMessagesConfiguration: Codable, Identifiable, Equatabl public enum DisappearingMessageType: Int, Codable, Hashable, DatabaseValueConvertible { case disappearAfterRead case disappearAfterSend + case legacy - init(protoType: SNProtoContent.SNProtoContentExpirationType) { + init(protoType: SNProtoContent.SNProtoContentExpirationType?) { switch protoType { case .deleteAfterSend: self = .disappearAfterSend case .deleteAfterRead: self = .disappearAfterRead + case .none: + self = .legacy } } - func toProto() -> SNProtoContent.SNProtoContentExpirationType { + func toProto() -> SNProtoContent.SNProtoContentExpirationType? { switch self { case .disappearAfterRead: return .deleteAfterRead case .disappearAfterSend: return .deleteAfterSend + case .legacy: + return nil } } } @@ -185,7 +192,7 @@ extension DisappearingMessagesConfiguration { public static func validDurationsSeconds(_ type: DisappearingMessageType) -> [TimeInterval] { switch type { - case .disappearAfterRead: + case .disappearAfterRead, .legacy: return [ 60, // TODO: remove this, for test purpose only (5 * 60),