From 01742af16b8a07254aea97994752a740f04e5a36 Mon Sep 17 00:00:00 2001 From: Morgan Pretty Date: Mon, 21 Mar 2022 17:18:12 +1100 Subject: [PATCH 1/3] Added an initial call to `isRTL` on the main thread to prevent a background thread calling it first --- Session/Home/HomeVC.swift | 6 ++++++ Session/Meta/MainAppContext.m | 1 + 2 files changed, 7 insertions(+) diff --git a/Session/Home/HomeVC.swift b/Session/Home/HomeVC.swift index da9153682..8bbc7a523 100644 --- a/Session/Home/HomeVC.swift +++ b/Session/Home/HomeVC.swift @@ -84,6 +84,12 @@ final class HomeVC : BaseVC, UITableViewDataSource, UITableViewDelegate, NewConv // MARK: Lifecycle override func viewDidLoad() { super.viewDidLoad() + + // Note: This is a hack to ensure `isRTL` is initially gets run on the main thread so the value is cached (it gets + // called on background threads and if it hasn't cached the value then it can cause odd performance issues since + // it accesses UIKit) + _ = CurrentAppContext().isRTL + // Threads (part 1) dbConnection.beginLongLivedReadTransaction() // Freeze the connection for use on the main thread (this gives us a stable data source that doesn't change until we tell it to) // Preparation diff --git a/Session/Meta/MainAppContext.m b/Session/Meta/MainAppContext.m index 66948daf6..2fad58d41 100644 --- a/Session/Meta/MainAppContext.m +++ b/Session/Meta/MainAppContext.m @@ -166,6 +166,7 @@ NSString *const ReportedApplicationStateDidChangeNotification = @"ReportedApplic - (BOOL)isRTL { + // FIXME: We should try to remove this as we've had to add a hack to ensure the first call to this runs on the main thread static BOOL isRTL = NO; static dispatch_once_t onceToken; dispatch_once(&onceToken, ^{ From e7e8aba69ab15723fba29e2065a658bb0ad322d6 Mon Sep 17 00:00:00 2001 From: Morgan Pretty Date: Wed, 23 Mar 2022 10:00:49 +1100 Subject: [PATCH 2/3] Fixed a bug where sharing a url with LinkPreviews disabled could result in it being duplicated in the message --- SessionShareExtension/ThreadPickerVC.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SessionShareExtension/ThreadPickerVC.swift b/SessionShareExtension/ThreadPickerVC.swift index 0e0ff5db3..91a193a7e 100644 --- a/SessionShareExtension/ThreadPickerVC.swift +++ b/SessionShareExtension/ThreadPickerVC.swift @@ -162,7 +162,7 @@ final class ThreadPickerVC: UIViewController, UITableViewDataSource, UITableView message.sentTimestamp = NSDate.millisecondTimestamp() message.text = (isSharingUrl && (messageText?.isEmpty == true || attachments[0].linkPreviewDraft == nil) ? ( - (messageText?.isEmpty == true ? + (messageText?.isEmpty == true || (attachments[0].text() == messageText) ? attachments[0].text() : "\(attachments[0].text() ?? "")\n\n\(messageText ?? "")" ) From 990edd20df1179b5e90416e36c044573ceaa92c1 Mon Sep 17 00:00:00 2001 From: Morgan Pretty Date: Thu, 24 Mar 2022 13:42:49 +1100 Subject: [PATCH 3/3] Swapped a force-unwrap to an optional unwrap --- .../Message Cells/Content Views/LinkPreviewView.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Session/Conversations/Message Cells/Content Views/LinkPreviewView.swift b/Session/Conversations/Message Cells/Content Views/LinkPreviewView.swift index a2fe25fc5..2132d417b 100644 --- a/Session/Conversations/Message Cells/Content Views/LinkPreviewView.swift +++ b/Session/Conversations/Message Cells/Content Views/LinkPreviewView.swift @@ -9,7 +9,7 @@ final class LinkPreviewView : UIView { private lazy var imageViewContainerHeightConstraint = imageView.set(.height, to: 100) private lazy var sentLinkPreviewTextColor: UIColor = { - let isOutgoing = (viewItem!.interaction.interactionType() == .outgoingMessage) + let isOutgoing = (viewItem?.interaction.interactionType() == .outgoingMessage) switch (isOutgoing, AppModeManager.shared.currentAppMode) { case (true, .dark), (false, .light): return .black case (true, .light): return Colors.grey