mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-04 01:20:12 +00:00
Switch to Xcode 14 and handle the UICollectionView-backed List. (#229)
* Fix Timeline on Xcode 14/iOS 16
Raise requirement to iOS 16+
Reduce pagination jumping.
Sonarcloud fixes.
Fix verification test.
Adopt if let optional { syntax.
* Remove unused ScrollViewReader
The ScrollViewReader didn't appear to change the behaviour.
* Fix warnings on Run Scripts.
Run script build phase 'SwiftLint' will be run during every build because it does not specify any outputs. To address this warning, either add output dependencies to the script phase, or configure it to run in every build by unchecking "Based on dependency analysis" in the script phase.
This commit is contained in:
@@ -52,7 +52,7 @@ class AnalyticsService {
|
||||
return .failure(.accountDataFailure)
|
||||
case .success(let settings):
|
||||
// The id has already be set so we are done here.
|
||||
if let settings = settings, settings.id != nil {
|
||||
if let settings, settings.id != nil {
|
||||
return .success(settings)
|
||||
}
|
||||
|
||||
|
||||
@@ -73,7 +73,7 @@ class PostHogAnalyticsClient: AnalyticsClientProtocol {
|
||||
}
|
||||
|
||||
func updateUserProperties(_ userProperties: AnalyticsEvent.UserProperties) {
|
||||
guard let pendingUserProperties = pendingUserProperties else {
|
||||
guard let pendingUserProperties else {
|
||||
pendingUserProperties = userProperties
|
||||
return
|
||||
}
|
||||
|
||||
@@ -100,8 +100,8 @@ class OIDCService {
|
||||
additionalParameters: nil)
|
||||
let result: OIDAuthorizationResponse = try await withCheckedThrowingContinuation { continuation in
|
||||
self.session = OIDAuthorizationService.present(request, externalUserAgent: userAgent) { response, error in
|
||||
guard let response = response else {
|
||||
if let error = error {
|
||||
guard let response else {
|
||||
if let error {
|
||||
MXLog.info("User cancelled the ASWebAuthenticationSession window")
|
||||
continuation.resume(with: .failure(self.isUserCancellationError(error) ? OIDCError.userCancellation : error))
|
||||
} else {
|
||||
@@ -136,7 +136,7 @@ extension OIDAuthorizationService {
|
||||
originalAuthorizationResponse authorizationResponse: OIDAuthorizationResponse?) async throws -> OIDTokenResponse {
|
||||
try await withCheckedThrowingContinuation { continuation in
|
||||
perform(request, originalAuthorizationResponse: authorizationResponse) { response, error in
|
||||
guard let response = response else {
|
||||
guard let response else {
|
||||
continuation.resume(with: .failure(error ?? OIDCError.unknown))
|
||||
return
|
||||
}
|
||||
|
||||
@@ -52,7 +52,7 @@ class UIKitBackgroundTask: BackgroundTaskProtocol {
|
||||
|
||||
// attempt to start
|
||||
identifier = application.beginBackgroundTask(withName: name) { [weak self] in
|
||||
guard let self = self else { return }
|
||||
guard let self else { return }
|
||||
self.expirationHandler?(self)
|
||||
}
|
||||
|
||||
|
||||
@@ -31,7 +31,7 @@ class UIKitBackgroundTaskService: BackgroundTaskServiceProtocol {
|
||||
func startBackgroundTask(withName name: String,
|
||||
isReusable: Bool,
|
||||
expirationHandler: (() -> Void)?) -> BackgroundTaskProtocol? {
|
||||
guard let application = application else {
|
||||
guard let application else {
|
||||
MXLog.verbose("Do not start background task: \(name). Application is nil")
|
||||
return nil
|
||||
}
|
||||
@@ -54,7 +54,7 @@ class UIKitBackgroundTaskService: BackgroundTaskServiceProtocol {
|
||||
isReusable: isReusable,
|
||||
application: application,
|
||||
expirationHandler: { [weak self] task in
|
||||
guard let self = self else { return }
|
||||
guard let self else { return }
|
||||
self.reusableTasks[task.name] = nil
|
||||
expirationHandler?()
|
||||
}) {
|
||||
|
||||
@@ -69,7 +69,7 @@ class ScreenshotDetector {
|
||||
targetSize: PHImageManagerMaximumSize,
|
||||
contentMode: .default,
|
||||
options: PHImageRequestOptions.highQualitySyncLocal) { [weak self] image, _ in
|
||||
guard let image = image else {
|
||||
guard let image else {
|
||||
self?.fail(withError: ScreenshotDetectorError.loadFailed)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -31,7 +31,7 @@ struct MediaProvider: MediaProviderProtocol {
|
||||
}
|
||||
|
||||
func imageFromSource(_ source: MediaSource?, avatarSize: AvatarSize?) -> UIImage? {
|
||||
guard let source = source else {
|
||||
guard let source else {
|
||||
return nil
|
||||
}
|
||||
let cacheKey = cacheKeyForURLString(source.underlyingSource.url(), avatarSize: avatarSize)
|
||||
@@ -39,7 +39,7 @@ struct MediaProvider: MediaProviderProtocol {
|
||||
}
|
||||
|
||||
func imageFromURLString(_ urlString: String?, avatarSize: AvatarSize?) -> UIImage? {
|
||||
guard let urlString = urlString else {
|
||||
guard let urlString else {
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -70,7 +70,7 @@ struct MediaProvider: MediaProviderProtocol {
|
||||
|
||||
do {
|
||||
let imageData = try await Task.detached { () -> Data in
|
||||
if let avatarSize = avatarSize {
|
||||
if let avatarSize {
|
||||
return try await clientProxy.loadMediaThumbnailForSource(source.underlyingSource, width: UInt(avatarSize.scaledValue), height: UInt(avatarSize.scaledValue))
|
||||
} else {
|
||||
return try await clientProxy.loadMediaContentForSource(source.underlyingSource)
|
||||
@@ -97,7 +97,7 @@ struct MediaProvider: MediaProviderProtocol {
|
||||
// MARK: - Private
|
||||
|
||||
private func cacheKeyForURLString(_ urlString: String, avatarSize: AvatarSize?) -> String {
|
||||
if let avatarSize = avatarSize {
|
||||
if let avatarSize {
|
||||
return "\(urlString){\(avatarSize.scaledValue),\(avatarSize.scaledValue)}"
|
||||
} else {
|
||||
return urlString
|
||||
|
||||
@@ -31,7 +31,7 @@ struct MockMediaProvider: MediaProviderProtocol {
|
||||
return nil
|
||||
}
|
||||
|
||||
if let avatarSize = avatarSize {
|
||||
if let avatarSize {
|
||||
switch avatarSize {
|
||||
case .room:
|
||||
return Asset.Images.appLogo.image
|
||||
|
||||
@@ -128,7 +128,7 @@ class RoomProxy: RoomProxyProtocol {
|
||||
}
|
||||
|
||||
func loadDisplayName() async -> Result<String, RoomProxyError> {
|
||||
if let displayName = displayName { return .success(displayName) }
|
||||
if let displayName { return .success(displayName) }
|
||||
|
||||
do {
|
||||
let displayName = try await Task.dispatch(on: .global()) {
|
||||
@@ -176,7 +176,7 @@ class RoomProxy: RoomProxyProtocol {
|
||||
|
||||
return await Task.dispatch(on: .global()) {
|
||||
do {
|
||||
if let inReplyToEventId = inReplyToEventId {
|
||||
if let inReplyToEventId {
|
||||
try self.room.sendReply(msg: message, inReplyToEventId: inReplyToEventId, txnId: transactionId)
|
||||
} else {
|
||||
let messageContent = messageEventContentFromMarkdown(md: message)
|
||||
|
||||
@@ -54,7 +54,7 @@ class RoomTimelineController: RoomTimelineControllerProtocol {
|
||||
.callbacks
|
||||
.receive(on: DispatchQueue.main)
|
||||
.sink { [weak self] callback in
|
||||
guard let self = self else { return }
|
||||
guard let self else { return }
|
||||
|
||||
switch callback {
|
||||
case .updatedMessages:
|
||||
@@ -248,7 +248,7 @@ class RoomTimelineController: RoomTimelineControllerProtocol {
|
||||
|
||||
switch await roomProxy.loadAvatarURLForUserId(timelineItem.senderId) {
|
||||
case .success(let avatarURLString):
|
||||
guard let avatarURLString = avatarURLString else {
|
||||
guard let avatarURLString else {
|
||||
return
|
||||
}
|
||||
|
||||
@@ -278,7 +278,7 @@ class RoomTimelineController: RoomTimelineControllerProtocol {
|
||||
|
||||
switch await roomProxy.loadDisplayNameForUserId(timelineItem.senderId) {
|
||||
case .success(let displayName):
|
||||
guard let displayName = displayName,
|
||||
guard let displayName,
|
||||
let index = timelineItems.firstIndex(where: { $0.id == timelineItem.id }),
|
||||
var item = timelineItems[index] as? EventBasedTimelineItemProtocol else {
|
||||
return
|
||||
|
||||
@@ -106,34 +106,34 @@ private extension RoomTimelineProvider {
|
||||
}
|
||||
|
||||
private func replaceItems(_ items: [MatrixRustSDK.TimelineItem]?) {
|
||||
guard let items = items else { return }
|
||||
guard let items else { return }
|
||||
itemProxies = items.map(TimelineItemProxy.init)
|
||||
}
|
||||
|
||||
private func insertItem(_ data: InsertAtData?) {
|
||||
guard let data = data else { return }
|
||||
guard let data else { return }
|
||||
let itemProxy = TimelineItemProxy(item: data.item)
|
||||
itemProxies.insert(itemProxy, at: Int(data.index))
|
||||
}
|
||||
|
||||
private func updateItem(_ data: UpdateAtData?) {
|
||||
guard let data = data else { return }
|
||||
guard let data else { return }
|
||||
let itemProxy = TimelineItemProxy(item: data.item)
|
||||
itemProxies[Int(data.index)] = itemProxy
|
||||
}
|
||||
|
||||
private func removeItem(at index: UInt32?) {
|
||||
guard let index = index else { return }
|
||||
guard let index else { return }
|
||||
itemProxies.remove(at: Int(index))
|
||||
}
|
||||
|
||||
private func moveItem(_ data: MoveData?) {
|
||||
guard let data = data else { return }
|
||||
guard let data else { return }
|
||||
itemProxies.move(fromOffsets: IndexSet(integer: Int(data.oldIndex)), toOffset: Int(data.newIndex))
|
||||
}
|
||||
|
||||
private func pushItem(_ item: MatrixRustSDK.TimelineItem?) {
|
||||
guard let item = item else { return }
|
||||
guard let item else { return }
|
||||
itemProxies.append(TimelineItemProxy(item: item))
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user