mirror of
https://gitlab.opencode.de/bwi/bundesmessenger/clients/bundesmessenger-ios.git
synced 2026-04-22 09:32:52 +02:00
Configured and applied SwiftFormat
This commit is contained in:
committed by
Stefan Ceriu
parent
ff2e6ddfa7
commit
43c28d23b7
+17
-19
@@ -1,4 +1,4 @@
|
||||
//
|
||||
//
|
||||
// Copyright 2021 New Vector Ltd
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
@@ -14,12 +14,11 @@
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
import CoreLocation
|
||||
import Foundation
|
||||
import MatrixSDK
|
||||
|
||||
class LiveLocationSharingViewerService: LiveLocationSharingViewerServiceProtocol {
|
||||
|
||||
// MARK: - Properties
|
||||
|
||||
private(set) var usersLiveLocation: [UserLiveLocation] = []
|
||||
@@ -40,17 +39,17 @@ class LiveLocationSharingViewerService: LiveLocationSharingViewerServiceProtocol
|
||||
self.session = session
|
||||
self.roomId = roomId
|
||||
|
||||
self.updateUsersLiveLocation(notifyUpdate: false)
|
||||
updateUsersLiveLocation(notifyUpdate: false)
|
||||
}
|
||||
|
||||
// MARK: - Public
|
||||
|
||||
func isCurrentUserId(_ userId: String) -> Bool {
|
||||
return self.session.myUserId == userId
|
||||
session.myUserId == userId
|
||||
}
|
||||
|
||||
func startListeningLiveLocationUpdates() {
|
||||
self.beaconInfoSummaryListener = self.session.aggregations.beaconAggregations.listenToBeaconInfoSummaryUpdateInRoom(withId: self.roomId) { [weak self] _ in
|
||||
beaconInfoSummaryListener = session.aggregations.beaconAggregations.listenToBeaconInfoSummaryUpdateInRoom(withId: roomId) { [weak self] _ in
|
||||
|
||||
self?.updateUsersLiveLocation(notifyUpdate: true)
|
||||
}
|
||||
@@ -58,17 +57,17 @@ class LiveLocationSharingViewerService: LiveLocationSharingViewerServiceProtocol
|
||||
|
||||
func stopListeningLiveLocationUpdates() {
|
||||
if let listener = beaconInfoSummaryListener {
|
||||
self.session.aggregations.removeListener(listener)
|
||||
self.beaconInfoSummaryListener = nil
|
||||
session.aggregations.removeListener(listener)
|
||||
beaconInfoSummaryListener = nil
|
||||
}
|
||||
}
|
||||
|
||||
func stopUserLiveLocationSharing(completion: @escaping (Result<Void, Error>) -> Void) {
|
||||
self.session.locationService.stopUserLocationSharing(inRoomWithId: roomId) { response in
|
||||
session.locationService.stopUserLocationSharing(inRoomWithId: roomId) { response in
|
||||
|
||||
switch response {
|
||||
case .success:
|
||||
completion(.success(Void()))
|
||||
completion(.success(()))
|
||||
case .failure(let error):
|
||||
completion(.failure(error))
|
||||
}
|
||||
@@ -78,17 +77,16 @@ class LiveLocationSharingViewerService: LiveLocationSharingViewerServiceProtocol
|
||||
// MARK: - Private
|
||||
|
||||
private func updateUsersLiveLocation(notifyUpdate: Bool) {
|
||||
let beaconInfoSummaries = self.session.locationService.getDisplayableBeaconInfoSummaries(inRoomWithId: roomId)
|
||||
self.usersLiveLocation = Self.usersLiveLocation(fromBeaconInfoSummaries: beaconInfoSummaries, session: session)
|
||||
let beaconInfoSummaries = session.locationService.getDisplayableBeaconInfoSummaries(inRoomWithId: roomId)
|
||||
usersLiveLocation = Self.usersLiveLocation(fromBeaconInfoSummaries: beaconInfoSummaries, session: session)
|
||||
|
||||
if notifyUpdate {
|
||||
self.didUpdateUsersLiveLocation?(self.usersLiveLocation)
|
||||
didUpdateUsersLiveLocation?(usersLiveLocation)
|
||||
}
|
||||
}
|
||||
|
||||
class private func usersLiveLocation(fromBeaconInfoSummaries beaconInfoSummaries: [MXBeaconInfoSummaryProtocol], session: MXSession) -> [UserLiveLocation] {
|
||||
|
||||
return beaconInfoSummaries.compactMap { beaconInfoSummary in
|
||||
private class func usersLiveLocation(fromBeaconInfoSummaries beaconInfoSummaries: [MXBeaconInfoSummaryProtocol], session: MXSession) -> [UserLiveLocation] {
|
||||
beaconInfoSummaries.compactMap { beaconInfoSummary in
|
||||
|
||||
let beaconInfo = beaconInfoSummary.beaconInfo
|
||||
|
||||
@@ -98,9 +96,9 @@ class LiveLocationSharingViewerService: LiveLocationSharingViewerServiceProtocol
|
||||
|
||||
let avatarData = session.avatarInput(for: beaconInfoSummary.userId)
|
||||
|
||||
let timestamp = TimeInterval(beaconInfo.timestamp/1000)
|
||||
let timeout = TimeInterval(beaconInfo.timeout/1000)
|
||||
let lastUpdate = TimeInterval(lastBeacon.timestamp/1000)
|
||||
let timestamp = TimeInterval(beaconInfo.timestamp / 1000)
|
||||
let timeout = TimeInterval(beaconInfo.timeout / 1000)
|
||||
let lastUpdate = TimeInterval(lastBeacon.timestamp / 1000)
|
||||
|
||||
let coordinate = CLLocationCoordinate2D(latitude: lastBeacon.location.latitude, longitude: lastBeacon.location.longitude)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user