Skip to content

Commit 8f86a65

Browse files
authored
Room preview on a long press should not update the read receipt (#6027)
- Done
1 parent c04db50 commit 8f86a65

File tree

9 files changed

+92
-13
lines changed

9 files changed

+92
-13
lines changed

Riot/Modules/Common/Recents/RecentsViewController.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -370,7 +370,7 @@ - (void)refreshRecentsTable
370370

371371
if (!self.recentsUpdateEnabled)
372372
{
373-
isRefreshNeeded = NO;
373+
isRefreshNeeded = YES;
374374
return;
375375
}
376376

Riot/Modules/ContextMenu/ContextMenuProviders/PublicRoomContextMenuProvider.swift

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,18 @@ class PublicRoomContextMenuProvider: NSObject {
3737
}
3838
roomViewController.isContextPreview = true
3939

40-
let roomDataSourceManager = MXKRoomDataSourceManager.sharedManager(forMatrixSession: session)
41-
roomDataSourceManager?.roomDataSource(forRoom: room.roomId, create: true, onComplete: { roomDataSource in
42-
roomViewController.displayRoom(roomDataSource)
43-
})
44-
40+
RoomPreviewDataSource.load(withRoomId: room.roomId, andMatrixSession: session) { [weak roomViewController] roomDataSource in
41+
guard let dataSource = roomDataSource as? RoomPreviewDataSource else {
42+
return
43+
}
44+
45+
dataSource.markTimelineInitialEvent = false
46+
roomViewController?.displayRoom(dataSource)
47+
48+
// Give the data source ownership to the room view controller.
49+
roomViewController?.hasRoomDataSourceOwnership = true
50+
}
51+
4552
return roomViewController
4653
} else {
4754
let viewModel = RoomContextPreviewViewModel(room: room)

Riot/Modules/ContextMenu/ContextMenuProviders/RecentCellContextMenuProvider.swift

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,18 @@ class RecentCellContextMenuProvider: NSObject {
4747
}
4848
roomViewController.isContextPreview = true
4949

50-
let roomDataSourceManager = MXKRoomDataSourceManager.sharedManager(forMatrixSession: session)
51-
roomDataSourceManager?.roomDataSource(forRoom: room.roomId, create: true, onComplete: { roomDataSource in
52-
roomViewController.displayRoom(roomDataSource)
53-
})
54-
50+
RoomPreviewDataSource.load(withRoomId: room.roomId, andMatrixSession: session) { [weak roomViewController] roomDataSource in
51+
guard let dataSource = roomDataSource as? RoomPreviewDataSource else {
52+
return
53+
}
54+
55+
dataSource.markTimelineInitialEvent = false
56+
roomViewController?.displayRoom(dataSource)
57+
58+
// Give the data source ownership to the room view controller.
59+
roomViewController?.hasRoomDataSourceOwnership = true
60+
}
61+
5562
return roomViewController
5663
} else {
5764
let viewModel = RoomContextPreviewViewModel(room: room)
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
//
2+
// Copyright 2022 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+
19+
/// `RoomPreviewDataSource` is used for room context menu.
20+
@objcMembers
21+
public class RoomPreviewDataSource: RoomDataSource {
22+
23+
public override func finalizeInitialization() {
24+
super.finalizeInitialization()
25+
showReadMarker = false
26+
showBubbleReceipts = false
27+
showTypingRow = false
28+
}
29+
30+
public override var showReadMarker: Bool {
31+
get {
32+
return false
33+
} set {
34+
_ = newValue
35+
}
36+
}
37+
38+
public override var showBubbleReceipts: Bool {
39+
get {
40+
return false
41+
} set {
42+
_ = newValue
43+
}
44+
}
45+
46+
}

Riot/Modules/Room/MXKRoomViewController.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,11 @@ typedef NS_ENUM(NSUInteger, MXKRoomViewControllerJoinRoomResult) {
206206
*/
207207
@property (strong, nonatomic) UserIndicatorStore *userIndicatorStore;
208208

209+
/**
210+
YES if the instance is used as context menu preview.
211+
*/
212+
@property (nonatomic, getter=isContextPreview) BOOL contextPeview;
213+
209214
/**
210215
This object is defined when the displayed room is left. It is added into the bubbles table header.
211216
This label is used to display the reason why the room has been left.

Riot/Modules/Room/MXKRoomViewController.m

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2368,6 +2368,12 @@ - (BOOL)reloadBubblesTable:(BOOL)useBottomAnchor invalidateBubblesCellDataCache:
23682368

23692369
- (void)updateCurrentEventIdAtTableBottom:(BOOL)acknowledge
23702370
{
2371+
// Do not update events if the controller is used as context menu preview.
2372+
if (self.isContextPreview)
2373+
{
2374+
return;
2375+
}
2376+
23712377
// Update the identifier of the event displayed at the bottom of the table, except if a rotation or other size transition is in progress.
23722378
if (!isSizeTransitionInProgress && !self.isBubbleTableViewDisplayInTransition)
23732379
{

Riot/Modules/Room/RoomViewController.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,6 @@ extern NSNotificationName const RoomGroupCallTileTappedNotification;
9191
*/
9292
@property (nonatomic, nullable) NSString *parentSpaceId;
9393

94-
@property (nonatomic, getter=isContextPreview) BOOL contextPeview;
95-
9694
/// Handles all banners that should be displayed at the top of the timeline but that should not scroll with the timeline
9795
@property (weak, nonatomic, nullable) IBOutlet UIStackView *topBannersStackView;
9896

Riot/Modules/Room/RoomViewController.m

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5569,6 +5569,15 @@ - (void)goBackToLive
55695569
continueBlock(threadDataSource, YES);
55705570
}];
55715571
}
5572+
else if (self.isContextPreview)
5573+
{
5574+
[RoomPreviewDataSource loadRoomDataSourceWithRoomId:self.roomDataSource.roomId
5575+
andMatrixSession:self.mainSession
5576+
onComplete:^(RoomPreviewDataSource *roomDataSource)
5577+
{
5578+
continueBlock(roomDataSource, YES);
5579+
}];
5580+
}
55725581
else
55735582
{
55745583
// Switch back to the room live timeline managed by MXKRoomDataSourceManager

changelog.d/6008.change

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Context menu: Room preview do not update the read receipt any more

0 commit comments

Comments
 (0)