Allow add-contact UI when disableAddContact is disabled

This commit is contained in:
Benoit Martins 2025-12-17 15:36:54 +01:00
parent d4b10d38ae
commit 4cd63b53b2
7 changed files with 148 additions and 120 deletions

View file

@ -141,6 +141,15 @@ class CorePreferences {
}
}
static var disableAddContact: Bool {
get {
return Config.get().getBool(section: "ui", key: "disable_add_contact", defaultValue: false)
}
set {
Config.get().setBool(section: "ui", key: "disable_add_contact", value: newValue)
}
}
static var showFavoriteContacts: Bool {
get {
return Config.get().getBool(section: "ui", key: "show_favorites_contacts", defaultValue: true)

View file

@ -2,6 +2,6 @@ import Foundation
public enum AppGitInfo {
public static let branch = "master"
public static let commit = "6827bdc1d"
public static let commit = "d4b10d38a"
public static let tag = "6.1.0-alpha"
}

View file

@ -32,6 +32,7 @@ struct ContactsView: View {
ZStack(alignment: .bottomTrailing) {
ContactsFragment(isShowDeletePopup: $isShowDeletePopup, text: $text)
if !CorePreferences.disableAddContact {
Button {
withAnimation {
contactsListViewModel.selectedEditFriend = nil
@ -48,6 +49,7 @@ struct ContactsView: View {
}
.padding()
}
// For testing crashlytics
/*Button(action: CoreContext.shared.crashForCrashlytics, label: {

View file

@ -353,6 +353,14 @@ struct ConversationInfoFragment: View {
if conversationViewModel.myParticipantConversationModel != nil && conversationViewModel.myParticipantConversationModel!.address != participantConversationModel.address {
Menu {
let addressConv = participantConversationModel.address
let friendIndex = contactsManager.lastSearch.firstIndex(
where: {$0.friend!.addresses.contains(where: {$0.asStringUriOnly() == addressConv})})
let disableAddContact = CorePreferences.disableAddContact
if (!disableAddContact || (disableAddContact && friendIndex != nil)) {
Button(
action: {
let addressConv = participantConversationModel.address
@ -376,10 +384,6 @@ struct ConversationInfoFragment: View {
},
label: {
HStack {
let addressConv = participantConversationModel.address
let friendIndex = contactsManager.lastSearch.firstIndex(
where: {$0.friend!.addresses.contains(where: {$0.asStringUriOnly() == addressConv})})
if friendIndex != nil {
Image("address-book")
.renderingMode(.template)
@ -406,6 +410,7 @@ struct ConversationInfoFragment: View {
}
}
)
}
if conversationViewModel.isUserAdmin {
let participantConversationModelIsAdmin = conversationViewModel.participantConversationModelAdmin.first(
@ -527,7 +532,14 @@ struct ConversationInfoFragment: View {
VStack(spacing: 0) {
if !SharedMainViewModel.shared.displayedConversation!.isReadOnly {
if !SharedMainViewModel.shared.displayedConversation!.isGroup {
let addressConv = conversationViewModel.participantConversationModel.first?.address ?? ""
let friendIndex = contactsManager.lastSearch.firstIndex(
where: {$0.friend!.addresses.contains(where: {$0.asStringUriOnly() == addressConv})})
let disableAddContact = CorePreferences.disableAddContact
if !SharedMainViewModel.shared.displayedConversation!.isGroup && (!disableAddContact || (disableAddContact && friendIndex != nil)) {
Button(
action: {
if SharedMainViewModel.shared.displayedConversation != nil {
@ -555,10 +567,6 @@ struct ConversationInfoFragment: View {
},
label: {
HStack {
let addressConv = conversationViewModel.participantConversationModel.first?.address ?? ""
let friendIndex = contactsManager.lastSearch.firstIndex(
where: {$0.friend!.addresses.contains(where: {$0.asStringUriOnly() == addressConv})})
if friendIndex != nil {
Image("address-book")
.renderingMode(.template)

View file

@ -70,7 +70,10 @@ struct HistoryContactFragment: View {
Spacer()
Menu {
if !historyModel.isConf {
let disableAddContact = CorePreferences.disableAddContact
let isFriend = historyModel.isFriend == true
if !historyModel.isConf && (!disableAddContact || (disableAddContact && isFriend)) {
Button {
isMenuOpen = false

View file

@ -58,6 +58,11 @@ struct HistoryListBottomSheet: View {
}
Spacer()
let disableAddContact = CorePreferences.disableAddContact
let isFriend = historyListViewModel.selectedCall?.isFriend == true
if !disableAddContact || (disableAddContact && isFriend) {
Button {
if #available(iOS 16.0, *) {
@ -120,6 +125,7 @@ struct HistoryListBottomSheet: View {
Divider()
}
.frame(maxWidth: .infinity)
}
Button {
if historyListViewModel.selectedCall != nil && historyListViewModel.selectedCall!.isOutgoing {

View file

@ -124,7 +124,7 @@
"location" : "https://gitlab.linphone.org/BC/public/linphone-sdk-swift-ios.git",
"state" : {
"branch" : "alpha",
"revision" : "0dc2d9ef5b2e1e1868e3e6143a89a7ba9d983ea6"
"revision" : "1e266452f9e464d8d6ea8359722d9038c5f46b9d"
}
},
{