add disappearing messages type legacy

pull/941/head
ryanzhao 1 year ago
parent fa02b76d77
commit a966fca55e

@ -20,11 +20,13 @@ public struct DisappearingMessagesConfiguration: Codable, Identifiable, Equatabl
} }
public enum DisappearingMessageType: Int, Codable, Hashable, DatabaseValueConvertible { public enum DisappearingMessageType: Int, Codable, Hashable, DatabaseValueConvertible {
case legacy
case disappearAfterRead case disappearAfterRead
case disappearAfterSend case disappearAfterSend
public var defaultDuration: TimeInterval { public var defaultDuration: TimeInterval {
switch self { switch self {
case .legacy: return (12 * 60 * 60)
case .disappearAfterRead: return (12 * 60 * 60) case .disappearAfterRead: return (12 * 60 * 60)
case .disappearAfterSend: return (24 * 60 * 60) case .disappearAfterSend: return (24 * 60 * 60)
} }
@ -32,6 +34,7 @@ public struct DisappearingMessagesConfiguration: Codable, Identifiable, Equatabl
init(protoType: SNProtoContent.SNProtoContentExpirationType) { init(protoType: SNProtoContent.SNProtoContentExpirationType) {
switch protoType { switch protoType {
case .legacy: self = .legacy
case .deleteAfterRead: self = .disappearAfterRead case .deleteAfterRead: self = .disappearAfterRead
case .deleteAfterSend: self = .disappearAfterSend case .deleteAfterSend: self = .disappearAfterSend
} }
@ -39,6 +42,7 @@ public struct DisappearingMessagesConfiguration: Codable, Identifiable, Equatabl
func toProto() -> SNProtoContent.SNProtoContentExpirationType { func toProto() -> SNProtoContent.SNProtoContentExpirationType {
switch self { switch self {
case .legacy: return .legacy
case .disappearAfterRead: return .deleteAfterRead case .disappearAfterRead: return .deleteAfterRead
case .disappearAfterSend: return .deleteAfterSend case .disappearAfterSend: return .deleteAfterSend
} }
@ -211,7 +215,7 @@ extension DisappearingMessagesConfiguration {
public static func validDurationsSeconds(_ type: DisappearingMessageType) -> [TimeInterval] { public static func validDurationsSeconds(_ type: DisappearingMessageType) -> [TimeInterval] {
switch type { switch type {
case .disappearAfterRead: case .legacy, .disappearAfterRead:
return [ return [
60, // TODO: remove this, for test purpose only 60, // TODO: remove this, for test purpose only
(5 * 60), (5 * 60),

Loading…
Cancel
Save