fix: 🚑 compiler issue on newer syntax (#12974)

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

## Summary by CodeRabbit

* **Refactor**
* Updated method and function signatures to accept any type conforming
to the chat cell view model protocol, improving flexibility and
extensibility of chat cell configuration and height estimation.
  * Simplified internal logic for determining text color in chat cells.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
This commit is contained in:
Lakr
2025-07-01 14:06:06 +09:00
committed by GitHub
parent f46d288b1b
commit 2be3f84196
6 changed files with 6 additions and 8 deletions

View File

@@ -21,7 +21,7 @@ extension ChatManager {
id: .init(),
content: inputBoxData.text,
timestamp: .init(),
attachments: [],
attachments: []
))
let messageParameters: [String: AnyHashable] = [

View File

@@ -84,7 +84,7 @@ class AssistantMessageCell: ChatBaseCell {
// MARK: - Configuration
override func configure(with viewModel: ChatCellViewModel) {
override func configure(with viewModel: any ChatCellViewModel) {
guard let assistantViewModel = viewModel as? AssistantMessageCellViewModel else { return }
self.viewModel = assistantViewModel

View File

@@ -76,7 +76,7 @@ class ChatBaseCell: UITableViewCell {
}
/// ViewModel
func configure(with _: ChatCellViewModel) {
func configure(with _: any ChatCellViewModel) {
//
}
@@ -91,8 +91,6 @@ class ChatBaseCell: UITableViewCell {
.systemRed
case .loading:
.secondaryLabel
default:
.label
}
}

View File

@@ -53,7 +53,7 @@ class ChatCellFactory {
// MARK: - Height Estimation
static func estimatedHeight(for viewModel: ChatCellViewModel) -> CGFloat {
static func estimatedHeight(for viewModel: any ChatCellViewModel) -> CGFloat {
switch viewModel.cellType {
case .userMessage,
.assistantMessage:

View File

@@ -63,7 +63,7 @@ class LoadingCell: ChatBaseCell {
// MARK: - Configuration
override func configure(with viewModel: ChatCellViewModel) {
override func configure(with viewModel: any ChatCellViewModel) {
guard let loadingViewModel = viewModel as? LoadingCellViewModel else { return }
self.viewModel = loadingViewModel

View File

@@ -68,7 +68,7 @@ class SystemMessageCell: ChatBaseCell {
// MARK: - Configuration
override func configure(with viewModel: ChatCellViewModel) {
override func configure(with viewModel: any ChatCellViewModel) {
guard let systemViewModel = viewModel as? SystemMessageCellViewModel else { return }
self.viewModel = systemViewModel