From 85dfd37a0c9cda79438ffa7d8dfeea7b494ff461 Mon Sep 17 00:00:00 2001 From: Nuno Vieira Date: Mon, 15 Dec 2025 15:27:42 +0000 Subject: [PATCH 1/2] Expose `ChatThreadListViewModel.preselectThreadIfNeeded()` --- .../ChatThreadListViewModel.swift | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/Sources/StreamChatSwiftUI/ChatThreadList/ChatThreadListViewModel.swift b/Sources/StreamChatSwiftUI/ChatThreadList/ChatThreadListViewModel.swift index a466da384..bc88697c3 100644 --- a/Sources/StreamChatSwiftUI/ChatThreadList/ChatThreadListViewModel.swift +++ b/Sources/StreamChatSwiftUI/ChatThreadList/ChatThreadListViewModel.swift @@ -155,6 +155,15 @@ open class ChatThreadListViewModel: ObservableObject, ChatThreadListControllerDe } } + /// Preselects the the thread if needed, for example, when inside an iPad Split View. + open func preselectThreadIfNeeded() { + guard isIPad else { return } + guard let firstThread = threads.first else { return } + guard selectedThread == nil else { return } + + selectedThread = .init(thread: firstThread) + } + public func controller( _ controller: ChatThreadListController, didChangeThreads changes: [ListChange] @@ -184,12 +193,4 @@ open class ChatThreadListViewModel: ObservableObject, ChatThreadListControllerDe private func makeDefaultEventsController() { eventsController = chatClient.eventsController() } - - private func preselectThreadIfNeeded() { - guard isIPad else { return } - guard let firstThread = threads.first else { return } - guard selectedThread == nil else { return } - - selectedThread = .init(thread: firstThread) - } } From 9d5031871a95b7ebb507193ea8ca154dd531abda Mon Sep 17 00:00:00 2001 From: Nuno Vieira Date: Mon, 15 Dec 2025 15:31:57 +0000 Subject: [PATCH 2/2] Update CHANGELOG.md --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 47d7c4a51..0d3d107ca 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). ### ✅ Added - Open `ChatChannelInfoViewModel.leaveButtonTitle` and `ChatChannelInfoViewModel.leaveConversationDescription` [#1018](https://github.com/GetStream/stream-chat-swiftui/pull/1018) +- Open `ChatThreadListViewModel.preselectThreadIfNeeded()` [#1069](https://github.com/GetStream/stream-chat-swiftui/pull/1069) ### 🐞 Fixed - Use `muteChannel` capability for showing mute channel button in the `ChatChannelInfoView` [#1018](https://github.com/GetStream/stream-chat-swiftui/pull/1018) - Fix `PollOptionAllVotesViewModel` not loading more votes [#1067](https://github.com/GetStream/stream-chat-swiftui/pull/1067)