diff --git a/Signal/src/ViewControllers/HomeView/Chat List/CLVRenderState.swift b/Signal/src/ViewControllers/HomeView/Chat List/CLVRenderState.swift index ce51f9bc52..502cacfee0 100644 --- a/Signal/src/ViewControllers/HomeView/Chat List/CLVRenderState.swift +++ b/Signal/src/ViewControllers/HomeView/Chat List/CLVRenderState.swift @@ -175,7 +175,9 @@ struct CLVRenderState { func indexPath(afterThread thread: TSThread?) -> IndexPath? { let section: (index: Int, threadUniqueIds: KeyPath) - if let thread = thread, pinnedThreadUniqueIds.contains(thread.uniqueId) { + let threadIsPinned = thread.map { pinnedThreadUniqueIds.contains($0.uniqueId) } == true + let noThreadSelectedAndHasPinnedThreads = thread == nil && !pinnedThreadUniqueIds.isEmpty + if threadIsPinned || noThreadSelectedAndHasPinnedThreads { let index = sectionIndex(for: .pinned)! section = (index, sections[index].threadUniqueIds!) } else { @@ -193,6 +195,12 @@ struct CLVRenderState { if index < (self[keyPath: section.threadUniqueIds].count - 1) { return IndexPath(item: index + 1, section: section.index) + } else if + let nextSection = sections[safe: section.index + 1], + let nextSectionThreads = nextSection.threadUniqueIds, + !self[keyPath: nextSectionThreads].isEmpty + { + return IndexPath(item: 0, section: section.index + 1) } else { return nil } @@ -201,7 +209,9 @@ struct CLVRenderState { func indexPath(beforeThread thread: TSThread?) -> IndexPath? { let section: (index: Int, threadUniqueIds: KeyPath) - if let thread = thread, pinnedThreadUniqueIds.contains(thread.uniqueId) { + let threadIsPinned = thread.map { pinnedThreadUniqueIds.contains($0.uniqueId) } == true + let allChatsArePinned = unpinnedThreadUniqueIds.isEmpty + if threadIsPinned || allChatsArePinned { let index = sectionIndex(for: .pinned)! section = (index, sections[index].threadUniqueIds!) } else { @@ -220,6 +230,12 @@ struct CLVRenderState { if index > 0 { return IndexPath(item: index - 1, section: section.index) + } else if + let previousSection = sections[safe: section.index - 1], + let previousSectionThreads = previousSection.threadUniqueIds, + !self[keyPath: previousSectionThreads].isEmpty + { + return IndexPath(item: self[keyPath: previousSectionThreads].count - 1, section: section.index - 1) } else { return nil } diff --git a/Signal/src/ViewControllers/HomeView/Chat List/ChatListViewController.swift b/Signal/src/ViewControllers/HomeView/Chat List/ChatListViewController.swift index 1a0cf47a64..1027e19c95 100644 --- a/Signal/src/ViewControllers/HomeView/Chat List/ChatListViewController.swift +++ b/Signal/src/ViewControllers/HomeView/Chat List/ChatListViewController.swift @@ -59,6 +59,7 @@ public class ChatListViewController: OWSViewController, HomeTabViewController { tableView.estimatedRowHeight = 60 tableView.allowsSelectionDuringEditing = true tableView.allowsMultipleSelectionDuringEditing = true + tableView.selectionFollowsFocus = false if let filterControl { filterControl.clearAction = .disableChatListFilter(target: self) diff --git a/Signal/src/ViewControllers/HomeView/ConversationSplitViewController.swift b/Signal/src/ViewControllers/HomeView/ConversationSplitViewController.swift index 8a3f51ffa6..c53d698ea9 100644 --- a/Signal/src/ViewControllers/HomeView/ConversationSplitViewController.swift +++ b/Signal/src/ViewControllers/HomeView/ConversationSplitViewController.swift @@ -412,7 +412,29 @@ class ConversationSplitViewController: UISplitViewController, ConversationSplit comment: "A keyboard command to jump to the next conversation in the list." ) ) - ] + ] + [ + UIKeyCommand( + action: #selector(selectPreviousConversation), + input: "\t", + modifierFlags: [.control, .shift], + discoverabilityTitle: OWSLocalizedString( + "KEY_COMMAND_PREVIOUS_CONVERSATION", + comment: "A keyboard command to jump to the previous conversation in the list." + ) + ), + UIKeyCommand( + action: #selector(selectNextConversation), + input: "\t", + modifierFlags: .control, + discoverabilityTitle: OWSLocalizedString( + "KEY_COMMAND_NEXT_CONVERSATION", + comment: "A keyboard command to jump to the next conversation in the list." + ) + ), + ].map { + $0.wantsPriorityOverSystemBehavior = true + return $0 + } var selectedConversationKeyCommands: [UIKeyCommand] { return [