Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<ChatThread>]
Expand Down Expand Up @@ -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)
}
}
Loading