Skip to content

Commit c5db1b8

Browse files
pixlwavekloenk
authored andcommitted
Add skeleton UserActivityService.
1 parent 3086234 commit c5db1b8

File tree

2 files changed

+53
-0
lines changed

2 files changed

+53
-0
lines changed
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
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+
}

Riot/Modules/Room/RoomViewController.m

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2007,6 +2007,9 @@ - (void)becomeCurrentActivity
20072007
self.userActivity = [[NSUserActivity alloc] initWithActivityType:kUserActivityTypeMatrixRoom];
20082008
}
20092009

2010+
// TODO: Move everything else into the method called below
2011+
[UserActivityService.shared update:self.userActivity from:self.roomDataSource.room];
2012+
20102013
self.userActivity.title = self.roomDataSource.room.summary.displayname;
20112014
self.userActivity.requiredUserInfoKeys = [[NSSet alloc] initWithObjects:kUserActivityInfoRoomId, nil];
20122015

0 commit comments

Comments
 (0)