Fix data type issue around losing millisecond precision in message expiration times.

// FREEBIE
pull/1/head
Matthew Chen 8 years ago
parent 19390abc41
commit 7afcad81c6

@ -5,8 +5,8 @@ target 'Signal' do
pod 'SocketRocket', :git => 'https://github.com/facebook/SocketRocket.git' pod 'SocketRocket', :git => 'https://github.com/facebook/SocketRocket.git'
pod 'AxolotlKit', git: 'https://github.com/WhisperSystems/SignalProtocolKit.git' pod 'AxolotlKit', git: 'https://github.com/WhisperSystems/SignalProtocolKit.git'
#pod 'AxolotlKit', path: '../SignalProtocolKit' #pod 'AxolotlKit', path: '../SignalProtocolKit'
pod 'SignalServiceKit', git: 'https://github.com/WhisperSystems/SignalServiceKit.git' #pod 'SignalServiceKit', git: 'https://github.com/WhisperSystems/SignalServiceKit.git'
#pod 'SignalServiceKit', path: '../SignalServiceKit' pod 'SignalServiceKit', path: '../SignalServiceKit'
pod 'OpenSSL' pod 'OpenSSL'
pod 'JSQMessagesViewController', git: 'https://github.com/WhisperSystems/JSQMessagesViewController.git', branch: 'mkirk/position-edit-menu' pod 'JSQMessagesViewController', git: 'https://github.com/WhisperSystems/JSQMessagesViewController.git', branch: 'mkirk/position-edit-menu'
#pod 'JSQMessagesViewController' path: '../JSQMessagesViewController' #pod 'JSQMessagesViewController' path: '../JSQMessagesViewController'

@ -114,7 +114,7 @@ DEPENDENCIES:
- OpenSSL - OpenSSL
- PureLayout - PureLayout
- Reachability - Reachability
- SignalServiceKit (from `https://github.com/WhisperSystems/SignalServiceKit.git`) - SignalServiceKit (from `../SignalServiceKit`)
- SocketRocket (from `https://github.com/facebook/SocketRocket.git`) - SocketRocket (from `https://github.com/facebook/SocketRocket.git`)
EXTERNAL SOURCES: EXTERNAL SOURCES:
@ -124,7 +124,7 @@ EXTERNAL SOURCES:
:branch: mkirk/position-edit-menu :branch: mkirk/position-edit-menu
:git: https://github.com/WhisperSystems/JSQMessagesViewController.git :git: https://github.com/WhisperSystems/JSQMessagesViewController.git
SignalServiceKit: SignalServiceKit:
:git: https://github.com/WhisperSystems/SignalServiceKit.git :path: ../SignalServiceKit
SocketRocket: SocketRocket:
:git: https://github.com/facebook/SocketRocket.git :git: https://github.com/facebook/SocketRocket.git
@ -135,9 +135,6 @@ CHECKOUT OPTIONS:
JSQMessagesViewController: JSQMessagesViewController:
:commit: 7054e4b13ee5bcd6d524adb6dc9a726e8c466308 :commit: 7054e4b13ee5bcd6d524adb6dc9a726e8c466308
:git: https://github.com/WhisperSystems/JSQMessagesViewController.git :git: https://github.com/WhisperSystems/JSQMessagesViewController.git
SignalServiceKit:
:commit: c7cc023541c9c7ee098f08f91949263fe0341625
:git: https://github.com/WhisperSystems/SignalServiceKit.git
SocketRocket: SocketRocket:
:commit: 877ac7438be3ad0b45ef5ca3969574e4b97112bf :commit: 877ac7438be3ad0b45ef5ca3969574e4b97112bf
:git: https://github.com/facebook/SocketRocket.git :git: https://github.com/facebook/SocketRocket.git
@ -164,6 +161,6 @@ SPEC CHECKSUMS:
UnionFind: c33be5adb12983981d6e827ea94fc7f9e370f52d UnionFind: c33be5adb12983981d6e827ea94fc7f9e370f52d
YapDatabase: cd911121580ff16675f65ad742a9eb0ab4d9e266 YapDatabase: cd911121580ff16675f65ad742a9eb0ab4d9e266
PODFILE CHECKSUM: 48e80d7f1e049bbf544a689fdfdf33e8196c640a PODFILE CHECKSUM: 6f9ef5d9fa17469569e127a9f5719dafa11631b9
COCOAPODS: 1.2.1 COCOAPODS: 1.2.1

@ -17,7 +17,7 @@ NS_ASSUME_NONNULL_BEGIN
@property (nonatomic) TSMessageAdapterType messageType; @property (nonatomic) TSMessageAdapterType messageType;
@property (nonatomic) BOOL isExpiringMessage; @property (nonatomic) BOOL isExpiringMessage;
@property (nonatomic) BOOL shouldStartExpireTimer; @property (nonatomic) BOOL shouldStartExpireTimer;
@property (nonatomic) uint64_t expiresAtSeconds; @property (nonatomic) double expiresAtSeconds;
@property (nonatomic) uint32_t expiresInSeconds; @property (nonatomic) uint32_t expiresInSeconds;
@property (nonatomic) TSInteraction *interaction; @property (nonatomic) TSInteraction *interaction;

@ -24,7 +24,7 @@ typedef NS_ENUM(NSInteger, TSMessageAdapterType) {
@property (nonatomic, readonly) TSInteraction *interaction; @property (nonatomic, readonly) TSInteraction *interaction;
@property (nonatomic, readonly) BOOL isExpiringMessage; @property (nonatomic, readonly) BOOL isExpiringMessage;
@property (nonatomic, readonly) BOOL shouldStartExpireTimer; @property (nonatomic, readonly) BOOL shouldStartExpireTimer;
@property (nonatomic, readonly) uint64_t expiresAtSeconds; @property (nonatomic, readonly) double expiresAtSeconds;
@property (nonatomic, readonly) uint32_t expiresInSeconds; @property (nonatomic, readonly) uint32_t expiresInSeconds;
@end @end

@ -54,7 +54,7 @@ NS_ASSUME_NONNULL_BEGIN
@property (nonatomic) TSMessageAdapterType messageType; @property (nonatomic) TSMessageAdapterType messageType;
@property (nonatomic) BOOL isExpiringMessage; @property (nonatomic) BOOL isExpiringMessage;
@property (nonatomic) BOOL shouldStartExpireTimer; @property (nonatomic) BOOL shouldStartExpireTimer;
@property (nonatomic) uint64_t expiresAtSeconds; @property (nonatomic) double expiresAtSeconds;
@property (nonatomic) uint32_t expiresInSeconds; @property (nonatomic) uint32_t expiresInSeconds;
@property (nonatomic) NSDate *messageDate; @property (nonatomic) NSDate *messageDate;
@ -83,7 +83,7 @@ NS_ASSUME_NONNULL_BEGIN
if ([interaction isKindOfClass:[TSMessage class]]) { if ([interaction isKindOfClass:[TSMessage class]]) {
TSMessage *message = (TSMessage *)interaction; TSMessage *message = (TSMessage *)interaction;
_isExpiringMessage = message.isExpiringMessage; _isExpiringMessage = message.isExpiringMessage;
_expiresAtSeconds = message.expiresAt / 1000; _expiresAtSeconds = message.expiresAt / 1000.0;
_expiresInSeconds = message.expiresInSeconds; _expiresInSeconds = message.expiresInSeconds;
_shouldStartExpireTimer = message.shouldStartExpireTimer; _shouldStartExpireTimer = message.shouldStartExpireTimer;
} else { } else {

@ -1,5 +1,6 @@
// Created by Michael Kirk on 9/29/16. //
// Copyright © 2016 Open Whisper Systems. All rights reserved. // Copyright (c) 2017 Open Whisper Systems. All rights reserved.
//
NS_ASSUME_NONNULL_BEGIN NS_ASSUME_NONNULL_BEGIN
@ -12,7 +13,7 @@ static const CGFloat OWSExpirableMessageViewTimerWidth = 10.0f;
@property (strong, nonatomic, readonly) IBOutlet OWSExpirationTimerView *expirationTimerView; @property (strong, nonatomic, readonly) IBOutlet OWSExpirationTimerView *expirationTimerView;
@property (strong, nonatomic, readonly) IBOutlet NSLayoutConstraint *expirationTimerViewWidthConstraint; @property (strong, nonatomic, readonly) IBOutlet NSLayoutConstraint *expirationTimerViewWidthConstraint;
- (void)startExpirationTimerWithExpiresAtSeconds:(uint64_t)expiresAtSeconds - (void)startExpirationTimerWithExpiresAtSeconds:(double)expiresAtSeconds
initialDurationSeconds:(uint32_t)initialDurationSeconds; initialDurationSeconds:(uint32_t)initialDurationSeconds;
- (void)stopExpirationTimer; - (void)stopExpirationTimer;

@ -1,5 +1,6 @@
// Created by Michael Kirk on 9/29/16. //
// Copyright © 2016 Open Whisper Systems. All rights reserved. // Copyright (c) 2017 Open Whisper Systems. All rights reserved.
//
#import <UIKit/UIKit.h> #import <UIKit/UIKit.h>
@ -7,8 +8,7 @@ NS_ASSUME_NONNULL_BEGIN
@interface OWSExpirationTimerView : UIView @interface OWSExpirationTimerView : UIView
- (void)startTimerWithExpiresAtSeconds:(uint64_t)expiresAtSeconds - (void)startTimerWithExpiresAtSeconds:(double)expiresAtSeconds initialDurationSeconds:(uint32_t)initialDurationSeconds;
initialDurationSeconds:(uint32_t)initialDurationSeconds;
- (void)stopTimer; - (void)stopTimer;

@ -1,5 +1,6 @@
// Created by Michael Kirk on 9/29/16. //
// Copyright © 2016 Open Whisper Systems. All rights reserved. // Copyright (c) 2017 Open Whisper Systems. All rights reserved.
//
#import "OWSExpirationTimerView.h" #import "OWSExpirationTimerView.h"
#import "MessagesViewController.h" #import "MessagesViewController.h"
@ -14,7 +15,7 @@ double const OWSExpirationTimerViewBlinkingSeconds = 2;
@interface OWSExpirationTimerView () @interface OWSExpirationTimerView ()
@property (nonatomic) uint32_t initialDurationSeconds; @property (nonatomic) uint32_t initialDurationSeconds;
@property (atomic) uint64_t expiresAtSeconds; @property (atomic) double expiresAtSeconds;
@property (nonatomic, readonly) UIImageView *emptyHourglassImageView; @property (nonatomic, readonly) UIImageView *emptyHourglassImageView;
@property (nonatomic, readonly) UIImageView *fullHourglassImageView; @property (nonatomic, readonly) UIImageView *fullHourglassImageView;
@ -91,8 +92,7 @@ double const OWSExpirationTimerViewBlinkingSeconds = 2;
[self startAnimation]; [self startAnimation];
} }
- (void)startTimerWithExpiresAtSeconds:(uint64_t)expiresAtSeconds - (void)startTimerWithExpiresAtSeconds:(double)expiresAtSeconds initialDurationSeconds:(uint32_t)initialDurationSeconds
initialDurationSeconds:(uint32_t)initialDurationSeconds
{ {
if (expiresAtSeconds == 0) { if (expiresAtSeconds == 0) {
DDLogWarn( DDLogWarn(
@ -101,7 +101,7 @@ double const OWSExpirationTimerViewBlinkingSeconds = 2;
initialDurationSeconds); initialDurationSeconds);
} }
DDLogVerbose(@"%@ Starting timer with expiresAtSeconds: %llu initialDurationSeconds: %d", DDLogVerbose(@"%@ Starting timer with expiresAtSeconds: %f initialDurationSeconds: %d",
self.logTag, self.logTag,
expiresAtSeconds, expiresAtSeconds,
initialDurationSeconds); initialDurationSeconds);
@ -117,12 +117,12 @@ double const OWSExpirationTimerViewBlinkingSeconds = 2;
- (void)startAnimation - (void)startAnimation
{ {
DDLogVerbose(@"%@ Starting animation with expiresAtSeconds: %llu initialDurationSeconds: %d", DDLogVerbose(@"%@ Starting animation with expiresAtSeconds: %f initialDurationSeconds: %d",
self.logTag, self.logTag,
self.expiresAtSeconds, self.expiresAtSeconds,
self.initialDurationSeconds); self.initialDurationSeconds);
double secondsLeft = (double)self.expiresAtSeconds - [NSDate new].timeIntervalSince1970; double secondsLeft = self.expiresAtSeconds - [NSDate new].timeIntervalSince1970;
if (secondsLeft < 0) { if (secondsLeft < 0) {
secondsLeft = 0; secondsLeft = 0;
@ -186,7 +186,7 @@ double const OWSExpirationTimerViewBlinkingSeconds = 2;
- (BOOL)itIsTimeToBlink - (BOOL)itIsTimeToBlink
{ {
double secondsLeft = (double)self.expiresAtSeconds - [NSDate new].timeIntervalSince1970; double secondsLeft = self.expiresAtSeconds - [NSDate new].timeIntervalSince1970;
return secondsLeft <= OWSExpirationTimerViewBlinkingSeconds; return secondsLeft <= OWSExpirationTimerViewBlinkingSeconds;
} }

@ -55,7 +55,7 @@ NS_ASSUME_NONNULL_BEGIN
// pragma mark - OWSExpirableMessageView // pragma mark - OWSExpirableMessageView
- (void)startExpirationTimerWithExpiresAtSeconds:(uint64_t)expiresAtSeconds - (void)startExpirationTimerWithExpiresAtSeconds:(double)expiresAtSeconds
initialDurationSeconds:(uint32_t)initialDurationSeconds initialDurationSeconds:(uint32_t)initialDurationSeconds
{ {
self.expirationTimerViewWidthConstraint.constant = OWSExpirableMessageViewTimerWidth; self.expirationTimerViewWidthConstraint.constant = OWSExpirableMessageViewTimerWidth;

@ -61,7 +61,7 @@ NS_ASSUME_NONNULL_BEGIN
// pragma mark - OWSExpirableMessageView // pragma mark - OWSExpirableMessageView
- (void)startExpirationTimerWithExpiresAtSeconds:(uint64_t)expiresAtSeconds - (void)startExpirationTimerWithExpiresAtSeconds:(double)expiresAtSeconds
initialDurationSeconds:(uint32_t)initialDurationSeconds initialDurationSeconds:(uint32_t)initialDurationSeconds
{ {
self.expirationTimerViewWidthConstraint.constant = OWSExpirableMessageViewTimerWidth; self.expirationTimerViewWidthConstraint.constant = OWSExpirableMessageViewTimerWidth;

Loading…
Cancel
Save