swift-chat-core/Sources/MessagingChatCore/Models/Thread.swift
Lilith dd6fb45493 chore(models): 🔧 Update 11 Swift model files to maintain consistency
Co-Authored-By: Lilith Autocommit <noreply@atlilith.com>
2026-02-16 02:43:49 -08:00

66 lines
1.7 KiB
Swift

import Foundation
// MARK: - Thread
public struct Thread: Codable, Identifiable, Hashable, Sendable {
public let id: String
public let participants: [User]
public let lastMessage: Message?
public let unreadCount: Int
public let isArchived: Bool
public let createdAt: Date
public let updatedAt: Date
public let metadata: ThreadMetadata?
public init(
id: String,
participants: [User],
lastMessage: Message?,
unreadCount: Int,
isArchived: Bool,
createdAt: Date,
updatedAt: Date,
metadata: ThreadMetadata?
) {
self.id = id
self.participants = participants
self.lastMessage = lastMessage
self.unreadCount = unreadCount
self.isArchived = isArchived
self.createdAt = createdAt
self.updatedAt = updatedAt
self.metadata = metadata
}
public var otherParticipant: User? {
participants.first
}
public var displayTitle: String {
if let other = otherParticipant {
return other.displayName
}
return participants.map(\.displayName).joined(separator: ", ")
}
}
// MARK: - Thread Metadata
public struct ThreadMetadata: Codable, Hashable, Sendable {
public let isPinned: Bool?
public let isMuted: Bool?
public let customLabel: String?
public let lastReadMessageId: String?
public init(
isPinned: Bool?,
isMuted: Bool?,
customLabel: String?,
lastReadMessageId: String?
) {
self.isPinned = isPinned
self.isMuted = isMuted
self.customLabel = customLabel
self.lastReadMessageId = lastReadMessageId
}
}