mirror of
https://gitlab.opencode.de/bwi/bundesmessenger/clients/bundesmessenger-ios.git
synced 2026-05-03 22:56:57 +02:00
BugFix SYIOS-26 - The app can work offline when debackgrounded but not when restarting from cold
This commit is contained in:
@@ -38,6 +38,7 @@
|
||||
NSDateFormatter *dateFormatter;
|
||||
|
||||
RoomViewController *currentRoomViewController;
|
||||
BOOL isVisible;
|
||||
}
|
||||
@property (strong, nonatomic) IBOutlet UIActivityIndicatorView *activityIndicator;
|
||||
|
||||
@@ -141,6 +142,8 @@
|
||||
- (void)viewDidAppear:(BOOL)animated {
|
||||
[super viewDidAppear:animated];
|
||||
|
||||
isVisible = YES;
|
||||
|
||||
// Release potential Room ViewController if none is visible (Note: check on room visibility is required to handle correctly splitViewController)
|
||||
if ([AppDelegate theDelegate].masterTabBarController.visibleRoomId == nil && currentRoomViewController) {
|
||||
currentRoomViewController.roomId = nil;
|
||||
@@ -148,6 +151,12 @@
|
||||
}
|
||||
}
|
||||
|
||||
- (void)viewDidDisappear:(BOOL)animated {
|
||||
[super viewDidDisappear:animated];
|
||||
|
||||
isVisible = NO;
|
||||
}
|
||||
|
||||
#pragma mark -
|
||||
|
||||
- (void)setPreSelectedRoomId:(NSString *)roomId {
|
||||
@@ -220,11 +229,26 @@
|
||||
|
||||
[self startActivityIndicator];
|
||||
|
||||
// FIXME handle MatrixHandlerStatusStoreDataReady gfo
|
||||
if (mxHandler.status == MatrixHandlerStatusServerSyncDone) {
|
||||
// Create/Update recents
|
||||
if (mxHandler.mxSession) {
|
||||
if (mxHandler.mxSession) {
|
||||
// Check matrix handler status
|
||||
if (mxHandler.status == MatrixHandlerStatusStoreDataReady) {
|
||||
// Server sync is not complete yet
|
||||
if (!recents) {
|
||||
// Retrieve recents from local storage (some data may not be up-to-date)
|
||||
NSArray *recentEvents = [NSMutableArray arrayWithArray:[mxHandler.mxSession recentsWithTypeIn:mxHandler.eventsFilterForMessages]];
|
||||
recents = [NSMutableArray arrayWithCapacity:recentEvents.count];
|
||||
for (MXEvent *mxEvent in recentEvents) {
|
||||
MXRoom *mxRoom = [mxHandler.mxSession roomWithRoomId:mxEvent.roomId];
|
||||
RecentRoom *recentRoom = [[RecentRoom alloc] initWithLastEvent:mxEvent andRoomState:mxRoom.state markAsUnread:NO];
|
||||
if (recentRoom) {
|
||||
[recents addObject:recentRoom];
|
||||
}
|
||||
}
|
||||
unreadCount = 0;
|
||||
}
|
||||
} else if (mxHandler.status == MatrixHandlerStatusServerSyncDone) {
|
||||
// Force recents refresh and add listener to update them (if it is not already done)
|
||||
if (!recentsListener) {
|
||||
NSArray *recentEvents = [NSMutableArray arrayWithArray:[mxHandler.mxSession recentsWithTypeIn:mxHandler.eventsFilterForMessages]];
|
||||
recents = [NSMutableArray arrayWithCapacity:recentEvents.count];
|
||||
for (MXEvent *mxEvent in recentEvents) {
|
||||
@@ -370,8 +394,8 @@
|
||||
if ([@"status" isEqualToString:keyPath]) {
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
[self configureView];
|
||||
// Hide the activity indicator when Recents is not the current tab
|
||||
if ([AppDelegate theDelegate].masterTabBarController.selectedIndex != TABBAR_RECENTS_INDEX) {
|
||||
// Hide the activity indicator when Recents is not visible
|
||||
if (!isVisible) {
|
||||
[self stopActivityIndicator];
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user