diff --git a/Signal.xcodeproj/project.pbxproj b/Signal.xcodeproj/project.pbxproj index 80f0534bee..a40f3a002b 100644 --- a/Signal.xcodeproj/project.pbxproj +++ b/Signal.xcodeproj/project.pbxproj @@ -1885,7 +1885,6 @@ D994C7C92C45D0B9009ECEDA /* MessageBackupContactTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = D994C7C52C45D07F009ECEDA /* MessageBackupContactTest.swift */; }; D994C7CA2C45D0BF009ECEDA /* MessageBackupDistributionListTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = D994C7C72C45D0B4009ECEDA /* MessageBackupDistributionListTest.swift */; }; D994C7CE2C45D100009ECEDA /* MessageBackupExpirationTimerChatUpdateTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = D994C7CD2C45D100009ECEDA /* MessageBackupExpirationTimerChatUpdateTest.swift */; }; - D994C7CF2C45D152009ECEDA /* MessageBackupSimpleChatUpdateTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = D994C7CB2C45D0D9009ECEDA /* MessageBackupSimpleChatUpdateTest.swift */; }; D994C7D12C45D24F009ECEDA /* MessageBackupProfileChangeChatUpdateArchiver.swift in Sources */ = {isa = PBXBuildFile; fileRef = D994C7D02C45D24F009ECEDA /* MessageBackupProfileChangeChatUpdateArchiver.swift */; }; D994C7D42C45E765009ECEDA /* profile-change-chat-update-message.jsonproto in Resources */ = {isa = PBXBuildFile; fileRef = D994C7D22C45E764009ECEDA /* profile-change-chat-update-message.jsonproto */; }; D994C7D52C45E765009ECEDA /* profile-change-chat-update-message.binproto in Resources */ = {isa = PBXBuildFile; fileRef = D994C7D32C45E764009ECEDA /* profile-change-chat-update-message.binproto */; }; @@ -1904,7 +1903,6 @@ D99ABC742A3D0BE10034CD3B /* BitmapsImageParsingTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = D99ABC722A3D0BBB0034CD3B /* BitmapsImageParsingTest.swift */; }; D99ABC782A3D132D0034CD3B /* blue-rectangle.png in Resources */ = {isa = PBXBuildFile; fileRef = D99ABC762A3D132D0034CD3B /* blue-rectangle.png */; }; D99ABC7A2A3D1D710034CD3B /* semitransparent.png in Resources */ = {isa = PBXBuildFile; fileRef = D99ABC792A3D1D710034CD3B /* semitransparent.png */; }; - D99C25A22C2A18C1001B2012 /* ConversationViewIsSelectedDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = D99C25A12C2A18C1001B2012 /* ConversationViewIsSelectedDelegate.swift */; }; D99D960F292871C600D5028B /* DonateViewController+OneTimePaypalDonation.swift in Sources */ = {isa = PBXBuildFile; fileRef = D99D960E292871C600D5028B /* DonateViewController+OneTimePaypalDonation.swift */; }; D9A3E22B2A0D633500E2A8B5 /* UsernameLookupRecordTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = D925F56F298DF41B00158EE4 /* UsernameLookupRecordTest.swift */; }; D9A3E2302A0DABDF00E2A8B5 /* UsernameQuerier.swift in Sources */ = {isa = PBXBuildFile; fileRef = D9A3E22F2A0DABDF00E2A8B5 /* UsernameQuerier.swift */; }; @@ -4959,7 +4957,6 @@ D99ABC722A3D0BBB0034CD3B /* BitmapsImageParsingTest.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BitmapsImageParsingTest.swift; sourceTree = ""; }; D99ABC762A3D132D0034CD3B /* blue-rectangle.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "blue-rectangle.png"; sourceTree = ""; }; D99ABC792A3D1D710034CD3B /* semitransparent.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = semitransparent.png; sourceTree = ""; }; - D99C25A12C2A18C1001B2012 /* ConversationViewIsSelectedDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ConversationViewIsSelectedDelegate.swift; sourceTree = ""; }; D99D960E292871C600D5028B /* DonateViewController+OneTimePaypalDonation.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "DonateViewController+OneTimePaypalDonation.swift"; sourceTree = ""; }; D9A3E22F2A0DABDF00E2A8B5 /* UsernameQuerier.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UsernameQuerier.swift; sourceTree = ""; }; D9A81C6A2BAA54FC00C07D2B /* CallRecordSyncMessageConversationIdAdapter.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CallRecordSyncMessageConversationIdAdapter.swift; sourceTree = ""; }; @@ -6290,7 +6287,6 @@ 88928A70264099EC009C9B30 /* ConversationViewController+VoiceMessage.swift */, 888B6D4C25B2523700E2A662 /* ConversationViewController+Wallpaper.swift */, 34A4D88C267A363A00A794E7 /* ConversationViewController.swift */, - D99C25A12C2A18C1001B2012 /* ConversationViewIsSelectedDelegate.swift */, 3498AC9E25190E8B00B1F315 /* ConversationViewLayout.swift */, 50EF8DCB2A189B3000A00935 /* ConversationViewModel.swift */, 348815CF25545C0A00D4F4C4 /* CVAttachments.swift */, @@ -13417,7 +13413,6 @@ 88928A71264099EC009C9B30 /* ConversationViewController+VoiceMessage.swift in Sources */, 888B6D4D25B2523800E2A662 /* ConversationViewController+Wallpaper.swift in Sources */, 34A4D88D267A363A00A794E7 /* ConversationViewController.swift in Sources */, - D99C25A22C2A18C1001B2012 /* ConversationViewIsSelectedDelegate.swift in Sources */, 3498AC9F25190E8C00B1F315 /* ConversationViewLayout.swift in Sources */, 50EF8DCC2A189B3000A00935 /* ConversationViewModel.swift in Sources */, 50733B202BAD03E400CEEC1F /* CreateCallLinkViewController.swift in Sources */, diff --git a/Signal/ConversationView/ConversationViewController+Misc.swift b/Signal/ConversationView/ConversationViewController+Misc.swift index 1d544274e4..90f576889f 100644 --- a/Signal/ConversationView/ConversationViewController+Misc.swift +++ b/Signal/ConversationView/ConversationViewController+Misc.swift @@ -340,8 +340,6 @@ extension ConversationViewController { public func startReadTimer(caller: String = #function) { AssertIsOnMainThread() - markAsReadLogger.info("Starting read timer for \(caller).") - readTimer?.invalidate() let readTimer = Timer(timeInterval: 0.1, repeats: true) { [weak self] timer in guard let self else { @@ -371,8 +369,6 @@ extension ConversationViewController { public func cancelReadTimer(caller: String = #function) { AssertIsOnMainThread() - markAsReadLogger.info("Canceling read timer for \(caller).") - readTimer?.invalidate() self.readTimer = nil } @@ -444,22 +440,6 @@ extension ConversationViewController { public func markVisibleMessagesAsRead(caller: String = #function) { AssertIsOnMainThread() - guard - let isSelectedDelegate, - isSelectedDelegate.isConversationViewSelected(self) - else { - /// We've seen reports of conversation views marking messages as - /// read while users are on the chat list, which is to say even when - /// the given conversation isn't "selected". (We're not sure why, - /// although we suspect that something is holding onto a reference - /// to a CVC it shouldn't.) - /// - /// This workaround confirms that we are, in fact, selected before - /// trying to mark messages as read. - markAsReadLogger.warn("Trying to mark visible messages as read, but conversation view is not selected! \(caller)") - return - } - guard let navigationController, navigationController.topViewController === self @@ -483,8 +463,6 @@ extension ConversationViewController { let lastVisibleSortId = self.lastVisibleSortId let isShowingUnreadMessage = lastVisibleSortId > self.lastSortIdMarkedRead if !self.isMarkingAsRead && isShowingUnreadMessage { - markAsReadLogger.info("Marking as read for \(caller).") - self.isMarkingAsRead = true Self.receiptManager.markAsReadLocally( diff --git a/Signal/ConversationView/ConversationViewController.swift b/Signal/ConversationView/ConversationViewController.swift index c2cca43c6c..c2d3ee52cf 100644 --- a/Signal/ConversationView/ConversationViewController.swift +++ b/Signal/ConversationView/ConversationViewController.swift @@ -44,23 +44,10 @@ public final class ConversationViewController: OWSViewController { public let collectionView: ConversationCollectionView public let searchController: ConversationSearchController - /// A delegate we can ask about our visibility to the user. If the delegate - /// is `nil`, we should assume we are not visible. - public weak var isSelectedDelegate: ConversationViewIsSelectedDelegate? - var selectionToolbar: MessageActionsToolbar? var otherUsersProfileDidChangeEvent: DebouncedEvent? - class MarkAsReadLogger: PrefixedLogger { - init(thread: TSThread) { - super.init(prefix: "[MarkAsRead]", suffix: thread.uniqueId) - } - } - - // [MarkAsRead] TODO: using this logger to track down the phantom "mark as read" bug. Remove once addressed. - let markAsReadLogger: MarkAsReadLogger - /// See `ConversationViewController+OWS.updateContentInsetsDebounced` lazy var updateContentInsetsEvent = DebouncedEvents.build( mode: .lastOnly, @@ -76,7 +63,6 @@ public final class ConversationViewController: OWSViewController { public static func load( threadViewModel: ThreadViewModel, - isSelectedDelegate: (any ConversationViewIsSelectedDelegate)?, action: ConversationViewAction, focusMessageId: String?, tx: SDSAnyReadTransaction @@ -127,7 +113,6 @@ public final class ConversationViewController: OWSViewController { chatColor: chatColor, wallpaperViewBuilder: wallpaperViewBuilder ) - cvc.isSelectedDelegate = isSelectedDelegate return cvc } @@ -173,8 +158,6 @@ public final class ConversationViewController: OWSViewController { self.collectionView = ConversationCollectionView(frame: .zero, collectionViewLayout: self.layout) self.searchController = ConversationSearchController(thread: threadViewModel.threadRecord) - self.markAsReadLogger = MarkAsReadLogger(thread: threadViewModel.threadRecord) - super.init() self.viewState.delegate = self diff --git a/Signal/ConversationView/ConversationViewIsSelectedDelegate.swift b/Signal/ConversationView/ConversationViewIsSelectedDelegate.swift deleted file mode 100644 index c104786b16..0000000000 --- a/Signal/ConversationView/ConversationViewIsSelectedDelegate.swift +++ /dev/null @@ -1,24 +0,0 @@ -// -// Copyright 2024 Signal Messenger, LLC -// SPDX-License-Identifier: AGPL-3.0-only -// - -/// Responsible for telling a ``ConversationViewController`` if it is currently -/// selected by the user. -/// -/// - Note -/// Even if a given conversation is selected, it may have additionally presented -/// other views (such as conversation settings) on top of itself. -public protocol ConversationViewIsSelectedDelegate: AnyObject { - func isConversationViewSelected(_ conversationView: ConversationViewController) -> Bool -} - -extension ConversationSplitViewController: ConversationViewIsSelectedDelegate { - func isConversationViewSelected(_ conversationView: ConversationViewController) -> Bool { - guard let selectedConversationViewController else { - return false - } - - return selectedConversationViewController === conversationView - } -} diff --git a/Signal/src/ViewControllers/HomeView/Chat List/ChatListViewController+Helpers.swift b/Signal/src/ViewControllers/HomeView/Chat List/ChatListViewController+Helpers.swift index 2a32839f8b..08a8ca15e9 100644 --- a/Signal/src/ViewControllers/HomeView/Chat List/ChatListViewController+Helpers.swift +++ b/Signal/src/ViewControllers/HomeView/Chat List/ChatListViewController+Helpers.swift @@ -171,7 +171,6 @@ extension ChatListViewController { let vc = databaseStorage.read { tx in ConversationViewController.load( threadViewModel: threadViewModel, - isSelectedDelegate: nil, action: .none, focusMessageId: nil, tx: tx diff --git a/Signal/src/ViewControllers/HomeView/ConversationSplitViewController.swift b/Signal/src/ViewControllers/HomeView/ConversationSplitViewController.swift index 5fa4aa1315..bfe1ce0dea 100644 --- a/Signal/src/ViewControllers/HomeView/ConversationSplitViewController.swift +++ b/Signal/src/ViewControllers/HomeView/ConversationSplitViewController.swift @@ -168,7 +168,6 @@ class ConversationSplitViewController: UISplitViewController, ConversationSplit let vc = databaseStorage.read { tx in ConversationViewController.load( threadViewModel: ThreadViewModel(thread: thread, forChatList: false, transaction: tx), - isSelectedDelegate: self, action: action, focusMessageId: focusMessageId, tx: tx