mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-03 06:55:59 +00:00
SDK Bump to 1.0.73-alpha (#1043)
* sdk bump * moved the bump event types to the sliding sync list builder * removed sync growing mode from notifications even if we are not really using it anymore * recency order is also for the all room list * removed the local notification code entirely * removed unused function * fixed the code placement for the ordering
This commit is contained in:
@@ -4780,7 +4780,7 @@
|
|||||||
repositoryURL = "https://github.com/matrix-org/matrix-rust-components-swift";
|
repositoryURL = "https://github.com/matrix-org/matrix-rust-components-swift";
|
||||||
requirement = {
|
requirement = {
|
||||||
kind = exactVersion;
|
kind = exactVersion;
|
||||||
version = "1.0.72-alpha";
|
version = "1.0.73-alpha";
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
96495DD8554E2F39D3954354 /* XCRemoteSwiftPackageReference "posthog-ios" */ = {
|
96495DD8554E2F39D3954354 /* XCRemoteSwiftPackageReference "posthog-ios" */ = {
|
||||||
|
|||||||
@@ -11,7 +11,7 @@
|
|||||||
{
|
{
|
||||||
"identity" : "compound-ios",
|
"identity" : "compound-ios",
|
||||||
"kind" : "remoteSourceControl",
|
"kind" : "remoteSourceControl",
|
||||||
"location" : "https://github.com/vector-im/compound-ios.git",
|
"location" : "https://github.com/vector-im/compound-ios",
|
||||||
"state" : {
|
"state" : {
|
||||||
"revision" : "aaa43409ca09130cb9e9a0fe02c803c65aa42aed"
|
"revision" : "aaa43409ca09130cb9e9a0fe02c803c65aa42aed"
|
||||||
}
|
}
|
||||||
@@ -102,8 +102,8 @@
|
|||||||
"kind" : "remoteSourceControl",
|
"kind" : "remoteSourceControl",
|
||||||
"location" : "https://github.com/matrix-org/matrix-rust-components-swift",
|
"location" : "https://github.com/matrix-org/matrix-rust-components-swift",
|
||||||
"state" : {
|
"state" : {
|
||||||
"revision" : "d0533a4ba40ff1d9ea9c6473a07639fa9b9c5079",
|
"revision" : "849e6c5c47d0172b28d757dee0c7d203bf4b34cc",
|
||||||
"version" : "1.0.72-alpha"
|
"version" : "1.0.73-alpha"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -159,8 +159,6 @@ final class AppSettings {
|
|||||||
@UserPreference(key: UserDefaultsKeys.enableInAppNotifications, defaultValue: true, storageType: .userDefaults(store))
|
@UserPreference(key: UserDefaultsKeys.enableInAppNotifications, defaultValue: true, storageType: .userDefaults(store))
|
||||||
var enableInAppNotifications
|
var enableInAppNotifications
|
||||||
|
|
||||||
let enableLocalPushNotifications = false
|
|
||||||
|
|
||||||
/// Tag describing which set of device specific rules a pusher executes.
|
/// Tag describing which set of device specific rules a pusher executes.
|
||||||
@UserPreference(key: UserDefaultsKeys.pusherProfileTag, storageType: .userDefaults(store))
|
@UserPreference(key: UserDefaultsKeys.pusherProfileTag, storageType: .userDefaults(store))
|
||||||
var pusherProfileTag: String?
|
var pusherProfileTag: String?
|
||||||
|
|||||||
@@ -192,27 +192,27 @@ class SDKClientMock: SDKClientProtocol {
|
|||||||
}
|
}
|
||||||
//MARK: - `getMediaFile`
|
//MARK: - `getMediaFile`
|
||||||
|
|
||||||
public var getMediaFileMediaSourceBodyMimeTypeThrowableError: Error?
|
public var getMediaFileMediaSourceBodyMimeTypeTempDirThrowableError: Error?
|
||||||
public var getMediaFileMediaSourceBodyMimeTypeCallsCount = 0
|
public var getMediaFileMediaSourceBodyMimeTypeTempDirCallsCount = 0
|
||||||
public var getMediaFileMediaSourceBodyMimeTypeCalled: Bool {
|
public var getMediaFileMediaSourceBodyMimeTypeTempDirCalled: Bool {
|
||||||
return getMediaFileMediaSourceBodyMimeTypeCallsCount > 0
|
return getMediaFileMediaSourceBodyMimeTypeTempDirCallsCount > 0
|
||||||
}
|
}
|
||||||
public var getMediaFileMediaSourceBodyMimeTypeReceivedArguments: (`mediaSource`: MediaSource, `body`: String?, `mimeType`: String)?
|
public var getMediaFileMediaSourceBodyMimeTypeTempDirReceivedArguments: (`mediaSource`: MediaSource, `body`: String?, `mimeType`: String, `tempDir`: String?)?
|
||||||
public var getMediaFileMediaSourceBodyMimeTypeReceivedInvocations: [(`mediaSource`: MediaSource, `body`: String?, `mimeType`: String)] = []
|
public var getMediaFileMediaSourceBodyMimeTypeTempDirReceivedInvocations: [(`mediaSource`: MediaSource, `body`: String?, `mimeType`: String, `tempDir`: String?)] = []
|
||||||
public var getMediaFileMediaSourceBodyMimeTypeReturnValue: MediaFileHandle!
|
public var getMediaFileMediaSourceBodyMimeTypeTempDirReturnValue: MediaFileHandle!
|
||||||
public var getMediaFileMediaSourceBodyMimeTypeClosure: ((MediaSource, String?, String) throws -> MediaFileHandle)?
|
public var getMediaFileMediaSourceBodyMimeTypeTempDirClosure: ((MediaSource, String?, String, String?) throws -> MediaFileHandle)?
|
||||||
|
|
||||||
public func `getMediaFile`(`mediaSource`: MediaSource, `body`: String?, `mimeType`: String) throws -> MediaFileHandle {
|
public func `getMediaFile`(`mediaSource`: MediaSource, `body`: String?, `mimeType`: String, `tempDir`: String?) throws -> MediaFileHandle {
|
||||||
if let error = getMediaFileMediaSourceBodyMimeTypeThrowableError {
|
if let error = getMediaFileMediaSourceBodyMimeTypeTempDirThrowableError {
|
||||||
throw error
|
throw error
|
||||||
}
|
}
|
||||||
getMediaFileMediaSourceBodyMimeTypeCallsCount += 1
|
getMediaFileMediaSourceBodyMimeTypeTempDirCallsCount += 1
|
||||||
getMediaFileMediaSourceBodyMimeTypeReceivedArguments = (`mediaSource`: `mediaSource`, `body`: `body`, `mimeType`: `mimeType`)
|
getMediaFileMediaSourceBodyMimeTypeTempDirReceivedArguments = (`mediaSource`: `mediaSource`, `body`: `body`, `mimeType`: `mimeType`, `tempDir`: `tempDir`)
|
||||||
getMediaFileMediaSourceBodyMimeTypeReceivedInvocations.append((`mediaSource`: `mediaSource`, `body`: `body`, `mimeType`: `mimeType`))
|
getMediaFileMediaSourceBodyMimeTypeTempDirReceivedInvocations.append((`mediaSource`: `mediaSource`, `body`: `body`, `mimeType`: `mimeType`, `tempDir`: `tempDir`))
|
||||||
if let getMediaFileMediaSourceBodyMimeTypeClosure = getMediaFileMediaSourceBodyMimeTypeClosure {
|
if let getMediaFileMediaSourceBodyMimeTypeTempDirClosure = getMediaFileMediaSourceBodyMimeTypeTempDirClosure {
|
||||||
return try getMediaFileMediaSourceBodyMimeTypeClosure(`mediaSource`, `body`, `mimeType`)
|
return try getMediaFileMediaSourceBodyMimeTypeTempDirClosure(`mediaSource`, `body`, `mimeType`, `tempDir`)
|
||||||
} else {
|
} else {
|
||||||
return getMediaFileMediaSourceBodyMimeTypeReturnValue
|
return getMediaFileMediaSourceBodyMimeTypeTempDirReturnValue
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//MARK: - `getMediaThumbnail`
|
//MARK: - `getMediaThumbnail`
|
||||||
@@ -559,23 +559,6 @@ class SDKClientMock: SDKClientProtocol {
|
|||||||
setPusherIdentifiersKindAppDisplayNameDeviceDisplayNameProfileTagLangReceivedInvocations.append((`identifiers`: `identifiers`, `kind`: `kind`, `appDisplayName`: `appDisplayName`, `deviceDisplayName`: `deviceDisplayName`, `profileTag`: `profileTag`, `lang`: `lang`))
|
setPusherIdentifiersKindAppDisplayNameDeviceDisplayNameProfileTagLangReceivedInvocations.append((`identifiers`: `identifiers`, `kind`: `kind`, `appDisplayName`: `appDisplayName`, `deviceDisplayName`: `deviceDisplayName`, `profileTag`: `profileTag`, `lang`: `lang`))
|
||||||
try setPusherIdentifiersKindAppDisplayNameDeviceDisplayNameProfileTagLangClosure?(`identifiers`, `kind`, `appDisplayName`, `deviceDisplayName`, `profileTag`, `lang`)
|
try setPusherIdentifiersKindAppDisplayNameDeviceDisplayNameProfileTagLangClosure?(`identifiers`, `kind`, `appDisplayName`, `deviceDisplayName`, `profileTag`, `lang`)
|
||||||
}
|
}
|
||||||
//MARK: - `slidingSync`
|
|
||||||
|
|
||||||
public var slidingSyncCallsCount = 0
|
|
||||||
public var slidingSyncCalled: Bool {
|
|
||||||
return slidingSyncCallsCount > 0
|
|
||||||
}
|
|
||||||
public var slidingSyncReturnValue: SlidingSyncBuilder!
|
|
||||||
public var slidingSyncClosure: (() -> SlidingSyncBuilder)?
|
|
||||||
|
|
||||||
public func `slidingSync`() -> SlidingSyncBuilder {
|
|
||||||
slidingSyncCallsCount += 1
|
|
||||||
if let slidingSyncClosure = slidingSyncClosure {
|
|
||||||
return slidingSyncClosure()
|
|
||||||
} else {
|
|
||||||
return slidingSyncReturnValue
|
|
||||||
}
|
|
||||||
}
|
|
||||||
//MARK: - `unignoreUser`
|
//MARK: - `unignoreUser`
|
||||||
|
|
||||||
public var unignoreUserUserIdThrowableError: Error?
|
public var unignoreUserUserIdThrowableError: Error?
|
||||||
@@ -642,5 +625,30 @@ class SDKClientMock: SDKClientProtocol {
|
|||||||
return userIdReturnValue
|
return userIdReturnValue
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
//MARK: - `slidingSync`
|
||||||
|
|
||||||
|
public var slidingSyncIdThrowableError: Error?
|
||||||
|
public var slidingSyncIdCallsCount = 0
|
||||||
|
public var slidingSyncIdCalled: Bool {
|
||||||
|
return slidingSyncIdCallsCount > 0
|
||||||
|
}
|
||||||
|
public var slidingSyncIdReceivedId: String?
|
||||||
|
public var slidingSyncIdReceivedInvocations: [String] = []
|
||||||
|
public var slidingSyncIdReturnValue: SlidingSyncBuilder!
|
||||||
|
public var slidingSyncIdClosure: ((String) throws -> SlidingSyncBuilder)?
|
||||||
|
|
||||||
|
public func `slidingSync`(`id`: String) throws -> SlidingSyncBuilder {
|
||||||
|
if let error = slidingSyncIdThrowableError {
|
||||||
|
throw error
|
||||||
|
}
|
||||||
|
slidingSyncIdCallsCount += 1
|
||||||
|
slidingSyncIdReceivedId = id
|
||||||
|
slidingSyncIdReceivedInvocations.append(`id`)
|
||||||
|
if let slidingSyncIdClosure = slidingSyncIdClosure {
|
||||||
|
return try slidingSyncIdClosure(`id`)
|
||||||
|
} else {
|
||||||
|
return slidingSyncIdReturnValue
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// swiftlint:enable all
|
// swiftlint:enable all
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ import Foundation
|
|||||||
import MatrixRustSDK
|
import MatrixRustSDK
|
||||||
import UIKit
|
import UIKit
|
||||||
|
|
||||||
private class WeakClientProxyWrapper: ClientDelegate, NotificationDelegate, SlidingSyncObserver {
|
private class WeakClientProxyWrapper: ClientDelegate, SlidingSyncObserver {
|
||||||
private weak var clientProxy: ClientProxy?
|
private weak var clientProxy: ClientProxy?
|
||||||
|
|
||||||
init(clientProxy: ClientProxy) {
|
init(clientProxy: ClientProxy) {
|
||||||
@@ -44,13 +44,6 @@ private class WeakClientProxyWrapper: ClientDelegate, NotificationDelegate, Slid
|
|||||||
MXLog.info("Received sliding sync update")
|
MXLog.info("Received sliding sync update")
|
||||||
clientProxy?.didReceiveSlidingSyncUpdate(summary: summary)
|
clientProxy?.didReceiveSlidingSyncUpdate(summary: summary)
|
||||||
}
|
}
|
||||||
|
|
||||||
// MARK: - NotificationDelegate
|
|
||||||
|
|
||||||
func didReceiveNotification(notification: MatrixRustSDK.NotificationItem) {
|
|
||||||
guard let userID = clientProxy?.userID else { return }
|
|
||||||
clientProxy?.didReceiveNotification(notification: NotificationItemProxy(notificationItem: notification, receiverID: userID))
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class ClientProxy: ClientProxyProtocol {
|
class ClientProxy: ClientProxyProtocol {
|
||||||
@@ -76,7 +69,7 @@ class ClientProxy: ClientProxyProtocol {
|
|||||||
var invitesListProxy: SlidingSyncListProxy?
|
var invitesListProxy: SlidingSyncListProxy?
|
||||||
var invitesSummaryProvider: RoomSummaryProviderProtocol?
|
var invitesSummaryProvider: RoomSummaryProviderProtocol?
|
||||||
|
|
||||||
var notificationsListBuilder: SlidingSyncListBuilder?
|
private let roomListRecencyOrderingAllowedEventTypes = ["m.room.message", "m.room.encrypted", "m.sticker"]
|
||||||
|
|
||||||
private var loadCachedAvatarURLTask: Task<Void, Never>?
|
private var loadCachedAvatarURLTask: Task<Void, Never>?
|
||||||
private let avatarURLSubject = CurrentValueSubject<URL?, Never>(nil)
|
private let avatarURLSubject = CurrentValueSubject<URL?, Never>(nil)
|
||||||
@@ -109,13 +102,6 @@ class ClientProxy: ClientProxyProtocol {
|
|||||||
|
|
||||||
let delegate = WeakClientProxyWrapper(clientProxy: self)
|
let delegate = WeakClientProxyWrapper(clientProxy: self)
|
||||||
client.setDelegate(delegate: delegate)
|
client.setDelegate(delegate: delegate)
|
||||||
|
|
||||||
// Set up sync listener for generating local notifications.
|
|
||||||
if ServiceLocator.shared.settings.enableLocalPushNotifications {
|
|
||||||
await Task.dispatch(on: clientQueue) {
|
|
||||||
client.setNotificationDelegate(notificationDelegate: delegate)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
configureSlidingSync()
|
configureSlidingSync()
|
||||||
|
|
||||||
@@ -414,31 +400,24 @@ class ClientProxy: ClientProxyProtocol {
|
|||||||
}
|
}
|
||||||
|
|
||||||
do {
|
do {
|
||||||
let slidingSyncBuilder = client.slidingSync()
|
let slidingSyncBuilder = try client.slidingSync(id: "ElementX")
|
||||||
|
|
||||||
// List observers need to be setup before calling build() on the SlidingSyncBuilder otherwise
|
// List observers need to be setup before calling build() on the SlidingSyncBuilder otherwise
|
||||||
// cold cache state and count updates will be lost
|
// cold cache state and count updates will be lost
|
||||||
buildAndConfigureVisibleRoomsSlidingSyncList()
|
buildAndConfigureVisibleRoomsSlidingSyncList()
|
||||||
buildAndConfigureAllRoomsSlidingSyncList()
|
buildAndConfigureAllRoomsSlidingSyncList()
|
||||||
buildAndConfigureInvitesSlidingSyncList()
|
buildAndConfigureInvitesSlidingSyncList()
|
||||||
if ServiceLocator.shared.settings.enableLocalPushNotifications {
|
|
||||||
buildAndConfigureNotificationsSlidingSyncList()
|
|
||||||
}
|
|
||||||
|
|
||||||
guard let visibleRoomsListBuilder else {
|
guard let visibleRoomsListBuilder else {
|
||||||
MXLog.error("Visible rooms sliding sync view unavailable")
|
MXLog.error("Visible rooms sliding sync view unavailable")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
let roomListRecencyOrderingAllowedEventTypes = ["m.room.message", "m.room.encrypted", "m.sticker"]
|
|
||||||
|
|
||||||
// Add the visibleRoomsSlidingSyncList here so that it can take advantage of the SS builder cold cache
|
// Add the visibleRoomsSlidingSyncList here so that it can take advantage of the SS builder cold cache
|
||||||
// We will still register the allRoomsSlidingSyncList later, and than will have no cache
|
// We will still register the allRoomsSlidingSyncList later, and than will have no cache
|
||||||
let slidingSync = try slidingSyncBuilder
|
let slidingSync = try slidingSyncBuilder
|
||||||
.addList(listBuilder: visibleRoomsListBuilder)
|
.addList(listBuilder: visibleRoomsListBuilder)
|
||||||
.withCommonExtensions()
|
.withCommonExtensions()
|
||||||
.bumpEventTypes(bumpEventTypes: roomListRecencyOrderingAllowedEventTypes)
|
|
||||||
// .storageKey(name: "ElementX")
|
|
||||||
.build()
|
.build()
|
||||||
|
|
||||||
// Don't forget to update the view proxies after building the slidingSync
|
// Don't forget to update the view proxies after building the slidingSync
|
||||||
@@ -466,12 +445,13 @@ class ClientProxy: ClientProxyProtocol {
|
|||||||
let listName = "CurrentlyVisibleRooms"
|
let listName = "CurrentlyVisibleRooms"
|
||||||
|
|
||||||
let visibleRoomsListProxy = SlidingSyncListProxy(name: listName)
|
let visibleRoomsListProxy = SlidingSyncListProxy(name: listName)
|
||||||
|
|
||||||
let visibleRoomsListBuilder = SlidingSyncListBuilder(name: listName)
|
let visibleRoomsListBuilder = SlidingSyncListBuilder(name: listName)
|
||||||
.timelineLimit(limit: UInt32(SlidingSyncConstants.initialTimelineLimit)) // Starts off with zero to quickly load rooms, then goes to 1 while scrolling to quickly load last messages and 20 when the scrolling stops to load room history
|
.timelineLimit(limit: UInt32(SlidingSyncConstants.initialTimelineLimit)) // Starts off with zero to quickly load rooms, then goes to 1 while scrolling to quickly load last messages and 20 when the scrolling stops to load room history
|
||||||
.requiredState(requiredState: slidingSyncRequiredState)
|
.requiredState(requiredState: slidingSyncRequiredState)
|
||||||
.filters(filters: slidingSyncFilters)
|
.filters(filters: slidingSyncFilters)
|
||||||
.syncModeSelective(selectiveModeBuilder: .init().addRange(start: 0, endInclusive: 20))
|
.syncModeSelective(selectiveModeBuilder: .init().addRange(start: 0, endInclusive: 20))
|
||||||
|
.bumpEventTypes(bumpEventTypes: roomListRecencyOrderingAllowedEventTypes)
|
||||||
.onceBuilt(callback: visibleRoomsListProxy)
|
.onceBuilt(callback: visibleRoomsListProxy)
|
||||||
|
|
||||||
self.visibleRoomsListBuilder = visibleRoomsListBuilder
|
self.visibleRoomsListBuilder = visibleRoomsListBuilder
|
||||||
@@ -503,6 +483,7 @@ class ClientProxy: ClientProxyProtocol {
|
|||||||
.requiredState(requiredState: slidingSyncRequiredState)
|
.requiredState(requiredState: slidingSyncRequiredState)
|
||||||
.filters(filters: slidingSyncFilters)
|
.filters(filters: slidingSyncFilters)
|
||||||
.syncModeGrowing(batchSize: 100, maximumNumberOfRoomsToFetch: nil)
|
.syncModeGrowing(batchSize: 100, maximumNumberOfRoomsToFetch: nil)
|
||||||
|
.bumpEventTypes(bumpEventTypes: roomListRecencyOrderingAllowedEventTypes)
|
||||||
.onceBuilt(callback: allRoomsListProxy)
|
.onceBuilt(callback: allRoomsListProxy)
|
||||||
|
|
||||||
self.allRoomsListBuilder = allRoomsListBuilder
|
self.allRoomsListBuilder = allRoomsListBuilder
|
||||||
@@ -529,20 +510,6 @@ class ClientProxy: ClientProxyProtocol {
|
|||||||
self.invitesListProxy = invitesListProxy
|
self.invitesListProxy = invitesListProxy
|
||||||
}
|
}
|
||||||
|
|
||||||
private func buildAndConfigureNotificationsSlidingSyncList() {
|
|
||||||
guard notificationsListBuilder == nil else {
|
|
||||||
fatalError("This shouldn't be called more than once")
|
|
||||||
}
|
|
||||||
|
|
||||||
let notificationsListBuilder = SlidingSyncListBuilder(name: "Notifications")
|
|
||||||
.noTimelineLimit()
|
|
||||||
.requiredState(requiredState: slidingSyncNotificationsRequiredState)
|
|
||||||
.filters(filters: slidingSyncNotificationsFilters)
|
|
||||||
.syncModeGrowing(batchSize: 100, maximumNumberOfRoomsToFetch: nil)
|
|
||||||
|
|
||||||
self.notificationsListBuilder = notificationsListBuilder
|
|
||||||
}
|
|
||||||
|
|
||||||
private func buildRoomSummaryProviders() {
|
private func buildRoomSummaryProviders() {
|
||||||
guard visibleRoomsSummaryProvider == nil, allRoomsSummaryProvider == nil, invitesSummaryProvider == nil else {
|
guard visibleRoomsSummaryProvider == nil, allRoomsSummaryProvider == nil, invitesSummaryProvider == nil else {
|
||||||
fatalError("This shouldn't be called more than once")
|
fatalError("This shouldn't be called more than once")
|
||||||
@@ -569,10 +536,6 @@ class ClientProxy: ClientProxyProtocol {
|
|||||||
private lazy var slidingSyncRequiredState = [RequiredState(key: "m.room.avatar", value: ""),
|
private lazy var slidingSyncRequiredState = [RequiredState(key: "m.room.avatar", value: ""),
|
||||||
RequiredState(key: "m.room.encryption", value: ""),
|
RequiredState(key: "m.room.encryption", value: ""),
|
||||||
RequiredState(key: "m.room.power_levels", value: "")]
|
RequiredState(key: "m.room.power_levels", value: "")]
|
||||||
|
|
||||||
private lazy var slidingSyncNotificationsRequiredState = [RequiredState(key: "m.room.member", value: "$ME"),
|
|
||||||
RequiredState(key: "m.room.power_levels", value: ""),
|
|
||||||
RequiredState(key: "m.room.name", value: "")]
|
|
||||||
|
|
||||||
private lazy var slidingSyncInvitesRequiredState = [RequiredState(key: "m.room.avatar", value: ""),
|
private lazy var slidingSyncInvitesRequiredState = [RequiredState(key: "m.room.avatar", value: ""),
|
||||||
RequiredState(key: "m.room.encryption", value: ""),
|
RequiredState(key: "m.room.encryption", value: ""),
|
||||||
@@ -589,17 +552,6 @@ class ClientProxy: ClientProxyProtocol {
|
|||||||
roomNameLike: nil,
|
roomNameLike: nil,
|
||||||
tags: [],
|
tags: [],
|
||||||
notTags: [])
|
notTags: [])
|
||||||
|
|
||||||
private lazy var slidingSyncNotificationsFilters = SlidingSyncRequestListFilters(isDm: nil,
|
|
||||||
spaces: [],
|
|
||||||
isEncrypted: nil,
|
|
||||||
isInvite: nil,
|
|
||||||
isTombstoned: false,
|
|
||||||
roomTypes: [],
|
|
||||||
notRoomTypes: ["m.space"],
|
|
||||||
roomNameLike: nil,
|
|
||||||
tags: [],
|
|
||||||
notTags: [])
|
|
||||||
|
|
||||||
private lazy var slidingSyncInviteFilters = SlidingSyncRequestListFilters(isDm: nil,
|
private lazy var slidingSyncInviteFilters = SlidingSyncRequestListFilters(isDm: nil,
|
||||||
spaces: [],
|
spaces: [],
|
||||||
@@ -633,15 +585,6 @@ class ClientProxy: ClientProxyProtocol {
|
|||||||
} else {
|
} else {
|
||||||
MXLog.error("Invites sliding sync view unavailable")
|
MXLog.error("Invites sliding sync view unavailable")
|
||||||
}
|
}
|
||||||
|
|
||||||
if ServiceLocator.shared.settings.enableLocalPushNotifications {
|
|
||||||
if let notificationsListBuilder {
|
|
||||||
MXLog.info("Registering notifications view")
|
|
||||||
slidingSyncTasks.append(slidingSync?.addList(listBuilder: notificationsListBuilder))
|
|
||||||
} else {
|
|
||||||
MXLog.error("Notifications sliding sync view unavailable")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private func roomTupleForIdentifier(_ identifier: String) -> (SlidingSyncRoom?, Room?) {
|
private func roomTupleForIdentifier(_ identifier: String) -> (SlidingSyncRoom?, Room?) {
|
||||||
@@ -667,10 +610,6 @@ class ClientProxy: ClientProxyProtocol {
|
|||||||
fileprivate func didReceiveSlidingSyncUpdate(summary: UpdateSummary) {
|
fileprivate func didReceiveSlidingSyncUpdate(summary: UpdateSummary) {
|
||||||
callbacks.send(.receivedSyncUpdate)
|
callbacks.send(.receivedSyncUpdate)
|
||||||
}
|
}
|
||||||
|
|
||||||
fileprivate func didReceiveNotification(notification: NotificationItemProxyProtocol) {
|
|
||||||
callbacks.send(.receivedNotification(notification))
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
extension ClientProxy: MediaLoaderProtocol {
|
extension ClientProxy: MediaLoaderProtocol {
|
||||||
|
|||||||
@@ -21,7 +21,6 @@ import MatrixRustSDK
|
|||||||
enum ClientProxyCallback {
|
enum ClientProxyCallback {
|
||||||
case receivedSyncUpdate
|
case receivedSyncUpdate
|
||||||
case receivedAuthError(isSoftLogout: Bool)
|
case receivedAuthError(isSoftLogout: Bool)
|
||||||
case receivedNotification(NotificationItemProxyProtocol)
|
|
||||||
case updateRestorationToken
|
case updateRestorationToken
|
||||||
|
|
||||||
var isSyncUpdate: Bool {
|
var isSyncUpdate: Bool {
|
||||||
|
|||||||
@@ -48,7 +48,7 @@ actor MediaLoader: MediaLoaderProtocol {
|
|||||||
|
|
||||||
func loadMediaFileForSource(_ source: MediaSourceProxy, body: String?) async throws -> MediaFileHandleProxy {
|
func loadMediaFileForSource(_ source: MediaSourceProxy, body: String?) async throws -> MediaFileHandleProxy {
|
||||||
let result = try await Task.dispatch(on: clientQueue) {
|
let result = try await Task.dispatch(on: clientQueue) {
|
||||||
try self.client.getMediaFile(mediaSource: source.underlyingSource, body: body, mimeType: source.mimeType ?? "application/octet-stream")
|
try self.client.getMediaFile(mediaSource: source.underlyingSource, body: body, mimeType: source.mimeType ?? "application/octet-stream", tempDir: nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
return MediaFileHandleProxy(handle: result)
|
return MediaFileHandleProxy(handle: result)
|
||||||
|
|||||||
@@ -22,7 +22,6 @@ import UserNotifications
|
|||||||
class NotificationManager: NSObject, NotificationManagerProtocol {
|
class NotificationManager: NSObject, NotificationManagerProtocol {
|
||||||
private let notificationCenter: UserNotificationCenterProtocol
|
private let notificationCenter: UserNotificationCenterProtocol
|
||||||
private var userSession: UserSessionProtocol?
|
private var userSession: UserSessionProtocol?
|
||||||
var clientCancellable: AnyCancellable?
|
|
||||||
|
|
||||||
init(notificationCenter: UserNotificationCenterProtocol = UNUserNotificationCenter.current()) {
|
init(notificationCenter: UserNotificationCenterProtocol = UNUserNotificationCenter.current()) {
|
||||||
self.notificationCenter = notificationCenter
|
self.notificationCenter = notificationCenter
|
||||||
@@ -73,17 +72,6 @@ class NotificationManager: NSObject, NotificationManagerProtocol {
|
|||||||
|
|
||||||
func setUserSession(_ userSession: UserSessionProtocol?) {
|
func setUserSession(_ userSession: UserSessionProtocol?) {
|
||||||
self.userSession = userSession
|
self.userSession = userSession
|
||||||
clientCancellable = userSession?.clientProxy.callbacks.sink { [weak self] value in
|
|
||||||
guard let self else { return }
|
|
||||||
switch value {
|
|
||||||
case let .receivedNotification(notification):
|
|
||||||
Task {
|
|
||||||
await self.showLocalNotification(notification)
|
|
||||||
}
|
|
||||||
default:
|
|
||||||
return
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func registrationFailed(with error: Error) {
|
func registrationFailed(with error: Error) {
|
||||||
@@ -106,28 +94,6 @@ class NotificationManager: NSObject, NotificationManagerProtocol {
|
|||||||
MXLog.error("[NotificationManager] show local notification failed: \(error)")
|
MXLog.error("[NotificationManager] show local notification failed: \(error)")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private func showLocalNotification(_ notification: NotificationItemProxyProtocol) async {
|
|
||||||
guard let userSession,
|
|
||||||
notification.event.timestamp > ServiceLocator.shared.settings.lastLaunchDate else { return }
|
|
||||||
do {
|
|
||||||
guard let identifier = notification.id else {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
let content = try await notification.process(mediaProvider: userSession.mediaProvider)
|
|
||||||
let request = UNNotificationRequest(identifier: identifier, content: content, trigger: nil)
|
|
||||||
|
|
||||||
guard !ServiceLocator.shared.settings.servedNotificationIdentifiers.contains(identifier) else {
|
|
||||||
MXLog.info("NotificationManager] local notification discarded because it has already been served")
|
|
||||||
return
|
|
||||||
}
|
|
||||||
ServiceLocator.shared.settings.servedNotificationIdentifiers.insert(identifier)
|
|
||||||
try await notificationCenter.add(request)
|
|
||||||
} catch {
|
|
||||||
MXLog.error("[NotificationManager] show local notification item failed: \(error)")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private func setPusher(with deviceToken: Data, clientProxy: ClientProxyProtocol) async -> Bool {
|
private func setPusher(with deviceToken: Data, clientProxy: ClientProxyProtocol) async -> Bool {
|
||||||
do {
|
do {
|
||||||
|
|||||||
+1
-1
@@ -42,7 +42,7 @@ include:
|
|||||||
packages:
|
packages:
|
||||||
MatrixRustSDK:
|
MatrixRustSDK:
|
||||||
url: https://github.com/matrix-org/matrix-rust-components-swift
|
url: https://github.com/matrix-org/matrix-rust-components-swift
|
||||||
exactVersion: 1.0.72-alpha
|
exactVersion: 1.0.73-alpha
|
||||||
# path: ../matrix-rust-sdk
|
# path: ../matrix-rust-sdk
|
||||||
DesignKit:
|
DesignKit:
|
||||||
path: DesignKit
|
path: DesignKit
|
||||||
|
|||||||
Reference in New Issue
Block a user