* Fix Conversation.lastStatus nullability issue * Fix UI --------- Co-authored-by: Thomas Ricouard <ricouard77@gmail.com>
This commit is contained in:
parent
e953c243cc
commit
1c8fabbe59
|
@ -113,12 +113,14 @@ public struct ConversationDetailView: View {
|
|||
private var inputTextView: some View {
|
||||
VStack {
|
||||
HStack(alignment: .bottom, spacing: 8) {
|
||||
if viewModel.conversation.lastStatus != nil {
|
||||
Button {
|
||||
routerPath.presentedSheet = .replyToStatusEditor(status: viewModel.conversation.lastStatus)
|
||||
routerPath.presentedSheet = .replyToStatusEditor(status: viewModel.conversation.lastStatus!)
|
||||
} label: {
|
||||
Image(systemName: "plus")
|
||||
}
|
||||
.padding(.bottom, 7)
|
||||
}
|
||||
|
||||
TextField("conversations.new.message.placeholder", text: $viewModel.newMessageText, axis: .vertical)
|
||||
.focused($isMessageFieldFocused)
|
||||
|
|
|
@ -17,7 +17,7 @@ class ConversationDetailViewModel: ObservableObject {
|
|||
|
||||
init(conversation: Conversation) {
|
||||
self.conversation = conversation
|
||||
messages = [conversation.lastStatus]
|
||||
messages = conversation.lastStatus != nil ? [conversation.lastStatus!] : []
|
||||
}
|
||||
|
||||
func fetchMessages() async {
|
||||
|
@ -64,7 +64,9 @@ class ConversationDetailViewModel: ObservableObject {
|
|||
event.conversation.id == conversation.id
|
||||
{
|
||||
conversation = event.conversation
|
||||
appendNewStatus(status: conversation.lastStatus)
|
||||
if conversation.lastStatus != nil {
|
||||
appendNewStatus(status: conversation.lastStatus!)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -61,7 +61,7 @@ struct ConversationMessageView: View {
|
|||
.padding(.trailing, isOwnMessage ? 0 : 24)
|
||||
}
|
||||
|
||||
if message.id == conversation.lastStatus.id {
|
||||
if message.id == String(conversation.lastStatus?.id ?? "") {
|
||||
HStack {
|
||||
if isOwnMessage {
|
||||
Spacer()
|
||||
|
|
|
@ -31,10 +31,12 @@ struct ConversationsListRow: View {
|
|||
.foregroundColor(theme.tintColor)
|
||||
.frame(width: 10, height: 10)
|
||||
}
|
||||
Text(conversation.lastStatus.createdAt.relativeFormatted)
|
||||
if conversation.lastStatus != nil {
|
||||
Text(conversation.lastStatus!.createdAt.relativeFormatted)
|
||||
.font(.scaledFootnote)
|
||||
}
|
||||
EmojiTextApp(conversation.lastStatus.content, emojis: conversation.lastStatus.emojis)
|
||||
}
|
||||
EmojiTextApp(conversation.lastStatus?.content ?? HTMLString(stringValue: ""), emojis: conversation.lastStatus?.emojis ?? [])
|
||||
.multilineTextAlignment(.leading)
|
||||
.font(.scaledBody)
|
||||
}
|
||||
|
@ -48,9 +50,11 @@ struct ConversationsListRow: View {
|
|||
routerPath.navigate(to: .conversationDetail(conversation: conversation))
|
||||
}
|
||||
.padding(.top, 4)
|
||||
if conversation.lastStatus != nil {
|
||||
actionsView
|
||||
.padding(.bottom, 4)
|
||||
}
|
||||
}
|
||||
.contextMenu {
|
||||
contextMenu
|
||||
}
|
||||
|
@ -59,7 +63,7 @@ struct ConversationsListRow: View {
|
|||
private var actionsView: some View {
|
||||
HStack(spacing: 12) {
|
||||
Button {
|
||||
routerPath.presentedSheet = .replyToStatusEditor(status: conversation.lastStatus)
|
||||
routerPath.presentedSheet = .replyToStatusEditor(status: conversation.lastStatus!)
|
||||
} label: {
|
||||
Image(systemName: "arrowshape.turn.up.left.fill")
|
||||
}
|
||||
|
|
|
@ -64,7 +64,7 @@ class ConversationsListViewModel: ObservableObject {
|
|||
conversations.remove(at: index)
|
||||
}
|
||||
conversations.insert(event.conversation, at: 0)
|
||||
conversations = conversations.sorted(by: { $0.lastStatus.createdAt.asDate > $1.lastStatus.createdAt.asDate })
|
||||
conversations = conversations.sorted(by: { ($0.lastStatus?.createdAt.asDate ?? Date.now) > ($1.lastStatus?.createdAt.asDate ?? Date.now) })
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,7 +3,7 @@ import Foundation
|
|||
public struct Conversation: Identifiable, Decodable, Hashable, Equatable {
|
||||
public let id: String
|
||||
public let unread: Bool
|
||||
public let lastStatus: Status
|
||||
public let lastStatus: Status?
|
||||
public let accounts: [Account]
|
||||
|
||||
public static func placeholder() -> Conversation {
|
||||
|
|
Loading…
Reference in New Issue