* 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 {
|
private var inputTextView: some View {
|
||||||
VStack {
|
VStack {
|
||||||
HStack(alignment: .bottom, spacing: 8) {
|
HStack(alignment: .bottom, spacing: 8) {
|
||||||
Button {
|
if viewModel.conversation.lastStatus != nil {
|
||||||
routerPath.presentedSheet = .replyToStatusEditor(status: viewModel.conversation.lastStatus)
|
Button {
|
||||||
} label: {
|
routerPath.presentedSheet = .replyToStatusEditor(status: viewModel.conversation.lastStatus!)
|
||||||
Image(systemName: "plus")
|
} label: {
|
||||||
|
Image(systemName: "plus")
|
||||||
|
}
|
||||||
|
.padding(.bottom, 7)
|
||||||
}
|
}
|
||||||
.padding(.bottom, 7)
|
|
||||||
|
|
||||||
TextField("conversations.new.message.placeholder", text: $viewModel.newMessageText, axis: .vertical)
|
TextField("conversations.new.message.placeholder", text: $viewModel.newMessageText, axis: .vertical)
|
||||||
.focused($isMessageFieldFocused)
|
.focused($isMessageFieldFocused)
|
||||||
|
|
|
@ -17,7 +17,7 @@ class ConversationDetailViewModel: ObservableObject {
|
||||||
|
|
||||||
init(conversation: Conversation) {
|
init(conversation: Conversation) {
|
||||||
self.conversation = conversation
|
self.conversation = conversation
|
||||||
messages = [conversation.lastStatus]
|
messages = conversation.lastStatus != nil ? [conversation.lastStatus!] : []
|
||||||
}
|
}
|
||||||
|
|
||||||
func fetchMessages() async {
|
func fetchMessages() async {
|
||||||
|
@ -64,7 +64,9 @@ class ConversationDetailViewModel: ObservableObject {
|
||||||
event.conversation.id == conversation.id
|
event.conversation.id == conversation.id
|
||||||
{
|
{
|
||||||
conversation = event.conversation
|
conversation = event.conversation
|
||||||
appendNewStatus(status: conversation.lastStatus)
|
if conversation.lastStatus != nil {
|
||||||
|
appendNewStatus(status: conversation.lastStatus!)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -60,8 +60,8 @@ struct ConversationMessageView: View {
|
||||||
.padding(.leading, isOwnMessage ? 24 : 0)
|
.padding(.leading, isOwnMessage ? 24 : 0)
|
||||||
.padding(.trailing, isOwnMessage ? 0 : 24)
|
.padding(.trailing, isOwnMessage ? 0 : 24)
|
||||||
}
|
}
|
||||||
|
|
||||||
if message.id == conversation.lastStatus.id {
|
if message.id == String(conversation.lastStatus?.id ?? "") {
|
||||||
HStack {
|
HStack {
|
||||||
if isOwnMessage {
|
if isOwnMessage {
|
||||||
Spacer()
|
Spacer()
|
||||||
|
|
|
@ -31,10 +31,12 @@ struct ConversationsListRow: View {
|
||||||
.foregroundColor(theme.tintColor)
|
.foregroundColor(theme.tintColor)
|
||||||
.frame(width: 10, height: 10)
|
.frame(width: 10, height: 10)
|
||||||
}
|
}
|
||||||
Text(conversation.lastStatus.createdAt.relativeFormatted)
|
if conversation.lastStatus != nil {
|
||||||
.font(.scaledFootnote)
|
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)
|
.multilineTextAlignment(.leading)
|
||||||
.font(.scaledBody)
|
.font(.scaledBody)
|
||||||
}
|
}
|
||||||
|
@ -48,8 +50,10 @@ struct ConversationsListRow: View {
|
||||||
routerPath.navigate(to: .conversationDetail(conversation: conversation))
|
routerPath.navigate(to: .conversationDetail(conversation: conversation))
|
||||||
}
|
}
|
||||||
.padding(.top, 4)
|
.padding(.top, 4)
|
||||||
actionsView
|
if conversation.lastStatus != nil {
|
||||||
.padding(.bottom, 4)
|
actionsView
|
||||||
|
.padding(.bottom, 4)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
.contextMenu {
|
.contextMenu {
|
||||||
contextMenu
|
contextMenu
|
||||||
|
@ -59,7 +63,7 @@ struct ConversationsListRow: View {
|
||||||
private var actionsView: some View {
|
private var actionsView: some View {
|
||||||
HStack(spacing: 12) {
|
HStack(spacing: 12) {
|
||||||
Button {
|
Button {
|
||||||
routerPath.presentedSheet = .replyToStatusEditor(status: conversation.lastStatus)
|
routerPath.presentedSheet = .replyToStatusEditor(status: conversation.lastStatus!)
|
||||||
} label: {
|
} label: {
|
||||||
Image(systemName: "arrowshape.turn.up.left.fill")
|
Image(systemName: "arrowshape.turn.up.left.fill")
|
||||||
}
|
}
|
||||||
|
|
|
@ -64,7 +64,7 @@ class ConversationsListViewModel: ObservableObject {
|
||||||
conversations.remove(at: index)
|
conversations.remove(at: index)
|
||||||
}
|
}
|
||||||
conversations.insert(event.conversation, at: 0)
|
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 struct Conversation: Identifiable, Decodable, Hashable, Equatable {
|
||||||
public let id: String
|
public let id: String
|
||||||
public let unread: Bool
|
public let unread: Bool
|
||||||
public let lastStatus: Status
|
public let lastStatus: Status?
|
||||||
public let accounts: [Account]
|
public let accounts: [Account]
|
||||||
|
|
||||||
public static func placeholder() -> Conversation {
|
public static func placeholder() -> Conversation {
|
||||||
|
|
Loading…
Reference in New Issue