Merge pull request #853 from RyanRory/fix-global-search-hanging

Fix global search hanging issue
This commit is contained in:
Morgan Pretty 2023-05-18 15:19:28 +10:00 committed by GitHub
commit 4455af9771
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -8,6 +8,11 @@ import SessionMessagingKit
public final class FullConversationCell: UITableViewCell {
public static let unreadCountViewSize: CGFloat = 20
private static let statusIndicatorSize: CGFloat = 14
// If a message is much too long, it will take forever to calculate its width and
// cause the app to be frozen. So if a search result string is longer than 100
// characters, we assume it cannot be shown within one line and need to be truncated
// to avoid the calculation.
private static let maxApproxCharactersCanBeShownInOneLine: Int = 100
// MARK: - UI
@ -657,14 +662,25 @@ public final class FullConversationCell: UITableViewCell {
return authorPrefix
.appending(
truncatingIfNeeded(
approxWidth: (authorPrefix.size().width + result.size().width),
approxWidth: (
authorPrefix.size().width +
(
result.length > Self.maxApproxCharactersCanBeShownInOneLine ?
bounds.width :
result.size().width
)
),
content: result
)
)
}
.defaulting(
to: truncatingIfNeeded(
approxWidth: result.size().width,
approxWidth: (
result.length > Self.maxApproxCharactersCanBeShownInOneLine ?
bounds.width :
result.size().width
),
content: result
)
)