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

View file

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

View file

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

View file

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

View file

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