mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-08-08 00:21:12 +00:00
Only check for new feedback when the app becomes active and was actually in the background previously
This commit is contained in:
parent
9ddcad6da7
commit
74751a9945
@ -60,6 +60,7 @@
|
|||||||
|
|
||||||
BOOL _incomingMessagesAlertShowing;
|
BOOL _incomingMessagesAlertShowing;
|
||||||
BOOL _didSetupDidBecomeActiveNotifications;
|
BOOL _didSetupDidBecomeActiveNotifications;
|
||||||
|
BOOL _didEnterBackgroundState;
|
||||||
BOOL _networkRequestInProgress;
|
BOOL _networkRequestInProgress;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -75,7 +76,7 @@
|
|||||||
_requireUserEmail = BITFeedbackUserDataElementOptional;
|
_requireUserEmail = BITFeedbackUserDataElementOptional;
|
||||||
_showAlertOnIncomingMessages = YES;
|
_showAlertOnIncomingMessages = YES;
|
||||||
_showFirstRequiredPresentationModal = YES;
|
_showFirstRequiredPresentationModal = YES;
|
||||||
|
|
||||||
_disableFeedbackManager = NO;
|
_disableFeedbackManager = NO;
|
||||||
_didSetupDidBecomeActiveNotifications = NO;
|
_didSetupDidBecomeActiveNotifications = NO;
|
||||||
_networkRequestInProgress = NO;
|
_networkRequestInProgress = NO;
|
||||||
@ -117,7 +118,8 @@
|
|||||||
|
|
||||||
- (void)didBecomeActiveActions {
|
- (void)didBecomeActiveActions {
|
||||||
if ([self isFeedbackManagerDisabled]) return;
|
if ([self isFeedbackManagerDisabled]) return;
|
||||||
|
if (!_didEnterBackgroundState) return;
|
||||||
|
|
||||||
if ([_feedbackList count] == 0) {
|
if ([_feedbackList count] == 0) {
|
||||||
[self loadMessages];
|
[self loadMessages];
|
||||||
} else {
|
} else {
|
||||||
@ -126,9 +128,18 @@
|
|||||||
[self updateMessagesList];
|
[self updateMessagesList];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (void)didEnterBackgroundActions {
|
||||||
|
_didEnterBackgroundState = NO;
|
||||||
|
|
||||||
|
if ([[UIApplication sharedApplication] applicationState] == UIApplicationStateBackground) {
|
||||||
|
_didEnterBackgroundState = YES;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
- (void)setupDidBecomeActiveNotifications {
|
- (void)setupDidBecomeActiveNotifications {
|
||||||
if (!_didSetupDidBecomeActiveNotifications) {
|
if (!_didSetupDidBecomeActiveNotifications) {
|
||||||
NSNotificationCenter *dnc = [NSNotificationCenter defaultCenter];
|
NSNotificationCenter *dnc = [NSNotificationCenter defaultCenter];
|
||||||
|
[dnc addObserver:self selector:@selector(didEnterBackgroundActions) name:UIApplicationDidEnterBackgroundNotification object:nil];
|
||||||
[dnc addObserver:self selector:@selector(didBecomeActiveActions) name:UIApplicationDidBecomeActiveNotification object:nil];
|
[dnc addObserver:self selector:@selector(didBecomeActiveActions) name:UIApplicationDidBecomeActiveNotification object:nil];
|
||||||
[dnc addObserver:self selector:@selector(didBecomeActiveActions) name:BITHockeyNetworkDidBecomeReachableNotification object:nil];
|
[dnc addObserver:self selector:@selector(didBecomeActiveActions) name:BITHockeyNetworkDidBecomeReachableNotification object:nil];
|
||||||
_didSetupDidBecomeActiveNotifications = YES;
|
_didSetupDidBecomeActiveNotifications = YES;
|
||||||
@ -198,6 +209,9 @@
|
|||||||
// we are already delayed, so the notification already came in and this won't invoked twice
|
// we are already delayed, so the notification already came in and this won't invoked twice
|
||||||
switch ([[UIApplication sharedApplication] applicationState]) {
|
switch ([[UIApplication sharedApplication] applicationState]) {
|
||||||
case UIApplicationStateActive:
|
case UIApplicationStateActive:
|
||||||
|
// we did startup, so yes we are coming from background
|
||||||
|
_didEnterBackgroundState = YES;
|
||||||
|
|
||||||
[self didBecomeActiveActions];
|
[self didBecomeActiveActions];
|
||||||
break;
|
break;
|
||||||
case UIApplicationStateBackground:
|
case UIApplicationStateBackground:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user