mirror of
https://gitlab.opencode.de/bwi/bundesmessenger/clients/bundesmessenger-ios.git
synced 2026-05-05 15:37:45 +02:00
Merge commit '80bda1906235b6007b98f18fb13681fff587f4a3' into feature/basis_update_192
# Conflicts: # Config/AppVersion.xcconfig # Config/BuildSettings.swift # DesignKit/Source/ColorsSwiftUI.swift # DesignKit/Source/FontsSwiftUI.swift # DesignKit/Source/ThemeV2.swift # DesignKit/Variants/Colors/Dark/DarkColors.swift # DesignKit/Variants/Colors/Light/LightColors.swift # Podfile.lock # Riot/Assets/de.lproj/InfoPlist.strings # Riot/Assets/de.lproj/Vector.strings # Riot/Assets/en.lproj/Vector.strings # Riot/Generated/Images.swift # Riot/Generated/Strings.swift # Riot/Managers/PushNotification/PushNotificationService.m # Riot/Managers/Settings/RiotSettings.swift # Riot/Modules/Common/Recents/DataSources/RecentsDataSource.h # Riot/Modules/Common/Recents/RecentsViewController.m # Riot/Modules/Communities/Home/GroupHomeViewController.m # Riot/Modules/Room/RoomViewController.m # Riot/Modules/SetPinCode/PinCodePreferences.swift # Riot/Modules/Settings/SettingsViewController.m # Riot/Modules/TabBar/MasterTabBarController.h # Riot/Modules/TabBar/MasterTabBarController.m # Riot/Modules/TabBar/TabBarCoordinator.swift # fastlane/Fastfile # project.yml
This commit is contained in:
@@ -69,9 +69,9 @@ const CGFloat kTypingCellHeight = 24;
|
||||
|
||||
@implementation RoomDataSource
|
||||
|
||||
- (instancetype)initWithRoomId:(NSString *)roomId andMatrixSession:(MXSession *)matrixSession
|
||||
- (instancetype)initWithRoomId:(NSString *)roomId andMatrixSession:(MXSession *)matrixSession threadId:(NSString *)threadId
|
||||
{
|
||||
self = [super initWithRoomId:roomId andMatrixSession:matrixSession];
|
||||
self = [super initWithRoomId:roomId andMatrixSession:matrixSession threadId:threadId];
|
||||
if (self)
|
||||
{
|
||||
// Replace default Cell data class
|
||||
@@ -163,7 +163,6 @@ const CGFloat kTypingCellHeight = 24;
|
||||
self.eventFormatter.treatMatrixUserIdAsLink = YES;
|
||||
self.eventFormatter.treatMatrixRoomIdAsLink = YES;
|
||||
self.eventFormatter.treatMatrixRoomAliasAsLink = YES;
|
||||
self.eventFormatter.treatMatrixGroupIdAsLink = YES;
|
||||
|
||||
// Apply the event types filter to display only the wanted event types.
|
||||
self.eventFormatter.eventTypesFilterForMessages = [MXKAppSettings standardAppSettings].eventsFilterForMessages;
|
||||
|
||||
@@ -15,15 +15,31 @@
|
||||
//
|
||||
|
||||
import Foundation
|
||||
import UIKit
|
||||
|
||||
@objcMembers
|
||||
public class ThreadDataSource: RoomDataSource {
|
||||
|
||||
private typealias ThreadID = String
|
||||
|
||||
/// Map of cached data sources. Keys are thread identifiers.
|
||||
private static var dataSourceCache: [ThreadID: ThreadDataSource] = [:]
|
||||
|
||||
public override func finalizeInitialization() {
|
||||
super.finalizeInitialization()
|
||||
showReadMarker = false
|
||||
showBubbleReceipts = false
|
||||
showTypingRow = false
|
||||
|
||||
NotificationCenter.default.addObserver(self,
|
||||
selector: #selector(didReceiveMemoryWarning),
|
||||
name: UIApplication.didReceiveMemoryWarningNotification,
|
||||
object: nil)
|
||||
|
||||
NotificationCenter.default.addObserver(self,
|
||||
selector: #selector(didLeaveRoom(_:)),
|
||||
name: .mxSessionDidLeaveRoom,
|
||||
object: nil)
|
||||
}
|
||||
|
||||
public override var showReadMarker: Bool {
|
||||
@@ -41,5 +57,47 @@ public class ThreadDataSource: RoomDataSource {
|
||||
_ = newValue
|
||||
}
|
||||
}
|
||||
|
||||
public override class func load(withRoomId roomId: String!,
|
||||
initialEventId: String!,
|
||||
threadId: String!,
|
||||
andMatrixSession mxSession: MXSession!,
|
||||
onComplete: ((Any?) -> Void)!) {
|
||||
if let dataSource = dataSourceCache[threadId] {
|
||||
onComplete(dataSource)
|
||||
return
|
||||
}
|
||||
super.load(withRoomId: roomId, initialEventId: initialEventId, threadId: threadId, andMatrixSession: mxSession) { dataSource in
|
||||
if let dataSource = dataSource as? ThreadDataSource {
|
||||
Self.dataSourceCache[threadId] = dataSource
|
||||
}
|
||||
onComplete(dataSource)
|
||||
}
|
||||
}
|
||||
|
||||
@objc
|
||||
private func didReceiveMemoryWarning() {
|
||||
MXLog.debug("[ThreadDataSource] didReceiveMemoryWarning. Will reload not active data sources in cache.")
|
||||
|
||||
Self.dataSourceCache.forEach {
|
||||
if $1.delegate == nil {
|
||||
$1.reload()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@objc
|
||||
private func didLeaveRoom(_ notification: Notification) {
|
||||
MXLog.debug("[ThreadDataSource] didReceiveMemoryWarning. Will reload not active data sources in cache.")
|
||||
|
||||
guard let session = notification.object as? MXSession,
|
||||
session == mxSession,
|
||||
let roomId = notification.userInfo?[kMXSessionNotificationRoomIdKey] as? String else {
|
||||
return
|
||||
}
|
||||
|
||||
let threadIds = Array(Self.dataSourceCache.filter { $1.roomId == roomId }.keys)
|
||||
threadIds.forEach { Self.dataSourceCache.removeValue(forKey: $0) }
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user