Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion Monal/Classes/MLPromise.m
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#import "DataLayer.h"
#import "HelperTools.h"
#import "MLPromise.h"
#import "MLXMPPManager.h"

NS_ASSUME_NONNULL_BEGIN

Expand Down Expand Up @@ -206,7 +207,13 @@ -(void) attemptConsume
return;
}

if(!self.isStale)
if(self.isStale && self.state == PromiseResolutionStateRejected)
{
DDLogDebug(@"Promise %@ with uuid %@ is both stale and rejected - posting error", self, self.uuid);
xmpp* account = [[MLXMPPManager sharedInstance] getEnabledAccountForID:self.rejection.accountID];
[HelperTools postError:self.rejection.errorDescription withNode:self.rejection.node andAccount:account andIsSevere:NO];
}
else if(!self.isStale)
{
DDLogDebug(@"Resolving promise %@ with uuid %@ and argument %@", self, self.uuid, self.resolvedArgument);
resolve(self.resolvedArgument);
Expand Down
6 changes: 3 additions & 3 deletions Monal/Classes/MonalAppDelegate.m
Original file line number Diff line number Diff line change
Expand Up @@ -393,9 +393,6 @@ -(BOOL) application:(UIApplication*) application willFinishLaunchingWithOptions:
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_BACKGROUND, 0), ^{
[[MLImageManager sharedInstance] cleanupHashes];
});

// Remove stale promises left in the DB that weren't consumed last time we ran the app
[MLPromise consumeStalePromises];

//only proceed with launching if the NotificationServiceExtension is *not* running
if([MLProcessLock checkRemoteRunning:@"NotificationServiceExtension"])
Expand Down Expand Up @@ -558,6 +555,9 @@ -(BOOL) application:(UIApplication*) application didFinishLaunchingWithOptions:(

//should any accounts connect?
[self connectIfNecessaryWithOptions:launchOptions];

// Consume stale promises left in the DB that weren't consumed last time we ran the app
[MLPromise consumeStalePromises];

//handle IPC messages (this should be done *after* calling connectIfNecessary to make sure any disconnectAll messages are handled properly
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(incomingIPC:) name:kMonalIncomingIPC object:nil];
Expand Down