From 984aee4aa9e9c731d2df22aff068934615a0019e Mon Sep 17 00:00:00 2001 From: Ryan Zhao Date: Thu, 1 Dec 2022 11:03:22 +1100 Subject: [PATCH] WIP: add legacy disappearing messages --- .../ThreadDisappearingMessagesViewModel.swift | 2 ++ .../Meta/Translations/de.lproj/Localizable.strings | 3 +++ .../Meta/Translations/en.lproj/Localizable.strings | 3 +++ .../Meta/Translations/es.lproj/Localizable.strings | 3 +++ .../Meta/Translations/fa.lproj/Localizable.strings | 3 +++ .../Meta/Translations/fi.lproj/Localizable.strings | 3 +++ .../Meta/Translations/fr.lproj/Localizable.strings | 3 +++ .../Meta/Translations/hi.lproj/Localizable.strings | 3 +++ .../Meta/Translations/hr.lproj/Localizable.strings | 3 +++ .../Translations/id-ID.lproj/Localizable.strings | 3 +++ .../Meta/Translations/it.lproj/Localizable.strings | 3 +++ .../Meta/Translations/ja.lproj/Localizable.strings | 3 +++ .../Meta/Translations/nl.lproj/Localizable.strings | 3 +++ .../Meta/Translations/pl.lproj/Localizable.strings | 3 +++ .../Translations/pt_BR.lproj/Localizable.strings | 3 +++ .../Meta/Translations/ru.lproj/Localizable.strings | 3 +++ .../Meta/Translations/si.lproj/Localizable.strings | 3 +++ .../Meta/Translations/sk.lproj/Localizable.strings | 3 +++ .../Meta/Translations/sv.lproj/Localizable.strings | 3 +++ .../Meta/Translations/th.lproj/Localizable.strings | 3 +++ .../Translations/vi-VN.lproj/Localizable.strings | 3 +++ .../Translations/zh-Hant.lproj/Localizable.strings | 3 +++ .../Translations/zh_CN.lproj/Localizable.strings | 3 +++ .../Models/DisappearingMessageConfiguration.swift | 13 ++++++++++--- 24 files changed, 78 insertions(+), 3 deletions(-) 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),