Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion src/components/ContactsList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@
RouterMixin,
],

components: {

Check warning on line 99 in src/components/ContactsList.vue

View workflow job for this annotation

GitHub Actions / NPM lint

The "components" property should be above the "mixins" property on line 95
AppContentList,
NcNoteCard,
VirtualList,
Expand Down Expand Up @@ -262,12 +262,19 @@
/**
* Is this matching the current search ?
*
* @param {Contact} contact the contact to search

Check warning on line 265 in src/components/ContactsList.vue

View workflow job for this annotation

GitHub Actions / NPM lint

The type 'Contact' is undefined
* @return {boolean}
*/
matchSearch(contact) {
if (this.query.trim() !== '') {
return contact.searchData.toString().toLowerCase().search(this.query.trim().toLowerCase()) !== -1
try {
return contact.searchData.toString().toLowerCase().search(this.query.trim().toLowerCase()) !== -1
} catch (e) {
if (e instanceof SyntaxError) {
// this.query likely is an invalid regex (i.e. just `+`)
return contact.searchData.toString().toLowerCase().includes(this.query.trim().toLowerCase())
}
}
}
return true
},
Expand Down
18 changes: 16 additions & 2 deletions src/models/contact.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ const isEmpty = value => {
export const ContactKindProperties = ['KIND', 'X-ADDRESSBOOKSERVER-KIND']

export const MinimalContactProperties = [
'EMAIL', 'UID', 'CATEGORIES', 'FN', 'ORG', 'N', 'X-PHONETIC-FIRST-NAME', 'X-PHONETIC-LAST-NAME', 'X-MANAGERSNAME', 'TITLE', 'NOTE', 'RELATED',
'EMAIL', 'UID', 'TEL', 'CATEGORIES', 'FN', 'ORG', 'N', 'X-PHONETIC-FIRST-NAME', 'X-PHONETIC-LAST-NAME', 'X-MANAGERSNAME', 'TITLE', 'NOTE', 'RELATED',
].concat(ContactKindProperties)

export default class Contact {
Expand Down Expand Up @@ -580,7 +580,21 @@ export default class Contact {
* @return {string[]}
*/
get searchData() {
return this.jCal[1].map(x => x[0] + ':' + x[3])
const MinimalContactPropertiesLower = MinimalContactProperties.map((prop) => prop.toLowerCase())
const filtered = this.jCal[1]
.filter((x) => MinimalContactPropertiesLower.includes(x[0].toLowerCase()))
.map((x) => {
if (x[0].toLowerCase() === 'tel') {
return this.normalizedTels(x[3])
}
return x[3].toString()
})
return filtered
}

// support numbers in weird formats for searching e.g. +49 (0) 123 456-789
normalizedTels(number) {
return number.replace(/[^0-9+#]/g, '')
}

/**
Expand Down
Loading