|
| 1 | +// |
| 2 | +// Copyright 2021 New Vector Ltd |
| 3 | +// |
| 4 | +// Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | +// you may not use this file except in compliance with the License. |
| 6 | +// You may obtain a copy of the License at |
| 7 | +// |
| 8 | +// http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | +// |
| 10 | +// Unless required by applicable law or agreed to in writing, software |
| 11 | +// distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | +// See the License for the specific language governing permissions and |
| 14 | +// limitations under the License. |
| 15 | +// |
| 16 | + |
| 17 | +import Foundation |
| 18 | +import MatrixSDK |
| 19 | + |
| 20 | +@objcMembers |
| 21 | +class UserActivityService: NSObject { |
| 22 | + |
| 23 | + // MARK: - Constants |
| 24 | + |
| 25 | + // TODO: Move constants in here from UserActivities.m |
| 26 | + |
| 27 | + // MARK: - Properties |
| 28 | + |
| 29 | + #warning("This is initialised lazily so currently only observes left rooms if RoomViewController has been presented.") |
| 30 | + static let shared = UserActivityService() |
| 31 | + |
| 32 | + // MARK: - Setup |
| 33 | + |
| 34 | + private override init() { |
| 35 | + super.init() |
| 36 | + |
| 37 | + NotificationCenter.default.addObserver(self, selector: #selector(didLeaveRoom(_:)), name: .mxSessionDidLeaveRoom, object: nil) |
| 38 | + } |
| 39 | + |
| 40 | + // MARK: - Public |
| 41 | + |
| 42 | + func update(_ activity: NSUserActivity, from room: MXRoom) { |
| 43 | + // TODO: Convert objc code into here. |
| 44 | + } |
| 45 | + |
| 46 | + func didLeaveRoom(_ notification: Notification) { |
| 47 | + guard let roomId = notification.userInfo?[kMXSessionNotificationRoomIdKey] as? String else { return } |
| 48 | + // TODO: Remove the room from spotlight |
| 49 | + } |
| 50 | +} |
0 commit comments