From 5e473bffc7104dd8881962b9e89856ddac526205 Mon Sep 17 00:00:00 2001 From: Doug Date: Mon, 17 Jun 2024 12:28:58 +0100 Subject: [PATCH 1/5] Prepare for new sprint --- Config/AppVersion.xcconfig | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Config/AppVersion.xcconfig b/Config/AppVersion.xcconfig index e53ee78429..716ff33d70 100644 --- a/Config/AppVersion.xcconfig +++ b/Config/AppVersion.xcconfig @@ -15,5 +15,5 @@ // // Version -MARKETING_VERSION = 1.11.14 -CURRENT_PROJECT_VERSION = 1.11.14 +MARKETING_VERSION = 1.11.15 +CURRENT_PROJECT_VERSION = 1.11.15 From 43de3eca3b5a9871e46c23352a13c979f24a45f5 Mon Sep 17 00:00:00 2001 From: Doug Date: Mon, 17 Jun 2024 12:31:30 +0100 Subject: [PATCH 2/5] Changelog. --- CHANGES.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/CHANGES.md b/CHANGES.md index 19854177cb..93a8b15809 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,6 +1,8 @@ ## Changes in 1.11.14 (2024-06-17) -No significant changes. +🙌 Improvements + +- Room retention event implementation ([#7809](https://github.com/element-hq/element-ios/pull/7809)) ## Changes in 1.11.13 (2024-06-12) From 412f8c9b8d5f425d4f5454a55733f32c33c36ec3 Mon Sep 17 00:00:00 2001 From: Mauro Romito Date: Tue, 18 Jun 2024 15:49:14 +0200 Subject: [PATCH 3/5] fix --- Podfile.lock | 10 +++++----- Riot/Categories/MXRoomSummary.swift | 13 ++++++------- Riot/Utils/EventFormatter.m | 17 +++++++++++++++-- Riot/Utils/Tools.h | 6 ------ Riot/Utils/Tools.m | 5 ----- matrix-ios-sdk | 2 +- 6 files changed, 27 insertions(+), 26 deletions(-) diff --git a/Podfile.lock b/Podfile.lock index 979f760d96..ce0165a2b2 100644 --- a/Podfile.lock +++ b/Podfile.lock @@ -39,9 +39,9 @@ PODS: - LoggerAPI (1.9.200): - Logging (~> 1.1) - Logging (1.4.0) - - MatrixSDK (0.27.9): - - MatrixSDK/Core (= 0.27.9) - - MatrixSDK/Core (0.27.9): + - MatrixSDK (0.27.10): + - MatrixSDK/Core (= 0.27.10) + - MatrixSDK/Core (0.27.10): - AFNetworking (~> 4.0.0) - GZIP (~> 1.3.0) - libbase58 (~> 0.1.4) @@ -49,7 +49,7 @@ PODS: - OLMKit (~> 3.2.5) - Realm (= 10.27.0) - SwiftyBeaver (= 1.9.5) - - MatrixSDK/JingleCallStack (0.27.9): + - MatrixSDK/JingleCallStack (0.27.10): - JitsiMeetSDKLite (= 8.1.2-lite) - MatrixSDK/Core - MatrixSDKCrypto (0.4.2) @@ -187,7 +187,7 @@ SPEC CHECKSUMS: libPhoneNumber-iOS: 0a32a9525cf8744fe02c5206eb30d571e38f7d75 LoggerAPI: ad9c4a6f1e32f518fdb43a1347ac14d765ab5e3d Logging: beeb016c9c80cf77042d62e83495816847ef108b - MatrixSDK: 246fd1d3620afcbf8cb76794e9343ebf3cbf881b + MatrixSDK: c805f9306d60955215f4b15043ed0f96fd4867b3 MatrixSDKCrypto: 736069ee0a5ec12852ab3498bf2242acecc443fc OLMKit: da115f16582e47626616874e20f7bb92222c7a51 ReadMoreTextView: 19147adf93abce6d7271e14031a00303fe28720d diff --git a/Riot/Categories/MXRoomSummary.swift b/Riot/Categories/MXRoomSummary.swift index b48f1a70f4..4cf55ff6a6 100644 --- a/Riot/Categories/MXRoomSummary.swift +++ b/Riot/Categories/MXRoomSummary.swift @@ -23,22 +23,21 @@ extension Notification.Name { extension MXRoomSummary { @objc static let roomSummaryDidRemoveExpiredDataFromStore = "roomSummaryDidRemoveExpiredDataFromStore" @objc static let roomRetentionStateEventType = "m.room.retention" + @objc static let roomRetentionEventMaxLifetimeKey = "max_lifetime" + @objc static let roomRetentionMaxLifetime = "roomRetentionMaxLifetime" - private enum Constants { - static let roomRetentionInDaysKey = "roomRetentionInDays" - } /// Get the room messages retention period in days - func roomRetentionPeriodInDays() -> uint { - if let period = self.others[Constants.roomRetentionInDaysKey] as? uint { + private func roomRetentionPeriodInMillis() -> UInt64 { + if let period = self.others[MXRoomSummary.roomRetentionMaxLifetime] as? UInt64 { return period } else { - return 365 + return Tools.durationInMs(fromDays: 365) } } /// Get the timestamp below which the received messages must be removed from the store, and the display @objc func minimumTimestamp() -> UInt64 { - let periodInMs = Tools.durationInMs(fromDays: self.roomRetentionPeriodInDays()) + let periodInMs = self.roomRetentionPeriodInMillis() let currentTs = (UInt64)(Date().timeIntervalSince1970 * 1000) return (currentTs - periodInMs) } diff --git a/Riot/Utils/EventFormatter.m b/Riot/Utils/EventFormatter.m index d53a3e19a0..2a1b15140b 100644 --- a/Riot/Utils/EventFormatter.m +++ b/Riot/Utils/EventFormatter.m @@ -632,7 +632,14 @@ - (MXEvent *)voiceBroadcastInfoStartedEventWithEvent:(MXEvent *)voiceBroadcastIn - (BOOL)session:(MXSession *)session updateRoomSummary:(MXRoomSummary *)summary withStateEvents:(NSArray *)stateEvents roomState:(MXRoomState *)roomState { BOOL updated = [super session:session updateRoomSummary:summary withStateEvents:stateEvents roomState:roomState]; - + + MXEvent* lastRoomRetentionEvent = [self roomRetentionEventFromStateEvents:stateEvents]; + if (lastRoomRetentionEvent) + { + summary.others[MXRoomSummary.roomRetentionMaxLifetime] = lastRoomRetentionEvent.content[MXRoomSummary.roomRetentionEventMaxLifetimeKey]; + updated = YES; + } + // Customisation for EMS Functional Members in direct rooms if (BuildSettings.supportFunctionalMembers && summary.room.isDirect) { @@ -645,7 +652,7 @@ - (BOOL)session:(MXSession *)session updateRoomSummary:(MXRoomSummary *)summary // room name which we'll do twice more in updateRoomSummary:withServerRoomSummary:roomState: anyway. // // So return YES and let that happen there. - return YES; + updated = YES; } } @@ -801,6 +808,12 @@ - (MXEvent *)functionalMembersEventFromStateEvents:(NSArray *)stateEv return [stateEvents filteredArrayUsingPredicate:functionalMembersPredicate].lastObject; } +- (MXEvent *)roomRetentionEventFromStateEvents:(NSArray *)stateEvents +{ + NSPredicate *functionalMembersPredicate = [NSPredicate predicateWithFormat:@"type == %@", kMXEventTypeStringRoomRetention]; + return [stateEvents filteredArrayUsingPredicate:functionalMembersPredicate].lastObject; +} + #pragma mark - Timestamp formatting - (NSString*)dateStringFromDate:(NSDate *)date withTime:(BOOL)time diff --git a/Riot/Utils/Tools.h b/Riot/Utils/Tools.h index 8d54e06b1d..f114167b3c 100644 --- a/Riot/Utils/Tools.h +++ b/Riot/Utils/Tools.h @@ -55,10 +55,4 @@ */ + (uint64_t)durationInMsFromDays:(uint)days; -/** - * Convert a duration in ms to a number of days. - */ -+ (uint)numberOfDaysFromDurationInMs:(uint64_t)duration; - - @end diff --git a/Riot/Utils/Tools.m b/Riot/Utils/Tools.m index 5866273ac8..4094d0223a 100644 --- a/Riot/Utils/Tools.m +++ b/Riot/Utils/Tools.m @@ -124,9 +124,4 @@ + (uint64_t)durationInMsFromDays:(uint)days return days * (uint64_t)(86400000); } -+ (uint)numberOfDaysFromDurationInMs:(uint64_t)duration -{ - return (uint)(duration / 86400000); -} - @end diff --git a/matrix-ios-sdk b/matrix-ios-sdk index fcfbb67182..ff2b2a4024 160000 --- a/matrix-ios-sdk +++ b/matrix-ios-sdk @@ -1 +1 @@ -Subproject commit fcfbb6718224e9819105b93fa9e86a9db1cf04a6 +Subproject commit ff2b2a4024b48dbeba5d4157d2622161b3034ba4 From ca90f363b181edc465e29c1dc972700b2dc54928 Mon Sep 17 00:00:00 2001 From: Mauro Romito Date: Tue, 18 Jun 2024 16:52:09 +0200 Subject: [PATCH 4/5] version++ --- CHANGES.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/CHANGES.md b/CHANGES.md index 93a8b15809..907d69b54b 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,3 +1,8 @@ +## Changes in 1.11.15 (2024-06-18) + +No significant changes. + + ## Changes in 1.11.14 (2024-06-17) 🙌 Improvements From 0c07ae2e9bcf084906ebfa423064eb93cc6c0292 Mon Sep 17 00:00:00 2001 From: Mauro Romito Date: Tue, 18 Jun 2024 16:54:46 +0200 Subject: [PATCH 5/5] finish version++