Skip to content

Commit b38f2c8

Browse files
committed
feat(search): Change search attribute names
In cozy/cozy-libs#2603 we renamed some of the API's attributes for better readability This commit adapt to those changes and handle retrocompatibility until the change is deployed in cozy-web-data-proxy Related PR: cozy/cozy-libs#2603 Related PR: cozy/cozy-web-data-proxy#10
1 parent dcc1551 commit b38f2c8

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

src/assistant/Search/getIconForSearchResult.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,14 @@ export const getIconForSearchResult = searchResult => {
2626
}
2727
}
2828

29-
if (searchResult.type === 'notes') {
29+
if (searchResult.slug === 'notes') {
3030
return {
3131
type: 'component',
3232
component: IconNote
3333
}
3434
}
3535

36-
if (searchResult.type === 'drive') {
36+
if (searchResult.slug === 'drive') {
3737
return {
3838
type: 'component',
3939
component: getDriveMimeTypeIcon(
@@ -44,7 +44,7 @@ export const getIconForSearchResult = searchResult => {
4444
}
4545
}
4646

47-
if (searchResult.type === 'contacts') {
47+
if (searchResult.slug === 'contacts') {
4848
return {
4949
type: 'component',
5050
component: ContactsIcon

src/assistant/Search/useFetchResult.jsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,16 @@ export const useFetchResult = searchValue => {
2828
const searchResults = await dataProxy.search(searchValue)
2929

3030
const results = searchResults.map(r => {
31+
// Begin Retrocompatibility code, to be removed when following PR is merged: https://github.com/cozy/cozy-web-data-proxy/pull/10
32+
r.slug = r.slug || r.type
33+
r.subTitle = r.subTitle || r.name
34+
// End Retrocompatibility code
3135
const icon = getIconForSearchResult(r)
3236
return {
3337
id: r.doc._id,
3438
icon: icon,
3539
primary: r.title,
36-
secondary: r.name,
40+
secondary: r.subTitle,
3741
onClick: () => {
3842
window.open(r.url)
3943
}

0 commit comments

Comments
 (0)