mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-03 06:55:59 +00:00
Updated setPusher function (#684)
* updated set_pusher function from the SDK * this fixes a crash and allows for the navigation to work by using the threadIdentifier of the notification * adding NCE target * project setup completed with xcodegen * no need for those ugly storyboards * code improvement * removing unused outlet * mocks generated with the comment instead of the marker protocol * updated stencil * fixed unit tests * updated swiftformat * pr comments
This commit is contained in:
@@ -212,30 +212,15 @@ class ClientProxy: ClientProxyProtocol {
|
||||
}
|
||||
}
|
||||
|
||||
// swiftlint:disable:next function_parameter_count
|
||||
func setPusher(pushkey: String,
|
||||
kind: PusherKind?,
|
||||
appId: String,
|
||||
appDisplayName: String,
|
||||
deviceDisplayName: String,
|
||||
profileTag: String?,
|
||||
lang: String,
|
||||
url: URL?,
|
||||
format: PushFormat?,
|
||||
defaultPayload: [AnyHashable: Any]?) async throws {
|
||||
// let defaultPayloadString = jsonString(from: defaultPayload)
|
||||
// try await Task.dispatch(on: .global()) {
|
||||
// try self.client.setPusher(pushkey: pushkey,
|
||||
// kind: kind?.rustValue,
|
||||
// appId: appId,
|
||||
// appDisplayName: appDisplayName,
|
||||
// deviceDisplayName: deviceDisplayName,
|
||||
// profileTag: profileTag,
|
||||
// lang: lang,
|
||||
// url: url,
|
||||
// format: format?.rustValue,
|
||||
// defaultPayload: defaultPayloadString)
|
||||
// }
|
||||
func setPusher(with configuration: PusherConfiguration) async throws {
|
||||
try await Task.dispatch(on: .global()) {
|
||||
try self.client.setPusher(identifiers: configuration.identifiers,
|
||||
kind: configuration.kind,
|
||||
appDisplayName: configuration.appDisplayName,
|
||||
deviceDisplayName: configuration.deviceDisplayName,
|
||||
profileTag: configuration.profileTag,
|
||||
lang: configuration.lang)
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: Private
|
||||
@@ -399,17 +384,6 @@ class ClientProxy: ClientProxyProtocol {
|
||||
fileprivate func didReceiveSlidingSyncUpdate(summary: UpdateSummary) {
|
||||
callbacks.send(.receivedSyncUpdate)
|
||||
}
|
||||
|
||||
/// Convenience method to get the json string of an Encodable
|
||||
private func jsonString(from dictionary: [AnyHashable: Any]?) -> String? {
|
||||
guard let dictionary,
|
||||
let data = try? JSONSerialization.data(withJSONObject: dictionary,
|
||||
options: [.fragmentsAllowed]) else {
|
||||
return nil
|
||||
}
|
||||
|
||||
return String(data: data, encoding: .utf8)
|
||||
}
|
||||
}
|
||||
|
||||
extension ClientProxy: MediaLoaderProtocol {
|
||||
|
||||
@@ -31,37 +31,24 @@ enum ClientProxyError: Error {
|
||||
case failedLoadingMedia
|
||||
}
|
||||
|
||||
enum PusherKind {
|
||||
case http
|
||||
case email
|
||||
|
||||
// var rustValue: MatrixRustSDK.PusherKind {
|
||||
// switch self {
|
||||
// case .http:
|
||||
// return .http
|
||||
// case .email:
|
||||
// return .email
|
||||
// }
|
||||
// }
|
||||
}
|
||||
|
||||
enum PushFormat {
|
||||
case eventIdOnly
|
||||
|
||||
// var rustValue: MatrixRustSDK.PushFormat {
|
||||
// switch self {
|
||||
// case .eventIdOnly:
|
||||
// return .eventIdOnly
|
||||
// }
|
||||
// }
|
||||
}
|
||||
|
||||
enum SlidingSyncConstants {
|
||||
static let initialTimelineLimit: UInt = 0
|
||||
static let lastMessageTimelineLimit: UInt = 1
|
||||
static let timelinePrecachingTimelineLimit: UInt = 20
|
||||
}
|
||||
|
||||
/// This struct represents the configuration that we are using to register the application through Pusher to Sygnal
|
||||
/// using the Matrix Rust SDK, more info here:
|
||||
/// https://github.com/matrix-org/sygnal
|
||||
struct PusherConfiguration {
|
||||
let identifiers: PusherIdentifiers
|
||||
let kind: PusherKind
|
||||
let appDisplayName: String
|
||||
let deviceDisplayName: String
|
||||
let profileTag: String?
|
||||
let lang: String
|
||||
}
|
||||
|
||||
protocol ClientProxyProtocol: AnyObject, MediaLoaderProtocol {
|
||||
var callbacks: PassthroughSubject<ClientProxyCallback, Never> { get }
|
||||
|
||||
@@ -97,15 +84,5 @@ protocol ClientProxyProtocol: AnyObject, MediaLoaderProtocol {
|
||||
|
||||
func logout() async
|
||||
|
||||
// swiftlint:disable:next function_parameter_count
|
||||
func setPusher(pushkey: String,
|
||||
kind: PusherKind?,
|
||||
appId: String,
|
||||
appDisplayName: String,
|
||||
deviceDisplayName: String,
|
||||
profileTag: String?,
|
||||
lang: String,
|
||||
url: URL?,
|
||||
format: PushFormat?,
|
||||
defaultPayload: [AnyHashable: Any]?) async throws
|
||||
func setPusher(with configuration: PusherConfiguration) async throws
|
||||
}
|
||||
|
||||
@@ -89,40 +89,13 @@ class MockClientProxy: ClientProxyProtocol {
|
||||
// no-op
|
||||
}
|
||||
|
||||
var setPusherCalled = false
|
||||
var setPusherErrorToThrow: Error?
|
||||
var setPusherPushkey: String?
|
||||
var setPusherKind: PusherKind?
|
||||
var setPusherAppId: String?
|
||||
var setPusherAppDisplayName: String?
|
||||
var setPusherDeviceDisplayName: String?
|
||||
var setPusherProfileTag: String?
|
||||
var setPusherLang: String?
|
||||
var setPusherUrl: URL?
|
||||
var setPusherFormat: PushFormat?
|
||||
var setPusherDefaultPayload: [AnyHashable: Any]?
|
||||
// swiftlint:disable:next function_parameter_count
|
||||
func setPusher(pushkey: String,
|
||||
kind: PusherKind?,
|
||||
appId: String,
|
||||
appDisplayName: String,
|
||||
deviceDisplayName: String,
|
||||
profileTag: String?,
|
||||
lang: String,
|
||||
url: URL?,
|
||||
format: PushFormat?,
|
||||
defaultPayload: [AnyHashable: Any]?) async throws {
|
||||
var setPusherArgument: PusherConfiguration?
|
||||
var setPusherCalled = false
|
||||
|
||||
func setPusher(with configuration: PusherConfiguration) async throws {
|
||||
if let setPusherErrorToThrow { throw setPusherErrorToThrow }
|
||||
setPusherCalled = true
|
||||
setPusherPushkey = pushkey
|
||||
setPusherKind = kind
|
||||
setPusherAppId = appId
|
||||
setPusherAppDisplayName = appDisplayName
|
||||
setPusherDeviceDisplayName = deviceDisplayName
|
||||
setPusherProfileTag = profileTag
|
||||
setPusherLang = lang
|
||||
setPusherUrl = url
|
||||
setPusherFormat = format
|
||||
setPusherDefaultPayload = defaultPayload
|
||||
setPusherArgument = configuration
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user