mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-15 05:37:32 +00: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:
@@ -21,7 +21,7 @@ extension ChatManager {
|
||||
id: .init(),
|
||||
content: inputBoxData.text,
|
||||
timestamp: .init(),
|
||||
attachments: [],
|
||||
attachments: []
|
||||
))
|
||||
|
||||
let messageParameters: [String: AnyHashable] = [
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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:
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user