Skip to content

Commit

Permalink
Fix sync errors not being displayed when no connectivity
Browse files Browse the repository at this point in the history
  • Loading branch information
tmolitor-stud-tu committed Jan 9, 2024
1 parent 878a587 commit d933290
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 7 deletions.
21 changes: 15 additions & 6 deletions Monal/Classes/HelperTools.m
Original file line number Diff line number Diff line change
Expand Up @@ -1374,17 +1374,25 @@ +(void) updateSyncErrorsWithDeleteOnly:(BOOL) removeOnly andWaitForCompletion:(B
for(xmpp* account in [MLXMPPManager sharedInstance].connectedXMPP)
{
//ignore already disconnected accounts (they are always "idle" but this does not reflect the real sync state)
if(account.accountState < kStateReconnecting && !account.reconnectInProgress)
//but only do so if we have connectivity (we want to alert the user of pending outgoing stanzas even if we don't have connectivity)
if(account.accountState < kStateReconnecting && !account.reconnectInProgress && [[MLXMPPManager sharedInstance] hasConnectivity])
{
DDLogDebug(@"Ignoring disconnected account: %@", account);
continue;
}
NSString* syncErrorIdentifier = [NSString stringWithFormat:@"syncError::%@", account.connectionProperties.identity.jid];
//dispatching this to the receive queue isn't neccessary anymore, see comments in account.idle
if(account.idle)
{
DDLogInfo(@"Removing syncError notification for %@ (now synced)...", account.connectionProperties.identity.jid);
[[UNUserNotificationCenter currentNotificationCenter] removePendingNotificationRequestsWithIdentifiers:@[syncErrorIdentifier]];
[[UNUserNotificationCenter currentNotificationCenter] removeDeliveredNotificationsWithIdentifiers:@[syncErrorIdentifier]];
syncErrorsDisplayed[account.connectionProperties.identity.jid] = @NO;
[[HelperTools defaultsDB] setObject:syncErrorsDisplayed forKey:@"syncErrorsDisplayed"];
//but only do so, if we have connectivity, otherwise just ignore it (the old sync error should still be displayed)
if([[MLXMPPManager sharedInstance] hasConnectivity])
{
DDLogInfo(@"Removing syncError notification for %@ (now synced)...", account.connectionProperties.identity.jid);
[[UNUserNotificationCenter currentNotificationCenter] removePendingNotificationRequestsWithIdentifiers:@[syncErrorIdentifier]];
[[UNUserNotificationCenter currentNotificationCenter] removeDeliveredNotificationsWithIdentifiers:@[syncErrorIdentifier]];
syncErrorsDisplayed[account.connectionProperties.identity.jid] = @NO;
[[HelperTools defaultsDB] setObject:syncErrorsDisplayed forKey:@"syncErrorsDisplayed"];
}
}
else if(!removeOnly && [self isNotInFocus])
{
Expand All @@ -1405,6 +1413,7 @@ +(void) updateSyncErrorsWithDeleteOnly:(BOOL) removeOnly andWaitForCompletion:(B
if(![self isAppExtension] && !account.isDoingFullReconnect && ![account shouldTriggerSyncErrorForImportantUnackedOutgoingStanzas])
{
DDLogWarn(@"NOT posting syncError notification for %@ (we are not in the appex, no important stanzas are unacked and we are not doing a full reconnect)...", account.connectionProperties.identity.jid);
DDLogDebug(@"[self isAppExtension] == %@, account.isDoingFullReconnect == %@, [account shouldTriggerSyncErrorForImportantUnackedOutgoingStanzas] == %@", bool2str([self isAppExtension]), bool2str(account.isDoingFullReconnect), bool2str([account shouldTriggerSyncErrorForImportantUnackedOutgoingStanzas]));
continue;
}
DDLogWarn(@"Posting syncError notification for %@...", account.connectionProperties.identity.jid);
Expand Down
2 changes: 1 addition & 1 deletion Monal/Classes/xmpp.m
Original file line number Diff line number Diff line change
Expand Up @@ -5180,7 +5180,7 @@ -(void) logCatchupStats
-(void) handleFinishedCatchup
{
self->_catchupDone = YES;
self.isDoingFullReconnect = NO;
self.isDoingFullReconnect = !self.connectionProperties.supportsSM3;

//log catchup statistics
[self logCatchupStats];
Expand Down

0 comments on commit d933290

Please sign in to comment.