mirror of
https://github.com/vector-im/element-ios.git
synced 2024-09-29 07:42:40 +00:00
Merge remote-tracking branch 'origin/develop'
This commit is contained in:
commit
2a0655df1f
3 changed files with 40 additions and 18 deletions
|
@ -15,11 +15,11 @@
|
|||
<key>CFBundlePackageType</key>
|
||||
<string>APPL</string>
|
||||
<key>CFBundleShortVersionString</key>
|
||||
<string>1.0</string>
|
||||
<string>0.1.0</string>
|
||||
<key>CFBundleSignature</key>
|
||||
<string>????</string>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>1</string>
|
||||
<string>0</string>
|
||||
<key>LSRequiresIPhoneOS</key>
|
||||
<true/>
|
||||
<key>UILaunchStoryboardName</key>
|
||||
|
|
|
@ -38,7 +38,7 @@ NSString *const kFailedEventId = @"failedEventId";
|
|||
|
||||
// Set date time text label
|
||||
if (event.originServerTs != kMXUndefinedTimestamp) {
|
||||
_date = [NSDate dateWithTimeIntervalSince1970:event.originServerTs/1000];
|
||||
_date = [NSDate dateWithTimeIntervalSince1970:(double)event.originServerTs/1000];
|
||||
} else {
|
||||
_date = nil;
|
||||
}
|
||||
|
|
|
@ -134,6 +134,7 @@ NSString *const kCmdResetUserPowerLevel = @"/deop";
|
|||
messagesListener = nil;
|
||||
[[AppSettings sharedSettings] removeObserver:self forKeyPath:@"hideUnsupportedMessages"];
|
||||
[[AppSettings sharedSettings] removeObserver:self forKeyPath:@"displayAllEvents"];
|
||||
[[MatrixHandler sharedHandler] removeObserver:self forKeyPath:@"isResumeDone"];
|
||||
}
|
||||
mxRoom = nil;
|
||||
|
||||
|
@ -162,7 +163,7 @@ NSString *const kCmdResetUserPowerLevel = @"/deop";
|
|||
|
||||
if (isBackPaginationInProgress || isJoinRequestInProgress) {
|
||||
// Busy - be sure that activity indicator is running
|
||||
[_activityIndicator startAnimating];
|
||||
[self startActivityIndicator];
|
||||
}
|
||||
|
||||
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(onKeyboardWillShow:) name:UIKeyboardWillShowNotification object:nil];
|
||||
|
@ -240,7 +241,7 @@ NSString *const kCmdResetUserPowerLevel = @"/deop";
|
|||
// Check whether a request is in progress to join the room
|
||||
if (isJoinRequestInProgress) {
|
||||
// Busy - be sure that activity indicator is running
|
||||
[_activityIndicator startAnimating];
|
||||
[self startActivityIndicator];
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -250,6 +251,7 @@ NSString *const kCmdResetUserPowerLevel = @"/deop";
|
|||
messagesListener = nil;
|
||||
[[AppSettings sharedSettings] removeObserver:self forKeyPath:@"hideUnsupportedMessages"];
|
||||
[[AppSettings sharedSettings] removeObserver:self forKeyPath:@"displayAllEvents"];
|
||||
[[MatrixHandler sharedHandler] removeObserver:self forKeyPath:@"isResumeDone"];
|
||||
}
|
||||
// The whole room history is flushed here to rebuild it from the current instant (live)
|
||||
messages = nil;
|
||||
|
@ -269,15 +271,15 @@ NSString *const kCmdResetUserPowerLevel = @"/deop";
|
|||
// Check first whether we have to join the room
|
||||
if (mxRoom.state.membership == MXMembershipInvite) {
|
||||
isJoinRequestInProgress = YES;
|
||||
[_activityIndicator startAnimating];
|
||||
[self startActivityIndicator];
|
||||
[mxRoom join:^{
|
||||
[_activityIndicator stopAnimating];
|
||||
[self stopActivityIndicator];
|
||||
isJoinRequestInProgress = NO;
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
[self configureView];
|
||||
});
|
||||
} failure:^(NSError *error) {
|
||||
[_activityIndicator stopAnimating];
|
||||
[self stopActivityIndicator];
|
||||
isJoinRequestInProgress = NO;
|
||||
NSLog(@"Failed to join room (%@): %@", mxRoom.state.displayname, error);
|
||||
//Alert user
|
||||
|
@ -292,6 +294,7 @@ NSString *const kCmdResetUserPowerLevel = @"/deop";
|
|||
messages = [NSMutableArray array];
|
||||
[[AppSettings sharedSettings] addObserver:self forKeyPath:@"hideUnsupportedMessages" options:0 context:nil];
|
||||
[[AppSettings sharedSettings] addObserver:self forKeyPath:@"displayAllEvents" options:0 context:nil];
|
||||
[[MatrixHandler sharedHandler] addObserver:self forKeyPath:@"isResumeDone" options:0 context:nil];
|
||||
// Register a listener to handle messages
|
||||
messagesListener = [mxRoom listenToEventsOfTypes:mxHandler.eventsFilterForMessages onEvent:^(MXEvent *event, MXEventDirection direction, MXRoomState *roomState) {
|
||||
BOOL shouldScrollToBottom = NO;
|
||||
|
@ -306,6 +309,8 @@ NSString *const kCmdResetUserPowerLevel = @"/deop";
|
|||
|
||||
// We will scroll to bottom after updating tableView only if the most recent message is entirely visible.
|
||||
CGFloat maxPositionY = self.messagesTableView.contentOffset.y + (self.messagesTableView.frame.size.height - self.messagesTableView.contentInset.bottom);
|
||||
// Be a bit less retrictive, scroll even if the most recent message is partially hidden
|
||||
maxPositionY += 30;
|
||||
shouldScrollToBottom = (maxPositionY >= self.messagesTableView.contentSize.height);
|
||||
|
||||
// Update Table
|
||||
|
@ -395,7 +400,11 @@ NSString *const kCmdResetUserPowerLevel = @"/deop";
|
|||
}
|
||||
|
||||
if (shouldScrollToBottom) {
|
||||
[self scrollToBottomAnimated:YES];
|
||||
// Delay the scrolling.
|
||||
// If there is a bunch of incoming events, scroll once for all of them
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
[self scrollToBottomAnimated:YES];
|
||||
});
|
||||
}
|
||||
}];
|
||||
|
||||
|
@ -426,7 +435,7 @@ NSString *const kCmdResetUserPowerLevel = @"/deop";
|
|||
}
|
||||
|
||||
if (mxRoom.canPaginate) {
|
||||
[_activityIndicator startAnimating];
|
||||
[self startActivityIndicator];
|
||||
isBackPaginationInProgress = YES;
|
||||
backPaginationAddedMsgNb = 0;
|
||||
|
||||
|
@ -492,8 +501,19 @@ NSString *const kCmdResetUserPowerLevel = @"/deop";
|
|||
[self.messagesTableView setContentOffset:contentOffset animated:NO];
|
||||
}
|
||||
}
|
||||
[_activityIndicator stopAnimating];
|
||||
isBackPaginationInProgress = NO;
|
||||
[self stopActivityIndicator];
|
||||
}
|
||||
|
||||
- (void)startActivityIndicator {
|
||||
[_activityIndicator startAnimating];
|
||||
}
|
||||
|
||||
- (void)stopActivityIndicator {
|
||||
// Check whether all conditions are satisfied before stopping loading wheel
|
||||
if ([[MatrixHandler sharedHandler] isResumeDone] && !isBackPaginationInProgress && !isJoinRequestInProgress) {
|
||||
[_activityIndicator stopAnimating];
|
||||
}
|
||||
}
|
||||
|
||||
#pragma mark - KVO
|
||||
|
@ -506,6 +526,12 @@ NSString *const kCmdResetUserPowerLevel = @"/deop";
|
|||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
[self configureView];
|
||||
});
|
||||
} else if ([@"isResumeDone" isEqualToString:keyPath]) {
|
||||
if ([[MatrixHandler sharedHandler] isResumeDone]) {
|
||||
[self stopActivityIndicator];
|
||||
} else {
|
||||
[self startActivityIndicator];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1311,16 +1337,12 @@ NSString *const kCmdResetUserPowerLevel = @"/deop";
|
|||
|
||||
NSString *roomName = self.roomNameTextField.text;
|
||||
if ([roomName isEqualToString:mxRoom.state.name] == NO) {
|
||||
[self.activityIndicator startAnimating];
|
||||
[self startActivityIndicator];
|
||||
MatrixHandler *mxHandler = [MatrixHandler sharedHandler];
|
||||
[mxHandler.mxRestClient setRoomName:self.roomId name:roomName success:^{
|
||||
if (isBackPaginationInProgress == NO) {
|
||||
[self.activityIndicator stopAnimating];
|
||||
}
|
||||
[self stopActivityIndicator];
|
||||
} failure:^(NSError *error) {
|
||||
if (isBackPaginationInProgress == NO) {
|
||||
[self.activityIndicator stopAnimating];
|
||||
}
|
||||
[self stopActivityIndicator];
|
||||
// Revert change
|
||||
self.roomNameTextField.text = mxRoom.state.displayname;
|
||||
NSLog(@"Rename room failed: %@", error);
|
||||
|
|
Loading…
Reference in a new issue