From 01d9993b9d4157d754a1d090fca57ceb5ebd8200 Mon Sep 17 00:00:00 2001 From: Matthew Chen Date: Thu, 28 Mar 2019 17:03:10 -0400 Subject: [PATCH] Handle notifications for open conversations. --- .../UserInterface/Notifications/AppNotifications.swift | 2 +- Signal/src/environment/SignalApp.h | 2 +- Signal/src/environment/SignalApp.m | 8 +++++--- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/Signal/src/UserInterface/Notifications/AppNotifications.swift b/Signal/src/UserInterface/Notifications/AppNotifications.swift index 60f255f91..2f7bf636f 100644 --- a/Signal/src/UserInterface/Notifications/AppNotifications.swift +++ b/Signal/src/UserInterface/Notifications/AppNotifications.swift @@ -648,7 +648,7 @@ class NotificationActionHandler { // can be visible to the user immediately upon opening the app, rather than having to watch // it animate in from the homescreen. let shouldAnimate = UIApplication.shared.applicationState == .active - signalApp.presentConversation(forThreadId: threadId, animated: shouldAnimate) + signalApp.presentConversationAndShowFirstUnreadMessage(forThreadId: threadId, animated: shouldAnimate) return Promise.value(()) } diff --git a/Signal/src/environment/SignalApp.h b/Signal/src/environment/SignalApp.h index e89daec85..3c759094e 100644 --- a/Signal/src/environment/SignalApp.h +++ b/Signal/src/environment/SignalApp.h @@ -46,7 +46,7 @@ NS_ASSUME_NONNULL_BEGIN focusMessageId:(nullable NSString *)focusMessageId animated:(BOOL)isAnimated; -- (void)presentConversationForThreadAndShowFirstUnreadMessage:(TSThread *)thread animated:(BOOL)isAnimated; +- (void)presentConversationAndShowFirstUnreadMessageForThreadId:(NSString *)threadId animated:(BOOL)isAnimated; #pragma mark - Methods diff --git a/Signal/src/environment/SignalApp.m b/Signal/src/environment/SignalApp.m index b03834b31..8d01c8ddf 100644 --- a/Signal/src/environment/SignalApp.m +++ b/Signal/src/environment/SignalApp.m @@ -122,14 +122,16 @@ NS_ASSUME_NONNULL_BEGIN }); } -- (void)presentConversationForThreadAndShowFirstUnreadMessage:(TSThread *)thread animated:(BOOL)isAnimated +- (void)presentConversationAndShowFirstUnreadMessageForThreadId:(NSString *)threadId animated:(BOOL)isAnimated { OWSAssertIsOnMainThread(); + OWSAssertDebug(threadId.length > 0); OWSLogInfo(@""); - if (!thread) { - OWSFailDebug(@"Can't present nil thread."); + TSThread *thread = [TSThread fetchObjectWithUniqueID:threadId]; + if (thread == nil) { + OWSFailDebug(@"unable to find thread with id: %@", threadId); return; }