mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-09-07 01:09:54 +08:00
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:
+1
-1
@@ -21,7 +21,7 @@ extension ChatManager {
|
|||||||
id: .init(),
|
id: .init(),
|
||||||
content: inputBoxData.text,
|
content: inputBoxData.text,
|
||||||
timestamp: .init(),
|
timestamp: .init(),
|
||||||
attachments: [],
|
attachments: []
|
||||||
))
|
))
|
||||||
|
|
||||||
let messageParameters: [String: AnyHashable] = [
|
let messageParameters: [String: AnyHashable] = [
|
||||||
|
|||||||
+1
-1
@@ -84,7 +84,7 @@ class AssistantMessageCell: ChatBaseCell {
|
|||||||
|
|
||||||
// MARK: - Configuration
|
// MARK: - Configuration
|
||||||
|
|
||||||
override func configure(with viewModel: ChatCellViewModel) {
|
override func configure(with viewModel: any ChatCellViewModel) {
|
||||||
guard let assistantViewModel = viewModel as? AssistantMessageCellViewModel else { return }
|
guard let assistantViewModel = viewModel as? AssistantMessageCellViewModel else { return }
|
||||||
self.viewModel = assistantViewModel
|
self.viewModel = assistantViewModel
|
||||||
|
|
||||||
|
|||||||
+1
-3
@@ -76,7 +76,7 @@ class ChatBaseCell: UITableViewCell {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// 配置 ViewModel,子类需要重写
|
/// 配置 ViewModel,子类需要重写
|
||||||
func configure(with _: ChatCellViewModel) {
|
func configure(with _: any ChatCellViewModel) {
|
||||||
// 子类实现
|
// 子类实现
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -91,8 +91,6 @@ class ChatBaseCell: UITableViewCell {
|
|||||||
.systemRed
|
.systemRed
|
||||||
case .loading:
|
case .loading:
|
||||||
.secondaryLabel
|
.secondaryLabel
|
||||||
default:
|
|
||||||
.label
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -53,7 +53,7 @@ class ChatCellFactory {
|
|||||||
|
|
||||||
// MARK: - Height Estimation
|
// MARK: - Height Estimation
|
||||||
|
|
||||||
static func estimatedHeight(for viewModel: ChatCellViewModel) -> CGFloat {
|
static func estimatedHeight(for viewModel: any ChatCellViewModel) -> CGFloat {
|
||||||
switch viewModel.cellType {
|
switch viewModel.cellType {
|
||||||
case .userMessage,
|
case .userMessage,
|
||||||
.assistantMessage:
|
.assistantMessage:
|
||||||
|
|||||||
+1
-1
@@ -63,7 +63,7 @@ class LoadingCell: ChatBaseCell {
|
|||||||
|
|
||||||
// MARK: - Configuration
|
// MARK: - Configuration
|
||||||
|
|
||||||
override func configure(with viewModel: ChatCellViewModel) {
|
override func configure(with viewModel: any ChatCellViewModel) {
|
||||||
guard let loadingViewModel = viewModel as? LoadingCellViewModel else { return }
|
guard let loadingViewModel = viewModel as? LoadingCellViewModel else { return }
|
||||||
self.viewModel = loadingViewModel
|
self.viewModel = loadingViewModel
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -68,7 +68,7 @@ class SystemMessageCell: ChatBaseCell {
|
|||||||
|
|
||||||
// MARK: - Configuration
|
// MARK: - Configuration
|
||||||
|
|
||||||
override func configure(with viewModel: ChatCellViewModel) {
|
override func configure(with viewModel: any ChatCellViewModel) {
|
||||||
guard let systemViewModel = viewModel as? SystemMessageCellViewModel else { return }
|
guard let systemViewModel = viewModel as? SystemMessageCellViewModel else { return }
|
||||||
self.viewModel = systemViewModel
|
self.viewModel = systemViewModel
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user