diff --git a/Session.xcodeproj/project.pbxproj b/Session.xcodeproj/project.pbxproj index 2fb6d1480..5e654b21c 100644 --- a/Session.xcodeproj/project.pbxproj +++ b/Session.xcodeproj/project.pbxproj @@ -6694,7 +6694,7 @@ "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; CODE_SIGN_STYLE = Automatic; COPY_PHASE_STRIP = NO; - CURRENT_PROJECT_VERSION = 435; + CURRENT_PROJECT_VERSION = 436; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; DEVELOPMENT_TEAM = SUQ8J2PCT7; FRAMEWORK_SEARCH_PATHS = "$(inherited)"; @@ -6766,7 +6766,7 @@ "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; CODE_SIGN_STYLE = Automatic; COPY_PHASE_STRIP = NO; - CURRENT_PROJECT_VERSION = 435; + CURRENT_PROJECT_VERSION = 436; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; DEVELOPMENT_TEAM = SUQ8J2PCT7; ENABLE_NS_ASSERTIONS = NO; @@ -6831,7 +6831,7 @@ "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; CODE_SIGN_STYLE = Automatic; COPY_PHASE_STRIP = NO; - CURRENT_PROJECT_VERSION = 435; + CURRENT_PROJECT_VERSION = 436; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; DEVELOPMENT_TEAM = SUQ8J2PCT7; FRAMEWORK_SEARCH_PATHS = "$(inherited)"; @@ -6905,7 +6905,7 @@ "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; CODE_SIGN_STYLE = Automatic; COPY_PHASE_STRIP = NO; - CURRENT_PROJECT_VERSION = 435; + CURRENT_PROJECT_VERSION = 436; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; DEVELOPMENT_TEAM = SUQ8J2PCT7; ENABLE_NS_ASSERTIONS = NO; @@ -7865,7 +7865,7 @@ CODE_SIGN_ENTITLEMENTS = Session/Meta/Signal.entitlements; CODE_SIGN_IDENTITY = "iPhone Developer"; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; - CURRENT_PROJECT_VERSION = 435; + CURRENT_PROJECT_VERSION = 436; DEVELOPMENT_TEAM = SUQ8J2PCT7; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", @@ -7936,7 +7936,7 @@ CODE_SIGN_ENTITLEMENTS = Session/Meta/Signal.entitlements; CODE_SIGN_IDENTITY = "iPhone Developer"; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; - CURRENT_PROJECT_VERSION = 435; + CURRENT_PROJECT_VERSION = 436; DEVELOPMENT_TEAM = SUQ8J2PCT7; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", diff --git a/Session/Conversations/Message Cells/InfoMessageCell.swift b/Session/Conversations/Message Cells/InfoMessageCell.swift index 016a806c6..c68bda5d5 100644 --- a/Session/Conversations/Message Cells/InfoMessageCell.swift +++ b/Session/Conversations/Message Cells/InfoMessageCell.swift @@ -132,11 +132,15 @@ final class InfoMessageCell: MessageCell { ) .adding( attributes: [ .font: UIFont.boldSystemFont(ofSize: Values.verySmallFontSize) ], - range: (body as NSString).range(of: floor(cellViewModel.threadExpirationTimer ?? 0).formatted(format: .long)) + range: (body as NSString).range(of: floor(cellViewModel.expiresInSeconds ?? 0).formatted(format: .long)) ) .adding( attributes: [ .font: UIFont.boldSystemFont(ofSize: Values.verySmallFontSize) ], - range: (body as NSString).range(of: (cellViewModel.threadExpirationType == .disappearAfterRead ? "DISAPPEARING_MESSAGE_STATE_READ".localized() : "DISAPPEARING_MESSAGE_STATE_SENT".localized())) + range: (body as NSString).range(of: "DISAPPEARING_MESSAGE_STATE_READ".localized()) + ) + .adding( + attributes: [ .font: UIFont.boldSystemFont(ofSize: Values.verySmallFontSize) ], + range: (body as NSString).range(of: "DISAPPEARING_MESSAGE_STATE_SENT".localized()) ) .adding( attributes: [ .font: UIFont.boldSystemFont(ofSize: Values.verySmallFontSize) ], diff --git a/Session/Meta/AppDelegate.swift b/Session/Meta/AppDelegate.swift index 2f5e77c54..d55ccf505 100644 --- a/Session/Meta/AppDelegate.swift +++ b/Session/Meta/AppDelegate.swift @@ -320,6 +320,11 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD Configuration.performMainSetup() JobRunner.setExecutor(SyncPushTokensJob.self, for: .syncPushTokens) + /// We need to do a clean up for disappear after send messages that are received by push notifications before + /// the app set up the main screen and load initial data to prevent a case when the PagedDatabaseObserver + /// hasn't been setup yet then the conversation screen can show stale (ie. deleted) interactions incorrectly + DisappearingMessagesJob.cleanExpiredMessagesOnLaunch() + // Setup the UI if needed, then trigger any post-UI setup actions self.ensureRootViewController(calledFrom: lifecycleMethod) { [weak self] success in // If we didn't successfully ensure the rootViewController then don't continue as diff --git a/SessionMessagingKit/Jobs/Types/DisappearingMessagesJob.swift b/SessionMessagingKit/Jobs/Types/DisappearingMessagesJob.swift index c41ac60cf..d5e238b9b 100644 --- a/SessionMessagingKit/Jobs/Types/DisappearingMessagesJob.swift +++ b/SessionMessagingKit/Jobs/Types/DisappearingMessagesJob.swift @@ -46,6 +46,24 @@ public enum DisappearingMessagesJob: JobExecutor { } } +// MARK: - Clean expired messages on app launch + +public extension DisappearingMessagesJob { + static func cleanExpiredMessagesOnLaunch() { + let timestampNowMs: TimeInterval = TimeInterval(SnodeAPI.currentOffsetTimestampMs()) + var numDeleted: Int = -1 + + Storage.shared.write { db in + numDeleted = try Interaction + .filter(Interaction.Columns.expiresStartedAtMs != nil) + .filter((Interaction.Columns.expiresStartedAtMs + (Interaction.Columns.expiresInSeconds * 1000)) <= timestampNowMs) + .deleteAll(db) + } + + SNLog("[DisappearingMessagesJob] Deleted \(numDeleted) expired messages on app launch.") + } +} + // MARK: - Convenience public extension DisappearingMessagesJob { diff --git a/SessionUtilitiesKit/General/Features.swift b/SessionUtilitiesKit/General/Features.swift index cb0e6b2d9..ad235bf31 100644 --- a/SessionUtilitiesKit/General/Features.swift +++ b/SessionUtilitiesKit/General/Features.swift @@ -5,5 +5,5 @@ import Foundation public final class Features { public static let useOnionRequests: Bool = true public static let useTestnet: Bool = false - public static let useNewDisappearingMessagesConfig: Bool = Date().timeIntervalSince1970 > 1710198000 + public static let useNewDisappearingMessagesConfig: Bool = Date().timeIntervalSince1970 > 1710284400 }