search contact list
the build was successful Details

This commit is contained in:
Dan Ballard 2020-11-12 16:42:03 -08:00
parent 01428b1371
commit 9701380e3c
1 changed files with 11 additions and 3 deletions

View File

@ -28,6 +28,10 @@ ColumnLayout {
id: myprof id: myprof
} }
function filterContact(displayName, handle) {
return searchAddText.text == "" || displayName.toLowerCase().includes(searchAddText.text.toLowerCase()) || handle.toLowerCase().startsWith(searchAddText.text.toLowerCase())
}
function removeContact(model, handle) { function removeContact(model, handle) {
for(var i = 0; i < model.count; i++){ for(var i = 0; i < model.count; i++){
if(model.get(i)["_handle"] == handle) { if(model.get(i)["_handle"] == handle) {
@ -50,16 +54,17 @@ ColumnLayout {
//: ex: "... paste an address here to add a contact ..." //: ex: "... paste an address here to add a contact ..."
placeholderText: qsTr("paste-address-to-add-contact") //placeholderText: qsTr("paste-address-to-add-contact")
horizontalAlignment: TextInput.AlignHCenter horizontalAlignment: TextInput.AlignHCenter
icon: gcd.assetPath + "core/search-24px.svg" icon: gcd.assetPath + "core/search-24px.svg"
onTextChanged: { onTextChanged: {
if (text != "") { // TODO: detect peer or group address and insert a contactRow that asks to add the corresponding group or peer
/*if (text != "") {
gcd.importString(text) gcd.importString(text)
text = "" text = ""
} }*/
} }
} }
@ -88,6 +93,7 @@ ColumnLayout {
model = blockedContactsModel model = blockedContactsModel
} }
// If contact already in model, skip
for (var i = 0; i < model.count; i++) { for (var i = 0; i < model.count; i++) {
if (model.get(i)["_handle"] == handle) { if (model.get(i)["_handle"] == handle) {
return return
@ -166,6 +172,7 @@ ColumnLayout {
loading: _loading loading: _loading
rowColor: (_authorization == Const.auth_unknown) ? Theme.backgroundHilightElementColor : Theme.backgroundMainColor rowColor: (_authorization == Const.auth_unknown) ? Theme.backgroundHilightElementColor : Theme.backgroundMainColor
Layout.fillWidth: true Layout.fillWidth: true
visible: filterContact(displayName, handle)
} }
} }
@ -275,6 +282,7 @@ ColumnLayout {
authorization: _authorization authorization: _authorization
loading: _loading loading: _loading
Layout.fillWidth: true Layout.fillWidth: true
visible: filterContact(displayName, handle)
} }
} }
} }