mirror of
https://gitlab.linphone.org/BC/public/linphone-iphone.git
synced 2026-05-07 05:53:06 +00:00
Fix conversation unread counters
This commit is contained in:
parent
1e16dbaa61
commit
088f3a7506
3 changed files with 42 additions and 44 deletions
|
|
@ -35,46 +35,47 @@ struct ContactFragment: View {
|
|||
|
||||
var body: some View {
|
||||
let indexDisplayed = contactViewModel.indexDisplayedFriend != nil ? contactViewModel.indexDisplayedFriend! : 0
|
||||
if #available(iOS 16.0, *), idiom != .pad {
|
||||
ContactInnerFragment(
|
||||
contactAvatarModel: ContactsManager.shared.avatarListModel[indexDisplayed],
|
||||
contactViewModel: contactViewModel,
|
||||
editContactViewModel: editContactViewModel,
|
||||
cnContact: CNContact(),
|
||||
isShowDeletePopup: $isShowDeletePopup,
|
||||
showingSheet: $showingSheet,
|
||||
showShareSheet: $showShareSheet,
|
||||
isShowDismissPopup: $isShowDismissPopup
|
||||
)
|
||||
.sheet(isPresented: $showingSheet) {
|
||||
ContactListBottomSheet(contactViewModel: contactViewModel, showingSheet: $showingSheet)
|
||||
.presentationDetents([.fraction(0.2)])
|
||||
}
|
||||
.sheet(isPresented: $showShareSheet) {
|
||||
ShareSheet(friendToShare: ContactsManager.shared.lastSearch[contactViewModel.indexDisplayedFriend!].friend!)
|
||||
.presentationDetents([.medium])
|
||||
.edgesIgnoringSafeArea(.bottom)
|
||||
}
|
||||
} else {
|
||||
ContactInnerFragment(
|
||||
contactAvatarModel: ContactsManager.shared.avatarListModel[indexDisplayed],
|
||||
contactViewModel: contactViewModel,
|
||||
editContactViewModel: editContactViewModel,
|
||||
cnContact: CNContact(),
|
||||
isShowDeletePopup: $isShowDeletePopup,
|
||||
showingSheet: $showingSheet,
|
||||
showShareSheet: $showShareSheet,
|
||||
isShowDismissPopup: $isShowDismissPopup
|
||||
)
|
||||
.halfSheet(showSheet: $showingSheet) {
|
||||
ContactListBottomSheet(contactViewModel: contactViewModel, showingSheet: $showingSheet)
|
||||
} onDismiss: {}
|
||||
if ContactsManager.shared.avatarListModel.count > indexDisplayed {
|
||||
if #available(iOS 16.0, *), idiom != .pad {
|
||||
ContactInnerFragment(
|
||||
contactAvatarModel: ContactsManager.shared.avatarListModel[indexDisplayed],
|
||||
contactViewModel: contactViewModel,
|
||||
editContactViewModel: editContactViewModel,
|
||||
cnContact: CNContact(),
|
||||
isShowDeletePopup: $isShowDeletePopup,
|
||||
showingSheet: $showingSheet,
|
||||
showShareSheet: $showShareSheet,
|
||||
isShowDismissPopup: $isShowDismissPopup
|
||||
)
|
||||
.sheet(isPresented: $showingSheet) {
|
||||
ContactListBottomSheet(contactViewModel: contactViewModel, showingSheet: $showingSheet)
|
||||
.presentationDetents([.fraction(0.2)])
|
||||
}
|
||||
.sheet(isPresented: $showShareSheet) {
|
||||
ShareSheet(friendToShare: ContactsManager.shared.lastSearch[contactViewModel.indexDisplayedFriend!].friend!)
|
||||
.presentationDetents([.medium])
|
||||
.edgesIgnoringSafeArea(.bottom)
|
||||
}
|
||||
} else {
|
||||
ContactInnerFragment(
|
||||
contactAvatarModel: ContactsManager.shared.avatarListModel[indexDisplayed],
|
||||
contactViewModel: contactViewModel,
|
||||
editContactViewModel: editContactViewModel,
|
||||
cnContact: CNContact(),
|
||||
isShowDeletePopup: $isShowDeletePopup,
|
||||
showingSheet: $showingSheet,
|
||||
showShareSheet: $showShareSheet,
|
||||
isShowDismissPopup: $isShowDismissPopup
|
||||
)
|
||||
.halfSheet(showSheet: $showingSheet) {
|
||||
ContactListBottomSheet(contactViewModel: contactViewModel, showingSheet: $showingSheet)
|
||||
} onDismiss: {}
|
||||
.sheet(isPresented: $showShareSheet) {
|
||||
ShareSheet(friendToShare: ContactsManager.shared.lastSearch[contactViewModel.indexDisplayedFriend!].friend!)
|
||||
.edgesIgnoringSafeArea(.bottom)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -112,11 +112,9 @@ class ConversationModel: ObservableObject {
|
|||
let unreadMessagesCountTmp = self.chatRoom.unreadMessagesCount
|
||||
if unreadMessagesCountTmp > 0 {
|
||||
self.chatRoom.markAsRead()
|
||||
}
|
||||
|
||||
DispatchQueue.main.async {
|
||||
if self.unreadMessagesCount != unreadMessagesCountTmp {
|
||||
self.unreadMessagesCount = unreadMessagesCountTmp
|
||||
|
||||
DispatchQueue.main.async {
|
||||
self.unreadMessagesCount = 0
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -89,10 +89,9 @@ class ConversationViewModel: ObservableObject {
|
|||
|
||||
if unreadMessagesCount > 0 {
|
||||
self.displayedConversation!.chatRoom.markAsRead()
|
||||
}
|
||||
DispatchQueue.main.async {
|
||||
if self.displayedConversationUnreadMessagesCount != unreadMessagesCount {
|
||||
self.displayedConversationUnreadMessagesCount = unreadMessagesCount
|
||||
|
||||
DispatchQueue.main.async {
|
||||
self.displayedConversationUnreadMessagesCount = 0
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue