mirror of
https://github.com/vector-im/element-ios.git
synced 2024-09-29 15:52:40 +00:00
commit
06dc000010
6 changed files with 63 additions and 37 deletions
|
@ -1,5 +1,6 @@
|
|||
/*
|
||||
Copyright 2015 OpenMarket Ltd
|
||||
Copyright 2017 Vector Creations Ltd
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
|
@ -26,4 +27,9 @@
|
|||
*/
|
||||
@property(nonatomic) NSString *selectedEventId;
|
||||
|
||||
/**
|
||||
Tell whether the initial event of the timeline (if any) must be marked. Default is NO.
|
||||
*/
|
||||
@property(nonatomic) BOOL markTimelineInitialEvent;
|
||||
|
||||
@end
|
||||
|
|
|
@ -51,6 +51,8 @@
|
|||
|
||||
// Set bubble pagination
|
||||
self.bubblesPagination = MXKRoomDataSourceBubblesPaginationPerDay;
|
||||
|
||||
self.markTimelineInitialEvent = NO;
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
@ -293,7 +295,7 @@
|
|||
}
|
||||
|
||||
// Manage initial event (case of permalink or search result)
|
||||
if (self.timeline.initialEventId)
|
||||
if (self.timeline.initialEventId && self.markTimelineInitialEvent)
|
||||
{
|
||||
// Check if the cell contains this initial event
|
||||
for (NSUInteger index = 0; index < bubbleComponents.count; index++)
|
||||
|
|
|
@ -86,6 +86,7 @@
|
|||
// Create the room data source
|
||||
_roomDataSource = [[RoomDataSource alloc] initWithPeekingRoom:peekingRoom andInitialEventId:_eventId];
|
||||
[_roomDataSource finalizeInitialization];
|
||||
_roomDataSource.markTimelineInitialEvent = YES;
|
||||
|
||||
_roomName = peekingRoom.riotDisplayname;
|
||||
_roomAvatarUrl = peekingRoom.state.avatar;
|
||||
|
|
|
@ -463,6 +463,8 @@
|
|||
roomDataSource = [[RoomDataSource alloc] initWithRoomId:_selectedRoomId initialEventId:_selectedEventId andMatrixSession:_selectedRoomSession];
|
||||
[roomDataSource finalizeInitialization];
|
||||
|
||||
((RoomDataSource*)roomDataSource).markTimelineInitialEvent = YES;
|
||||
|
||||
// Give the data source ownership to the room view controller.
|
||||
_currentRoomViewController.hasRoomDataSourceOwnership = YES;
|
||||
}
|
||||
|
@ -473,6 +475,8 @@
|
|||
roomDataSource = [[RoomDataSource alloc] initWithRoomId:selectedSearchEvent.roomId initialEventId:selectedSearchEvent.eventId andMatrixSession:selectedSearchEventSession];
|
||||
[roomDataSource finalizeInitialization];
|
||||
|
||||
((RoomDataSource*)roomDataSource).markTimelineInitialEvent = YES;
|
||||
|
||||
// Give the data source ownership to the room view controller.
|
||||
_currentRoomViewController.hasRoomDataSourceOwnership = YES;
|
||||
}
|
||||
|
|
|
@ -285,6 +285,7 @@
|
|||
RoomViewController *roomViewController = segue.destinationViewController;
|
||||
RoomDataSource *roomDataSource = [[RoomDataSource alloc] initWithRoomId:selectedSearchEvent.roomId initialEventId:selectedSearchEvent.eventId andMatrixSession:selectedSearchEventSession];
|
||||
[roomDataSource finalizeInitialization];
|
||||
roomDataSource.markTimelineInitialEvent = YES;
|
||||
|
||||
[roomViewController displayRoom:roomDataSource];
|
||||
roomViewController.hasRoomDataSourceOwnership = YES;
|
||||
|
|
|
@ -272,16 +272,6 @@
|
|||
// Prepare jump to last unread banner
|
||||
self.jumpToLastUnreadLabel.attributedText = [[NSAttributedString alloc] initWithString:NSLocalizedStringFromTable(@"room_jump_to_first_unread", @"Vector", nil) attributes:@{NSUnderlineStyleAttributeName: @(NSUnderlineStyleSingle), NSUnderlineColorAttributeName: kRiotTextColorBlack, NSForegroundColorAttributeName: kRiotTextColorBlack}];
|
||||
|
||||
[NSLayoutConstraint deactivateConstraints:@[_jumpToLastUnreadBannerContainerTopConstraint]];
|
||||
_jumpToLastUnreadBannerContainerTopConstraint = [NSLayoutConstraint constraintWithItem:self.topLayoutGuide
|
||||
attribute:NSLayoutAttributeBottom
|
||||
relatedBy:NSLayoutRelationEqual
|
||||
toItem:self.jumpToLastUnreadBannerContainer
|
||||
attribute:NSLayoutAttributeTop
|
||||
multiplier:1.0f
|
||||
constant:0.0f];
|
||||
[NSLayoutConstraint activateConstraints:@[_jumpToLastUnreadBannerContainerTopConstraint]];
|
||||
|
||||
// Prepare expanded header
|
||||
self.expandedHeaderContainer.backgroundColor = kRiotColorLightGrey;
|
||||
|
||||
|
@ -432,9 +422,6 @@
|
|||
[self.bubblesTableView setContentOffset:CGPointMake(-self.bubblesTableView.contentInset.left, -self.bubblesTableView.contentInset.top) animated:YES];
|
||||
|
||||
}];
|
||||
|
||||
isAppeared = YES;
|
||||
[self checkReadMarkerVisibility];
|
||||
}
|
||||
|
||||
- (void)viewWillDisappear:(BOOL)animated
|
||||
|
@ -481,6 +468,9 @@
|
|||
{
|
||||
[super viewDidAppear:animated];
|
||||
|
||||
isAppeared = YES;
|
||||
[self checkReadMarkerVisibility];
|
||||
|
||||
if (self.roomDataSource)
|
||||
{
|
||||
// Set visible room id
|
||||
|
@ -650,7 +640,7 @@
|
|||
}
|
||||
else
|
||||
{
|
||||
self.jumpToLastUnreadBannerContainerTopConstraint.constant = 0;
|
||||
self.jumpToLastUnreadBannerContainerTopConstraint.constant = self.bubblesTableView.contentInset.top;
|
||||
}
|
||||
|
||||
[self refreshMissedDiscussionsCount:YES];
|
||||
|
@ -743,16 +733,16 @@
|
|||
[self removeMatrixSession:self.mainSession];
|
||||
}
|
||||
|
||||
// Enable the read marker display, and disable its update.
|
||||
dataSource.showReadMarker = YES;
|
||||
self.updateRoomReadMarker = NO;
|
||||
|
||||
[super displayRoom:dataSource];
|
||||
|
||||
customizedRoomDataSource = nil;
|
||||
|
||||
if (self.roomDataSource)
|
||||
{
|
||||
// Enable the read marker display, and disable its update.
|
||||
self.roomDataSource.showReadMarker = YES;
|
||||
self.updateRoomReadMarker = NO;
|
||||
|
||||
// Set room title view
|
||||
[self refreshRoomTitle];
|
||||
|
||||
|
@ -1237,8 +1227,7 @@
|
|||
animations:^{
|
||||
|
||||
self.bubblesTableViewTopConstraint.constant = (isVisible ? self.expandedHeaderContainerHeightConstraint.constant - self.bubblesTableView.contentInset.top : 0);
|
||||
// TODO: shall we update self.jumpToLastUnreadBannerContainerTopConstraint
|
||||
// self.jumpToLastUnreadBannerContainerTopConstraint.constant = (isVisible ? self.expandedHeaderContainerHeightConstraint.constant : 0);
|
||||
self.jumpToLastUnreadBannerContainerTopConstraint.constant = (isVisible ? self.expandedHeaderContainerHeightConstraint.constant : self.bubblesTableView.contentInset.top);
|
||||
|
||||
if (roomAvatarView)
|
||||
{
|
||||
|
@ -1353,8 +1342,7 @@
|
|||
animations:^{
|
||||
|
||||
self.bubblesTableViewTopConstraint.constant = 0;
|
||||
// TODO: shall we update self.jumpToLastUnreadBannerContainerTopConstraint
|
||||
// self.jumpToLastUnreadBannerContainerTopConstraint.constant = 0;
|
||||
self.jumpToLastUnreadBannerContainerTopConstraint.constant = self.bubblesTableView.contentInset.top;
|
||||
|
||||
// Force to render the view
|
||||
[self forceLayoutRefresh];
|
||||
|
@ -2484,13 +2472,15 @@
|
|||
}
|
||||
else if (sender == self.jumpToLastUnreadButton)
|
||||
{
|
||||
// TODO: Support jump to last unread message
|
||||
currentAlert = [[MXKAlert alloc] initWithTitle:@"Not supported yet" message:nil style:MXKAlertStyleAlert];
|
||||
currentAlert.cancelButtonIndex = [currentAlert addActionWithTitle:[NSBundle mxk_localizedStringForKey:@"ok"] style:MXKAlertActionStyleDefault handler:^(MXKAlert *alert) {
|
||||
MXKRoomDataSource *roomDataSource;
|
||||
// Jump to the last unread event by using a temporary room data source initialized with the last unread event id.
|
||||
roomDataSource = [[RoomDataSource alloc] initWithRoomId:self.roomDataSource.roomId initialEventId:self.roomDataSource.room.accountData.readMarkerEventId andMatrixSession:self.mainSession];
|
||||
[roomDataSource finalizeInitialization];
|
||||
|
||||
currentAlert = nil;
|
||||
}];
|
||||
[currentAlert showInViewController:self];
|
||||
[self displayRoom:roomDataSource];
|
||||
|
||||
// Give the data source ownership to the room view controller.
|
||||
self.hasRoomDataSourceOwnership = YES;
|
||||
}
|
||||
else if (sender == self.resetReadMarkerButton)
|
||||
{
|
||||
|
@ -2726,10 +2716,11 @@
|
|||
{
|
||||
RoomDataSource *roomDataSource = [[RoomDataSource alloc] initWithRoomId:self.roomDataSource.roomId initialEventId:eventId andMatrixSession:self.mainSession];
|
||||
[roomDataSource finalizeInitialization];
|
||||
|
||||
self.hasRoomDataSourceOwnership = YES;
|
||||
roomDataSource.markTimelineInitialEvent = YES;
|
||||
|
||||
[self displayRoom:roomDataSource];
|
||||
|
||||
self.hasRoomDataSourceOwnership = YES;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -3001,8 +2992,9 @@
|
|||
}
|
||||
else if ([self checkUnsentMessages] == NO)
|
||||
{
|
||||
// Show "scroll to bottom" icon when the most recent message is not visible
|
||||
if ([self isBubblesTableScrollViewAtTheBottom] == NO)
|
||||
// Show "scroll to bottom" icon when the most recent message is not visible,
|
||||
// or when the timelime is not live (this icon is used to go back to live).
|
||||
if (!self.roomDataSource.isLive || [self isBubblesTableScrollViewAtTheBottom] == NO)
|
||||
{
|
||||
// Retrieve the unread messages count
|
||||
NSUInteger unreadCount = self.roomDataSource.room.summary.localUnreadEventCount;
|
||||
|
@ -3016,7 +3008,27 @@
|
|||
|
||||
[roomActivitiesView displayScrollToBottomIcon:unreadCount onIconTapGesture:^{
|
||||
|
||||
if (self.roomDataSource.isLive)
|
||||
{
|
||||
[self scrollBubblesTableViewToBottomAnimated:YES];
|
||||
}
|
||||
else
|
||||
{
|
||||
// Switch back to the room live timeline managed by MXKRoomDataSourceManager
|
||||
MXKRoomDataSourceManager *roomDataSourceManager = [MXKRoomDataSourceManager sharedManagerForMatrixSession:self.mainSession];
|
||||
MXKRoomDataSource *roomDataSource = [roomDataSourceManager roomDataSourceForRoom:self.roomDataSource.roomId create:YES];
|
||||
|
||||
// Scroll to bottom the bubble history on the display refresh.
|
||||
shouldScrollToBottomOnTableRefresh = YES;
|
||||
|
||||
[self displayRoom:roomDataSource];
|
||||
|
||||
// The room view controller do not have here the data source ownership.
|
||||
self.hasRoomDataSourceOwnership = NO;
|
||||
|
||||
[self refreshActivitiesViewDisplay];
|
||||
[self refreshJumpToLastUnreadBannerDisplay];
|
||||
}
|
||||
|
||||
}];
|
||||
}
|
||||
|
@ -3492,8 +3504,8 @@
|
|||
|
||||
- (void)refreshJumpToLastUnreadBannerDisplay
|
||||
{
|
||||
// Check whether the read marker has not been rendered yet.
|
||||
if (self.roomDataSource.showReadMarker)
|
||||
// Check whether the read marker exists and has not been rendered yet.
|
||||
if (self.roomDataSource.showReadMarker && self.roomDataSource.room.accountData.readMarkerEventId)
|
||||
{
|
||||
UITableViewCell *cell = [self.bubblesTableView visibleCells].firstObject;
|
||||
if ([cell isKindOfClass:MXKRoomBubbleTableViewCell.class])
|
||||
|
|
Loading…
Reference in a new issue