From bcc5da75b6e7a791d1ed38df5db6ca5695c9565c Mon Sep 17 00:00:00 2001 From: Ryan Zhao Date: Fri, 28 Jan 2022 13:14:02 +1100 Subject: [PATCH 01/11] minor fix on debug mode to prevent crashing --- Session/Conversations/ConversationViewItem.m | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Session/Conversations/ConversationViewItem.m b/Session/Conversations/ConversationViewItem.m index a60beeab4..4ebdd168a 100644 --- a/Session/Conversations/ConversationViewItem.m +++ b/Session/Conversations/ConversationViewItem.m @@ -567,13 +567,13 @@ NSString *NSStringForOWSMessageCellType(OWSMessageCellType cellType) TSAttachment *_Nullable linkPreviewAttachment = [TSAttachment fetchObjectWithUniqueID:message.linkPreview.imageAttachmentId transaction:transaction]; if (!linkPreviewAttachment) { - OWSFailDebug(@"Could not load link preview image attachment."); + OWSLogDebug(@"Could not load link preview image attachment."); } else if (!linkPreviewAttachment.isImage) { - OWSFailDebug(@"Link preview attachment isn't an image."); + OWSLogDebug(@"Link preview attachment isn't an image."); } else if ([linkPreviewAttachment isKindOfClass:[TSAttachmentStream class]]) { TSAttachmentStream *attachmentStream = (TSAttachmentStream *)linkPreviewAttachment; if (!attachmentStream.isValidImage) { - OWSFailDebug(@"Link preview image attachment isn't valid."); + OWSLogDebug(@"Link preview image attachment isn't valid."); } else { self.linkPreviewAttachment = linkPreviewAttachment; } From d642d8a4ed4639d1e4700c43b1f7acb5b0b93fc5 Mon Sep 17 00:00:00 2001 From: Ryan Zhao Date: Mon, 20 Dec 2021 15:23:31 +1100 Subject: [PATCH 02/11] improve image message ratio --- .../Message Cells/VisibleMessageCell.swift | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/Session/Conversations/Message Cells/VisibleMessageCell.swift b/Session/Conversations/Message Cells/VisibleMessageCell.swift index c564a598e..86279801f 100644 --- a/Session/Conversations/Message Cells/VisibleMessageCell.swift +++ b/Session/Conversations/Message Cells/VisibleMessageCell.swift @@ -612,8 +612,15 @@ final class VisibleMessageCell : MessageCell, LinkPreviewViewDelegate { let maxAspectRatio = 1 / minAspectRatio aspectRatio = aspectRatio.clamp(minAspectRatio, maxAspectRatio) let maxSize = CGSize(width: maxMessageWidth, height: maxMessageWidth) - var width = with(maxSize.height * aspectRatio) { $0 > maxSize.width ? maxSize.width : $0 } - var height = (width > maxSize.width) ? (maxSize.width / aspectRatio) : maxSize.height + var width: CGFloat + var height: CGFloat + if aspectRatio > 1 { + width = maxSize.width + height = width / aspectRatio + } else { + height = maxSize.height + width = height * aspectRatio + } // Don't blow up small images unnecessarily let minSize: CGFloat = 150 let shortSourceDimension = min(size.width, size.height) From 6ae84d3e37c943f9bafff83908c5c7adf0d1001d Mon Sep 17 00:00:00 2001 From: Ryan Zhao Date: Fri, 28 Jan 2022 13:45:27 +1100 Subject: [PATCH 03/11] update outgoing message text colour in light mode --- Podfile.lock | 8 ++++---- .../Message Cells/VisibleMessageCell.swift | 1 + SessionUIKit/Style Guide/Colors.swift | 1 + .../session_grey.colorset/Contents.json | 20 +++++++++++++++++++ 4 files changed, 26 insertions(+), 4 deletions(-) create mode 100644 SessionUIKit/Style Guide/Colors.xcassets/session_grey.colorset/Contents.json diff --git a/Podfile.lock b/Podfile.lock index 24d6abeed..d8af51feb 100644 --- a/Podfile.lock +++ b/Podfile.lock @@ -132,7 +132,7 @@ DEPENDENCIES: - SignalCoreKit (from `https://github.com/oxen-io/session-ios-core-kit`, branch `session-version`) - Sodium (~> 0.9.1) - SwiftProtobuf (~> 1.5.0) - - YapDatabase/SQLCipher (from `https://github.com/loki-project/session-ios-yap-database.git`, branch `signal-release`) + - YapDatabase/SQLCipher (from `https://github.com/oxen-io/session-ios-yap-database.git`, branch `signal-release`) - YYImage (from `https://github.com/signalapp/YYImage`) - ZXingObjC @@ -163,7 +163,7 @@ EXTERNAL SOURCES: :git: https://github.com/oxen-io/session-ios-core-kit YapDatabase: :branch: signal-release - :git: https://github.com/loki-project/session-ios-yap-database.git + :git: https://github.com/oxen-io/session-ios-yap-database.git YYImage: :git: https://github.com/signalapp/YYImage @@ -179,7 +179,7 @@ CHECKOUT OPTIONS: :git: https://github.com/oxen-io/session-ios-core-kit YapDatabase: :commit: d84069e25e12a16ab4422e5258127a04b70489ad - :git: https://github.com/loki-project/session-ios-yap-database.git + :git: https://github.com/oxen-io/session-ios-yap-database.git YYImage: :commit: 62a4cede20bcf31da73d18163408e46a92f171c6 :git: https://github.com/signalapp/YYImage @@ -204,6 +204,6 @@ SPEC CHECKSUMS: YYImage: f1ddd15ac032a58b78bbed1e012b50302d318331 ZXingObjC: fdbb269f25dd2032da343e06f10224d62f537bdb -PODFILE CHECKSUM: 7722d8a03a0ebc6ecd0070d02b199bd748992f12 +PODFILE CHECKSUM: 7f961dc4934dd213f5a3277af57d54caef7a4442 COCOAPODS: 1.11.2 diff --git a/Session/Conversations/Message Cells/VisibleMessageCell.swift b/Session/Conversations/Message Cells/VisibleMessageCell.swift index 86279801f..ad3b33ea0 100644 --- a/Session/Conversations/Message Cells/VisibleMessageCell.swift +++ b/Session/Conversations/Message Cells/VisibleMessageCell.swift @@ -131,6 +131,7 @@ final class VisibleMessageCell : MessageCell, LinkPreviewViewDelegate { private var bodyLabelTextColor: UIColor { switch (direction, AppModeManager.shared.currentAppMode) { case (.outgoing, .dark), (.incoming, .light): return .black + case (.outgoing, .light): return Colors.grey default: return .white } } diff --git a/SessionUIKit/Style Guide/Colors.swift b/SessionUIKit/Style Guide/Colors.swift index 1a150ebc9..e2d45fb7f 100644 --- a/SessionUIKit/Style Guide/Colors.swift +++ b/SessionUIKit/Style Guide/Colors.swift @@ -13,6 +13,7 @@ import UIKit @objc(LKColors) public final class Colors : NSObject { + @objc public static var grey: UIColor { UIColor(named: "session_grey")! } @objc public static var accent: UIColor { UIColor(named: "session_accent")! } @objc public static var text: UIColor { UIColor(named: "session_text")! } @objc public static var destructive: UIColor { UIColor(named: "session_destructive")! } diff --git a/SessionUIKit/Style Guide/Colors.xcassets/session_grey.colorset/Contents.json b/SessionUIKit/Style Guide/Colors.xcassets/session_grey.colorset/Contents.json new file mode 100644 index 000000000..f347d967f --- /dev/null +++ b/SessionUIKit/Style Guide/Colors.xcassets/session_grey.colorset/Contents.json @@ -0,0 +1,20 @@ +{ + "colors" : [ + { + "color" : { + "color-space" : "srgb", + "components" : { + "alpha" : "1.000", + "blue" : "0x30", + "green" : "0x2F", + "red" : "0x31" + } + }, + "idiom" : "universal" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} From d96d7468a420de3f08ca31bce11d16e50bf509e0 Mon Sep 17 00:00:00 2001 From: Ryan Zhao Date: Fri, 28 Jan 2022 14:04:41 +1100 Subject: [PATCH 04/11] fix read more button colour --- .../Message Cells/Content Views/MediaTextOverlayView.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Session/Conversations/Message Cells/Content Views/MediaTextOverlayView.swift b/Session/Conversations/Message Cells/Content Views/MediaTextOverlayView.swift index 9be711311..a0c655a5f 100644 --- a/Session/Conversations/Message Cells/Content Views/MediaTextOverlayView.swift +++ b/Session/Conversations/Message Cells/Content Views/MediaTextOverlayView.swift @@ -56,7 +56,7 @@ final class MediaTextOverlayView : UIView { self.readMoreButton = readMoreButton readMoreButton.setTitle("Read More", for: UIControl.State.normal) readMoreButton.titleLabel!.font = .boldSystemFont(ofSize: Values.smallFontSize) - readMoreButton.setTitleColor(.white, for: UIControl.State.normal) + readMoreButton.setTitleColor(self.textColor, for: UIControl.State.normal) readMoreButton.addTarget(self, action: #selector(readMore), for: UIControl.Event.touchUpInside) addSubview(readMoreButton) readMoreButton.pin(.left, to: .left, of: self, withInset: inset) From 8ed77435d880dc7925e963b5b44ef38f4ec678a7 Mon Sep 17 00:00:00 2001 From: Ryan Zhao Date: Thu, 6 Jan 2022 10:12:54 +1100 Subject: [PATCH 05/11] update translation --- Session/Meta/Translations/en.lproj/Localizable.strings | 2 ++ .../DataExtractionNotificationInfoMessage.swift | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/Session/Meta/Translations/en.lproj/Localizable.strings b/Session/Meta/Translations/en.lproj/Localizable.strings index a58f90996..0f7885322 100644 --- a/Session/Meta/Translations/en.lproj/Localizable.strings +++ b/Session/Meta/Translations/en.lproj/Localizable.strings @@ -579,3 +579,5 @@ "light_mode_theme" = "Light"; "PIN_BUTTON_TEXT" = "Pin"; "UNPIN_BUTTON_TEXT" = "Unpin"; +"meida_saved" = "Media saved by %@."; +"screenshot_taken" = "%@ took a screenshot."; diff --git a/SessionMessagingKit/Sending & Receiving/Data Extraction/DataExtractionNotificationInfoMessage.swift b/SessionMessagingKit/Sending & Receiving/Data Extraction/DataExtractionNotificationInfoMessage.swift index df2477e25..18ceef7f5 100644 --- a/SessionMessagingKit/Sending & Receiving/Data Extraction/DataExtractionNotificationInfoMessage.swift +++ b/SessionMessagingKit/Sending & Receiving/Data Extraction/DataExtractionNotificationInfoMessage.swift @@ -19,10 +19,10 @@ final class DataExtractionNotificationInfoMessage : TSInfoMessage { let sessionID = thread.contactSessionID() let displayName = Storage.shared.getContact(with: sessionID)?.displayName(for: .regular) ?? sessionID switch messageType { - case .screenshotNotification: return "\(displayName) took a screenshot." + case .screenshotNotification: return String(format: NSLocalizedString("screenshot_taken", comment: ""), displayName) case .mediaSavedNotification: // TODO: Use referencedAttachmentTimestamp to tell the user * which * media was saved - return "Media saved by \(displayName)." + return String(format: NSLocalizedString("meida_saved", comment: ""), displayName) default: preconditionFailure() } } From 70a562344c508f9c966023e40d4913248241df95 Mon Sep 17 00:00:00 2001 From: Ryan Zhao Date: Thu, 6 Jan 2022 10:08:59 +1100 Subject: [PATCH 06/11] minor issue fix --- .../Conversations/Message Cells/VisibleMessageCell.swift | 7 +++---- Session/Open Groups/JoinOpenGroupVC.swift | 2 +- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/Session/Conversations/Message Cells/VisibleMessageCell.swift b/Session/Conversations/Message Cells/VisibleMessageCell.swift index ad3b33ea0..f54ea79c9 100644 --- a/Session/Conversations/Message Cells/VisibleMessageCell.swift +++ b/Session/Conversations/Message Cells/VisibleMessageCell.swift @@ -208,8 +208,7 @@ final class VisibleMessageCell : MessageCell, LinkPreviewViewDelegate { // MARK: Updating override func update() { guard let viewItem = viewItem, let message = viewItem.interaction as? TSMessage else { return } - let thread = message.thread - let isGroupThread = thread.isGroupThread() + let isGroupThread = viewItem.isGroupThread // Profile picture view profilePictureViewLeftConstraint.constant = isGroupThread ? VisibleMessageCell.groupThreadHSpacing : 0 profilePictureViewWidthConstraint.constant = isGroupThread ? VisibleMessageCell.profilePictureSize : 0 @@ -218,8 +217,8 @@ final class VisibleMessageCell : MessageCell, LinkPreviewViewDelegate { if let senderSessionID = senderSessionID { profilePictureView.update(for: senderSessionID) } - if let thread = thread as? TSGroupThread, thread.isOpenGroup, let senderSessionID = senderSessionID { - if let openGroupV2 = Storage.shared.getV2OpenGroup(for: thread.uniqueId!) { + if let senderSessionID = senderSessionID, message.isOpenGroupMessage { + if let openGroupV2 = Storage.shared.getV2OpenGroup(for: message.uniqueThreadId) { let isUserModerator = OpenGroupAPIV2.isUserModerator(senderSessionID, for: openGroupV2.room, on: openGroupV2.server) moderatorIconImageView.isHidden = !isUserModerator || profilePictureView.isHidden } else { diff --git a/Session/Open Groups/JoinOpenGroupVC.swift b/Session/Open Groups/JoinOpenGroupVC.swift index b1587be54..debad90e2 100644 --- a/Session/Open Groups/JoinOpenGroupVC.swift +++ b/Session/Open Groups/JoinOpenGroupVC.swift @@ -143,7 +143,7 @@ final class JoinOpenGroupVC : BaseVC, UIPageViewControllerDataSource, UIPageView Storage.shared.write { transaction in OpenGroupManagerV2.shared.add(room: room, server: server, publicKey: publicKey, using: transaction) .done(on: DispatchQueue.main) { [weak self] _ in - self?.presentingViewController!.dismiss(animated: true, completion: nil) + self?.presentingViewController?.dismiss(animated: true, completion: nil) let appDelegate = UIApplication.shared.delegate as! AppDelegate appDelegate.forceSyncConfigurationNowIfNeeded().retainUntilComplete() // FIXME: It's probably cleaner to do this inside addOpenGroup(...) } From 2c7dfe6a37ea7cf200fa70c13fd74c154166c0a0 Mon Sep 17 00:00:00 2001 From: Ryan Zhao Date: Mon, 20 Dec 2021 12:24:42 +1100 Subject: [PATCH 07/11] fix conversation screen scrolling to bottom issue --- Session/Conversations/ConversationVC.swift | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Session/Conversations/ConversationVC.swift b/Session/Conversations/ConversationVC.swift index 0a58c831c..1cafba6dd 100644 --- a/Session/Conversations/ConversationVC.swift +++ b/Session/Conversations/ConversationVC.swift @@ -460,6 +460,10 @@ final class ConversationVC : BaseVC, ConversationViewModelDelegate, OWSConversat func scrollToBottom(isAnimated: Bool) { guard !isUserScrolling else { return } + if let interactionID = viewItems.last?.interaction.uniqueId { + self.scrollToInteraction(with: interactionID, position: .top, isAnimated: isAnimated) + return + } // Ensure the view is fully up to date before we try to scroll to the bottom, since // we use the table view's bounds to determine where the bottom is. view.layoutIfNeeded() From 99022006da52e49e5081a89d3ac34f23457d6efc Mon Sep 17 00:00:00 2001 From: Ryan Zhao Date: Fri, 28 Jan 2022 14:21:54 +1100 Subject: [PATCH 08/11] Make the unread message count 4 digits instead of 2 --- Session/Conversations/ConversationVC.swift | 4 ++-- Session/Shared/ConversationCell.swift | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Session/Conversations/ConversationVC.swift b/Session/Conversations/ConversationVC.swift index 1cafba6dd..85063436c 100644 --- a/Session/Conversations/ConversationVC.swift +++ b/Session/Conversations/ConversationVC.swift @@ -494,8 +494,8 @@ final class ConversationVC : BaseVC, ConversationViewModelDelegate, OWSConversat unreadViewItems.remove(at: index) } let unreadCount = unreadViewItems.count - unreadCountLabel.text = unreadCount < 100 ? "\(unreadCount)" : "99+" - let fontSize = (unreadCount < 100) ? Values.verySmallFontSize : 8 + unreadCountLabel.text = unreadCount < 10000 ? "\(unreadCount)" : "9999+" + let fontSize = (unreadCount < 10000) ? Values.verySmallFontSize : 8 unreadCountLabel.font = .boldSystemFont(ofSize: fontSize) unreadCountView.isHidden = (unreadCount == 0) } diff --git a/Session/Shared/ConversationCell.swift b/Session/Shared/ConversationCell.swift index 2a7edf38a..5f8a64c82 100644 --- a/Session/Shared/ConversationCell.swift +++ b/Session/Shared/ConversationCell.swift @@ -210,8 +210,8 @@ final class ConversationCell : UITableViewCell { isPinnedIcon.isHidden = !threadViewModel.isPinned unreadCountView.isHidden = !threadViewModel.hasUnreadMessages let unreadCount = threadViewModel.unreadCount - unreadCountLabel.text = unreadCount < 100 ? "\(unreadCount)" : "99+" - let fontSize = (unreadCount < 100) ? Values.verySmallFontSize : 8 + unreadCountLabel.text = unreadCount < 10000 ? "\(unreadCount)" : "9999+" + let fontSize = (unreadCount < 10000) ? Values.verySmallFontSize : 8 unreadCountLabel.font = .boldSystemFont(ofSize: fontSize) hasMentionView.isHidden = !(threadViewModel.hasUnreadMentions && thread.isGroupThread()) profilePictureView.update(for: thread) From c81e0e517d916ced49dd717455b1e597e703766e Mon Sep 17 00:00:00 2001 From: Ryan Zhao Date: Fri, 28 Jan 2022 15:03:19 +1100 Subject: [PATCH 09/11] fix ui issue after making unread message count 4 digits --- Session/Conversations/ConversationVC.swift | 7 +++++-- Session/Shared/ConversationCell.swift | 6 ++++-- SessionUIKit/Utilities/UIView+Constraints.swift | 13 +++++++++++++ 3 files changed, 22 insertions(+), 4 deletions(-) diff --git a/Session/Conversations/ConversationVC.swift b/Session/Conversations/ConversationVC.swift index 85063436c..c409b6112 100644 --- a/Session/Conversations/ConversationVC.swift +++ b/Session/Conversations/ConversationVC.swift @@ -112,7 +112,7 @@ final class ConversationVC : BaseVC, ConversationViewModelDelegate, OWSConversat let result = UIView() result.backgroundColor = Colors.text.withAlphaComponent(Values.veryLowOpacity) let size = ConversationVC.unreadCountViewSize - result.set(.width, to: size) + result.set(.width, greaterThanOrEqualTo: size) result.set(.height, to: size) result.layer.masksToBounds = true result.layer.cornerRadius = size / 2 @@ -192,7 +192,10 @@ final class ConversationVC : BaseVC, ConversationViewModelDelegate, OWSConversat // Unread count view view.addSubview(unreadCountView) unreadCountView.addSubview(unreadCountLabel) - unreadCountLabel.pin(to: unreadCountView) + unreadCountLabel.pin(.top, to: .top, of: unreadCountView) + unreadCountLabel.pin(.bottom, to: .bottom, of: unreadCountView) + unreadCountView.pin(.leading, to: .leading, of: unreadCountLabel, withInset: -4) + unreadCountView.pin(.trailing, to: .trailing, of: unreadCountLabel, withInset: 4) unreadCountView.centerYAnchor.constraint(equalTo: scrollButton.topAnchor).isActive = true unreadCountView.center(.horizontal, in: scrollButton) updateUnreadCountView() diff --git a/Session/Shared/ConversationCell.swift b/Session/Shared/ConversationCell.swift index 5f8a64c82..073bd8c28 100644 --- a/Session/Shared/ConversationCell.swift +++ b/Session/Shared/ConversationCell.swift @@ -23,7 +23,7 @@ final class ConversationCell : UITableViewCell { let result = UIView() result.backgroundColor = Colors.text.withAlphaComponent(Values.veryLowOpacity) let size = ConversationCell.unreadCountViewSize - result.set(.width, to: size) + result.set(.width, greaterThanOrEqualTo: size) result.set(.height, to: size) result.layer.masksToBounds = true result.layer.cornerRadius = size / 2 @@ -129,7 +129,9 @@ final class ConversationCell : UITableViewCell { profilePictureView.size = profilePictureViewSize // Unread count view unreadCountView.addSubview(unreadCountLabel) - unreadCountLabel.pin(to: unreadCountView) + unreadCountLabel.pin([ VerticalEdge.top, VerticalEdge.bottom ], to: unreadCountView) + unreadCountView.pin(.leading, to: .leading, of: unreadCountLabel, withInset: -4) + unreadCountView.pin(.trailing, to: .trailing, of: unreadCountLabel, withInset: 4) // Has mention view hasMentionView.addSubview(hasMentionLabel) hasMentionLabel.pin(to: hasMentionView) diff --git a/SessionUIKit/Utilities/UIView+Constraints.swift b/SessionUIKit/Utilities/UIView+Constraints.swift index 0dcad6829..e62e27940 100644 --- a/SessionUIKit/Utilities/UIView+Constraints.swift +++ b/SessionUIKit/Utilities/UIView+Constraints.swift @@ -95,4 +95,17 @@ public extension UIView { constraint.isActive = true return constraint } + + @discardableResult + func set(_ dimension: Dimension, greaterThanOrEqualTo size: CGFloat) -> NSLayoutConstraint { + translatesAutoresizingMaskIntoConstraints = false + let constraint: NSLayoutConstraint = { + switch dimension { + case .width: return widthAnchor.constraint(greaterThanOrEqualToConstant: size) + case .height: return heightAnchor.constraint(greaterThanOrEqualToConstant: size) + } + }() + constraint.isActive = true + return constraint + } } From ce83de5c46509b251ac665b84fc92ace70cf38fb Mon Sep 17 00:00:00 2001 From: Ryan Zhao Date: Mon, 31 Jan 2022 14:09:56 +1100 Subject: [PATCH 10/11] fix crash of dictionary.subscript.getter for closed groups --- .../Sending & Receiving/Pollers/ClosedGroupPoller.swift | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/SessionMessagingKit/Sending & Receiving/Pollers/ClosedGroupPoller.swift b/SessionMessagingKit/Sending & Receiving/Pollers/ClosedGroupPoller.swift index 00148075a..1142ff4d8 100644 --- a/SessionMessagingKit/Sending & Receiving/Pollers/ClosedGroupPoller.swift +++ b/SessionMessagingKit/Sending & Receiving/Pollers/ClosedGroupPoller.swift @@ -44,7 +44,7 @@ public final class ClosedGroupPoller : NSObject { // Might be a race condition that the setUpPolling finishes too soon, // and the timer is not created, if we mark the group as is polling // after setUpPolling. So the poller may not work, thus misses messages. - isPolling[groupPublicKey] = true + internalQueue.sync{ isPolling[groupPublicKey] = true } setUpPolling(for: groupPublicKey) } @@ -55,7 +55,7 @@ public final class ClosedGroupPoller : NSObject { } public func stopPolling(for groupPublicKey: String) { - isPolling[groupPublicKey] = false + internalQueue.sync{ isPolling[groupPublicKey] = false } timers[groupPublicKey]?.invalidate() } From 5ce7aa49ee1fb1c617504c4d17b9b45508bffa7c Mon Sep 17 00:00:00 2001 From: Ryan Zhao Date: Tue, 1 Feb 2022 15:12:48 +1100 Subject: [PATCH 11/11] mark messages with undownloaded attachments as read as well --- .../Messages/Signal/TSIncomingMessage.m | 29 +++---------------- 1 file changed, 4 insertions(+), 25 deletions(-) diff --git a/SessionMessagingKit/Messages/Signal/TSIncomingMessage.m b/SessionMessagingKit/Messages/Signal/TSIncomingMessage.m index 01769a1aa..e80bf0bdb 100644 --- a/SessionMessagingKit/Messages/Signal/TSIncomingMessage.m +++ b/SessionMessagingKit/Messages/Signal/TSIncomingMessage.m @@ -155,31 +155,10 @@ NS_ASSUME_NONNULL_BEGIN if (_read && readTimestamp >= self.expireStartedAt) { return; } - BOOL isTrusted = YES; - TSThread* thread = [self threadWithTransaction:transaction]; - if ([thread isKindOfClass:[TSContactThread class]]) { - TSContactThread* contactThread = (TSContactThread*)thread; - isTrusted = [[LKStorage shared] getContactWithSessionID:[contactThread contactSessionID] using:transaction].isTrusted; - } - - BOOL areAllAttachmentsDownloaded = YES; - if (isTrusted) { - for (NSString *attachmentId in self.attachmentIds) { - TSAttachment *attachment = [TSAttachment fetchObjectWithUniqueID:attachmentId transaction:transaction]; - // If the attachment download failed, we can mark this message as read. - // Otherwise, this message will never be marked as read. - if ([attachment isKindOfClass:[TSAttachmentPointer class]] - && ((TSAttachmentPointer *)attachment).state == TSAttachmentPointerStateFailed) { - continue; - } - areAllAttachmentsDownloaded = areAllAttachmentsDownloaded && attachment.isDownloaded; - if (!areAllAttachmentsDownloaded) break; - } - } - - if (!areAllAttachmentsDownloaded) { - return; - } + // We just ignore all attachments download state here and mark all messages as read + // This is a workaround for a situation that some large attachments won't be downloaded + // and just stuck in a downloading state. In that case, the corresponding message won't + // be able to be marked as read. _read = YES; [self saveWithTransaction:transaction];