fix list not updating

This commit is contained in:
spaced4ndy
2024-05-07 14:55:32 +04:00
parent aed8c228fd
commit e78dffc358
3 changed files with 27 additions and 24 deletions
@@ -11,34 +11,38 @@ import SimpleXChat
struct ContactListNavLink: View {
@ObservedObject var chat: Chat
var contact: Contact
var body: some View {
// TODO keep bottom bar?
NavigationLink {
ChatInfoView(
chat: chat,
contact: contact,
localAlias: chat.chatInfo.localAlias
)
} label: {
HStack{
ProfileImage(imageStr: contact.image, size: 38)
.padding(.trailing, 2)
previewTitle()
if contact.contactConnIncognito {
Spacer()
Image(systemName: "theatermasks")
.resizable()
.scaledToFit()
.frame(width: 22, height: 22)
.foregroundColor(.secondary)
switch chat.chatInfo {
case let .direct(contact):
NavigationLink {
ChatInfoView(
chat: chat,
contact: contact,
localAlias: chat.chatInfo.localAlias
)
} label: {
HStack{
ProfileImage(imageStr: contact.image, size: 38)
.padding(.trailing, 2)
previewTitle(contact)
if contact.contactConnIncognito {
Spacer()
Image(systemName: "theatermasks")
.resizable()
.scaledToFit()
.frame(width: 22, height: 22)
.foregroundColor(.secondary)
}
}
}
default:
EmptyView()
}
}
@ViewBuilder private func previewTitle() -> some View {
@ViewBuilder private func previewTitle(_ contact: Contact) -> some View {
let t = Text(chat.chatInfo.chatViewName)
(
contact.verified == true
@@ -57,5 +61,5 @@ struct ContactListNavLink: View {
}
#Preview {
ContactListNavLink(chat: Chat.sampleData, contact: Contact.sampleData)
ContactListNavLink(chat: Chat.sampleData)
}
@@ -50,10 +50,10 @@ struct ContactsView: View {
.listRowSeparator(.hidden)
.frame(maxWidth: .infinity)
}
ForEach(filteredContactChats, id: \.id) { chat in
ForEach(filteredContactChats, id: \.viewId) { chat in
switch chat.chatInfo {
case let .direct(contact):
ContactListNavLink(chat: chat, contact: contact)
ContactListNavLink(chat: chat)
.scaleEffect(x: 1, y: oneHandUI ? -1 : 1, anchor: .center)
.disabled(chatModel.chatRunning != true || chatModel.deletedChats.contains(contact.id))
default:
@@ -248,7 +248,6 @@ struct HomeView: View {
}
@ViewBuilder private func contactsView() -> some View {
// TODO changing alias / verification doesn't update list
if oneHandUI {
ContactsView()
.padding(.vertical, 5)