From 027cd8cb34cad0b41771385dad8dd6474e061936 Mon Sep 17 00:00:00 2001 From: Matthew Chen Date: Mon, 12 Jun 2017 11:52:21 -0400 Subject: [PATCH] Rework how messages are marked read. // FREEBIE --- Podfile | 4 ++-- Podfile.lock | 9 +++------ .../ConversationView/MessagesViewController.m | 3 ++- Signal/src/network/PushManager.m | 16 +++++++++------- 4 files changed, 16 insertions(+), 16 deletions(-) diff --git a/Podfile b/Podfile index 55d7dcd08..624665393 100644 --- a/Podfile +++ b/Podfile @@ -5,8 +5,8 @@ target 'Signal' do pod 'SocketRocket', :git => 'https://github.com/facebook/SocketRocket.git' pod 'AxolotlKit', git: 'https://github.com/WhisperSystems/SignalProtocolKit.git' #pod 'AxolotlKit', path: '../SignalProtocolKit' - pod 'SignalServiceKit', git: 'https://github.com/WhisperSystems/SignalServiceKit.git' - #pod 'SignalServiceKit', path: '../SignalServiceKit' + #pod 'SignalServiceKit', git: 'https://github.com/WhisperSystems/SignalServiceKit.git' + pod 'SignalServiceKit', path: '../SignalServiceKit' pod 'OpenSSL' pod 'JSQMessagesViewController', git: 'https://github.com/WhisperSystems/JSQMessagesViewController.git', branch: 'mkirk/position-edit-menu' #pod 'JSQMessagesViewController' path: '../JSQMessagesViewController' diff --git a/Podfile.lock b/Podfile.lock index b40e8d831..0f8ef4e41 100644 --- a/Podfile.lock +++ b/Podfile.lock @@ -114,7 +114,7 @@ DEPENDENCIES: - OpenSSL - PureLayout - Reachability - - SignalServiceKit (from `https://github.com/WhisperSystems/SignalServiceKit.git`) + - SignalServiceKit (from `../SignalServiceKit`) - SocketRocket (from `https://github.com/facebook/SocketRocket.git`) EXTERNAL SOURCES: @@ -124,7 +124,7 @@ EXTERNAL SOURCES: :branch: mkirk/position-edit-menu :git: https://github.com/WhisperSystems/JSQMessagesViewController.git SignalServiceKit: - :git: https://github.com/WhisperSystems/SignalServiceKit.git + :path: ../SignalServiceKit SocketRocket: :git: https://github.com/facebook/SocketRocket.git @@ -135,9 +135,6 @@ CHECKOUT OPTIONS: JSQMessagesViewController: :commit: 7054e4b13ee5bcd6d524adb6dc9a726e8c466308 :git: https://github.com/WhisperSystems/JSQMessagesViewController.git - SignalServiceKit: - :commit: 49f11804310bbdddbb6d50ff071b53b328858b32 - :git: https://github.com/WhisperSystems/SignalServiceKit.git SocketRocket: :commit: 877ac7438be3ad0b45ef5ca3969574e4b97112bf :git: https://github.com/facebook/SocketRocket.git @@ -164,6 +161,6 @@ SPEC CHECKSUMS: UnionFind: c33be5adb12983981d6e827ea94fc7f9e370f52d YapDatabase: cd911121580ff16675f65ad742a9eb0ab4d9e266 -PODFILE CHECKSUM: 48e80d7f1e049bbf544a689fdfdf33e8196c640a +PODFILE CHECKSUM: 6f9ef5d9fa17469569e127a9f5719dafa11631b9 COCOAPODS: 1.2.1 diff --git a/Signal/src/ViewControllers/ConversationView/MessagesViewController.m b/Signal/src/ViewControllers/ConversationView/MessagesViewController.m index a0f0470c0..f42fdf9e8 100644 --- a/Signal/src/ViewControllers/ConversationView/MessagesViewController.m +++ b/Signal/src/ViewControllers/ConversationView/MessagesViewController.m @@ -3558,6 +3558,7 @@ typedef enum : NSUInteger { } id possiblyRead = (id)object; + OWSAssert(!possiblyRead.read); if (!possiblyRead.read) { [interactions addObject:possiblyRead]; } @@ -3568,7 +3569,7 @@ typedef enum : NSUInteger { } DDLogError(@"Marking %zd messages as read.", interactions.count); for (id possiblyRead in interactions) { - [possiblyRead markAsReadLocallyWithTransaction:transaction]; + [possiblyRead markAsReadWithTransaction:transaction sendReadReceipt:YES]; } }]; } diff --git a/Signal/src/network/PushManager.m b/Signal/src/network/PushManager.m index 7254b0caa..4d4adf650 100644 --- a/Signal/src/network/PushManager.m +++ b/Signal/src/network/PushManager.m @@ -225,15 +225,17 @@ NSString *const Signal_Message_MarkAsRead_Identifier = @"Signal_Message_MarkAsRe NSString *threadId = userInfo[Signal_Thread_UserInfo_Key]; TSThread *thread = [TSThread fetchObjectWithUniqueID:threadId]; - [[TSStorageManager sharedManager] - .dbConnection asyncReadWriteWithBlock:^(YapDatabaseReadWriteTransaction *_Nonnull transaction) { - [thread markAllAsReadWithTransaction:transaction]; - } + [[TSStorageManager sharedManager].dbConnection + asyncReadWriteWithBlock:^(YapDatabaseReadWriteTransaction *_Nonnull transaction) { + // TODO: I suspect we only want to mark the message in + // question as read. + [thread markAllAsReadWithTransaction:transaction]; + } completionBlock:^{ - [[[Environment getCurrent] signalsViewController] updateInboxCountLabel]; - [self cancelNotificationsWithThreadId:threadId]; + [[[Environment getCurrent] signalsViewController] updateInboxCountLabel]; + [self cancelNotificationsWithThreadId:threadId]; - completionHandler(); + completionHandler(); }]; }