Skip to content

Commit

Permalink
feat(search): Change search attribute names
Browse files Browse the repository at this point in the history
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
  • Loading branch information
Ldoppea committed Nov 6, 2024
1 parent dcc1551 commit 1558db8
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
6 changes: 3 additions & 3 deletions src/assistant/Search/getIconForSearchResult.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,14 @@ export const getIconForSearchResult = searchResult => {
}
}

if (searchResult.type === 'notes') {
if (searchResult.slug === 'notes') {
return {
type: 'component',
component: IconNote
}
}

if (searchResult.type === 'drive') {
if (searchResult.slug === 'drive') {
return {
type: 'component',
component: getDriveMimeTypeIcon(
Expand All @@ -44,7 +44,7 @@ export const getIconForSearchResult = searchResult => {
}
}

if (searchResult.type === 'contacts') {
if (searchResult.slug === 'contacts') {
return {
type: 'component',
component: ContactsIcon
Expand Down
6 changes: 5 additions & 1 deletion src/assistant/Search/useFetchResult.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,16 @@ export const useFetchResult = searchValue => {
const searchResults = await dataProxy.search(searchValue)

const results = searchResults.map(r => {
// Begin Retrocompatibility code, to be removed when following PR is merged: https://github.com/cozy/cozy-web-data-proxy/pull/10
r.slug = r.slug || r.type
r.subTitle = r.subTitle || r.name
// End Retrocompatibility code
const icon = getIconForSearchResult(r)
return {
id: r.doc._id,
icon: icon,
primary: r.title,
secondary: r.name,
secondary: r.subTitle,
onClick: () => {
window.open(r.url)
}
Expand Down

0 comments on commit 1558db8

Please sign in to comment.