Merge branch 'charlesmchen/unreadIndicatorVsBackground'

This commit is contained in:
Matthew Chen 2017-05-31 09:45:42 -04:00
commit 5485f5d55a
5 changed files with 42 additions and 18 deletions

View file

@ -585,6 +585,7 @@ typedef enum : NSUInteger {
}
}];
[self.voiceMemoUpdateTimer invalidate];
self.voiceMemoUpdateTimer = [NSTimer weakScheduledTimerWithTimeInterval:0.1f
target:self
selector:@selector(updateVoiceMemo)
@ -971,6 +972,10 @@ typedef enum : NSUInteger {
selector:@selector(applicationWillEnterForeground:)
name:UIApplicationWillEnterForegroundNotification
object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(applicationDidEnterBackground:)
name:UIApplicationDidEnterBackgroundNotification
object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(applicationWillResignActive:)
name:UIApplicationWillResignActiveNotification
@ -1006,6 +1011,16 @@ typedef enum : NSUInteger {
[self ensureThreadOffersAndIndicators];
}
- (void)applicationDidEnterBackground:(NSNotification *)notification
{
// self.hasEnteredBackground = YES;
if (self.hasClearedUnreadMessagesIndicator) {
self.hasClearedUnreadMessagesIndicator = NO;
self.offersAndIndicators = nil;
}
}
- (void)applicationWillResignActive:(NSNotification *)notification
{
[self cancelVoiceMemo];
@ -1279,11 +1294,12 @@ typedef enum : NSUInteger {
}
- (void)startReadTimer {
self.readTimer = [NSTimer scheduledTimerWithTimeInterval:1
target:self
selector:@selector(readTimerDidFire)
userInfo:nil
repeats:YES];
[self.readTimer invalidate];
self.readTimer = [NSTimer weakScheduledTimerWithTimeInterval:2
target:self
selector:@selector(readTimerDidFire)
userInfo:nil
repeats:YES];
}
- (void)readTimerDidFire
@ -2972,7 +2988,11 @@ typedef enum : NSUInteger {
// make sure we don't show it again.
self.hasClearedUnreadMessagesIndicator = YES;
[self ensureThreadOffersAndIndicators];
if (self.offersAndIndicators.unreadIndicatorPosition) {
// If we've just cleared the "unread messages" indicator,
// update the dynamic interactions.
[self ensureThreadOffersAndIndicators];
}
}
#pragma mark - Attachment Picking: Documents

View file

@ -127,6 +127,7 @@ NS_ASSUME_NONNULL_BEGIN
[self.audioPlayer prepareToPlay];
[self.audioPlayer play];
[self.audioPlayerPoller invalidate];
self.audioPlayerPoller = [NSTimer weakScheduledTimerWithTimeInterval:.05f
target:self
selector:@selector(audioPlayerUpdated:)

View file

@ -6,6 +6,7 @@
#import "OWSDeviceTableViewCell.h"
#import "OWSLinkDeviceViewController.h"
#import "UIViewController+CameraPermissions.h"
#import <SignalServiceKit/NSTimer+OWS.h>
#import <SignalServiceKit/OWSDevice.h>
#import <SignalServiceKit/OWSDevicesService.h>
#import <SignalServiceKit/TSDatabaseView.h>
@ -100,11 +101,11 @@ int const OWSLinkedDevicesTableViewControllerSectionAddDevice = 1;
self.editing = NO;
__weak typeof(self) wself = self;
self.pollingRefreshTimer = [NSTimer scheduledTimerWithTimeInterval:(10.0)
target:wself
selector:@selector(refreshDevices)
userInfo:nil
repeats:YES];
[self.pollingRefreshTimer invalidate];
self.pollingRefreshTimer = [NSTimer weakScheduledTimerWithTimeInterval:(10.0)target:wself
selector:@selector(refreshDevices)
userInfo:nil
repeats:YES];
NSString *progressText = NSLocalizedString(@"WAITING_TO_COMPLETE_DEVICE_LINK_TEXT",
@"Activity indicator title, shown upon returning to the device "

View file

@ -4,6 +4,7 @@
#import "SignalsNavigationController.h"
#import "UIUtil.h"
#import <SignalServiceKit/NSTimer+OWS.h>
#import <SignalServiceKit/OWSSignalService.h>
#import <SignalServiceKit/TSSocketManager.h>
@ -87,12 +88,13 @@ static double const STALLED_PROGRESS = 0.9;
case SocketManagerStateClosed:
if (_socketStatusView == nil) {
[self initializeSocketStatusBar];
_updateStatusTimer = [NSTimer scheduledTimerWithTimeInterval:0.5
target:self
selector:@selector(updateProgress)
userInfo:nil
repeats:YES];
[_updateStatusTimer invalidate];
_updateStatusTimer = [NSTimer weakScheduledTimerWithTimeInterval:0.5
target:self
selector:@selector(updateProgress)
userInfo:nil
repeats:YES];
} else if (_socketStatusView.progress >= STALLED_PROGRESS) {
[_updateStatusTimer invalidate];
}

View file

@ -155,7 +155,7 @@ NS_ASSUME_NONNULL_BEGIN
// have been marked as read.
//
// IFF this variable is non-null, there are unseen messages in the thread.
__block NSNumber *firstUnseenInteractionTimestamp = nil;
NSNumber *firstUnseenInteractionTimestamp = nil;
if (firstUnseenInteractionTimestampParameter) {
firstUnseenInteractionTimestamp = firstUnseenInteractionTimestampParameter;
} else {