From e78dffc3588a9b3ad295dc9e4805069d73836d5a Mon Sep 17 00:00:00 2001 From: spaced4ndy <8711996+spaced4ndy@users.noreply.github.com> Date: Tue, 7 May 2024 14:55:32 +0400 Subject: [PATCH] fix list not updating --- .../Chat/Contacts/ContactListNavLink.swift | 46 ++++++++++--------- .../Views/Chat/Contacts/ContactsView.swift | 4 +- apps/ios/Shared/Views/Home/HomeView.swift | 1 - 3 files changed, 27 insertions(+), 24 deletions(-) diff --git a/apps/ios/Shared/Views/Chat/Contacts/ContactListNavLink.swift b/apps/ios/Shared/Views/Chat/Contacts/ContactListNavLink.swift index 443f5408b6..43cc93405d 100644 --- a/apps/ios/Shared/Views/Chat/Contacts/ContactListNavLink.swift +++ b/apps/ios/Shared/Views/Chat/Contacts/ContactListNavLink.swift @@ -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) } diff --git a/apps/ios/Shared/Views/Chat/Contacts/ContactsView.swift b/apps/ios/Shared/Views/Chat/Contacts/ContactsView.swift index 2ab7ac20e7..7ab0cbb7cd 100644 --- a/apps/ios/Shared/Views/Chat/Contacts/ContactsView.swift +++ b/apps/ios/Shared/Views/Chat/Contacts/ContactsView.swift @@ -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: diff --git a/apps/ios/Shared/Views/Home/HomeView.swift b/apps/ios/Shared/Views/Home/HomeView.swift index 87aeb5ccdc..e478b337d1 100644 --- a/apps/ios/Shared/Views/Home/HomeView.swift +++ b/apps/ios/Shared/Views/Home/HomeView.swift @@ -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)