Skip to content

Commit

Permalink
fix(search): use find method where args are for find
Browse files Browse the repository at this point in the history
  • Loading branch information
trollepierre committed Aug 17, 2022
1 parent 8d4abc3 commit 6e15528
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 46 deletions.
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@
"cozy-authentication": "2.8.3",
"cozy-bar": "7.20.0",
"cozy-ci": "0.4.1",
"cozy-client": "^32.7.0",
"cozy-client": "^32.7.3",
"cozy-client-js": "0.19.0",
"cozy-device-helper": "^2.1.0",
"cozy-doctypes": "1.82.2",
Expand All @@ -125,12 +125,12 @@
"cozy-intent": "^1.17.1",
"cozy-keys-lib": "4.1.9",
"cozy-logger": "1.9.0",
"cozy-pouch-link": "^32.7.0",
"cozy-pouch-link": "^32.7.3",
"cozy-realtime": "3.14.4",
"cozy-scanner": "2.0.2",
"cozy-scripts": "^6.3.8",
"cozy-sharing": "4.1.5",
"cozy-stack-client": "^32.7.0",
"cozy-stack-client": "^32.7.3",
"cozy-ui": "^68.4.0",
"date-fns": "1.30.1",
"diacritics": "1.3.0",
Expand Down
42 changes: 17 additions & 25 deletions src/drive/web/modules/queries.js
Original file line number Diff line number Diff line change
Expand Up @@ -326,35 +326,27 @@ export const buildEncryptionByIdQuery = id => ({
})

/**
* Provide selector and options to fetch files
* Provide options to fetch files
*
* @returns {{options: {MangoQueryOptions}, selector: object}} A minimalist file list
* @returns {MangoQueryOptions} A minimalist file list
*/
export const prepareSuggestionQuery = () => {
const selector = {
export const prepareSuggestionQuery = () => ({
partialFilter: {
_id: {
$gt: null
}
}
const options = {
partialFilter: {
_id: {
$ne: TRASH_DIR_ID
},
path: {
// this predicate is necessary until the trashed attribute is more reliable
$or: [{ $exists: false }, { $regex: '^(?!/.cozy_trash)' }]
},
trashed: {
$or: [{ $exists: false }, { $eq: false }]
}
$ne: TRASH_DIR_ID
},
fields: ['_id', 'trashed', 'dir_id', 'name', 'path', 'type', 'mime'],
indexedFields: ['_id'],
limit: 1000
}
return { selector, options }
}
path: {
// this predicate is necessary until the trashed attribute is more reliable
$or: [{ $exists: false }, { $regex: '^(?!/.cozy_trash)' }]
},
trashed: {
$or: [{ $exists: false }, { $eq: false }]
}
},
fields: ['_id', 'trashed', 'dir_id', 'name', 'path', 'type', 'mime'],
indexedFields: ['_id'],
limit: 1000
})

export {
buildDriveQuery,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,8 @@ class SuggestionProvider extends React.Component {
const { client } = this.props
this.hasIndexFilesBeenLaunched = true

const { selector, options } = prepareSuggestionQuery()
const files = await client
.collection(DOCTYPE_FILES)
.findAll(selector, options)
const options = prepareSuggestionQuery()
const files = await client.collection(DOCTYPE_FILES).findAll(null, options)

const folders = files.filter(file => file.type === TYPE_DIRECTORY)

Expand Down
28 changes: 14 additions & 14 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -5974,16 +5974,16 @@ cozy-client@^27.14.4:
sift "^6.0.0"
url-search-params-polyfill "^8.0.0"

cozy-client@^32.7.0:
version "32.7.0"
resolved "https://registry.yarnpkg.com/cozy-client/-/cozy-client-32.7.0.tgz#8b997d9d9f704e5699fdd5da51b7470cd6eafb1f"
integrity sha512-91L3mf2WIWhjM2von4bTTMIspoP4405QxF+MT4hYS1viWnoADbKsDhCu2s3ZTOxca9ri3AJrzjxtYdUoyXAnYA==
cozy-client@^32.7.3:
version "32.7.3"
resolved "https://registry.yarnpkg.com/cozy-client/-/cozy-client-32.7.3.tgz#8048e899124852c2dab66cd627b238e61e08a476"
integrity sha512-7em+xdzdbOeUKrb7X8aVlOITYkilqsv5y1xvPijIUAY9oPfGVnOsDByTlrtxel9VDRjdyhTWV/TFosyFsF6YlQ==
dependencies:
"@cozy/minilog" "1.0.0"
"@types/jest" "^26.0.20"
"@types/lodash" "^4.14.170"
btoa "^1.2.1"
cozy-stack-client "^32.7.0"
cozy-stack-client "^32.7.3"
json-stable-stringify "^1.0.1"
lodash "^4.17.13"
microee "^0.0.6"
Expand Down Expand Up @@ -6128,12 +6128,12 @@ cozy-logger@^1.3.0, cozy-logger@^1.6.0, cozy-logger@^1.7.0:
chalk "^2.4.2"
json-stringify-safe "5.0.1"

cozy-pouch-link@^32.7.0:
version "32.7.0"
resolved "https://registry.yarnpkg.com/cozy-pouch-link/-/cozy-pouch-link-32.7.0.tgz#7766cde69783a98502f8ee75b642708b23195bb6"
integrity sha512-Kxr7VZpr6VXenqXmtggZYdwtgmy5VcYtIy+wmDX23WH8IFobLottoR4L/v53Diqai4l1jeuAZCvJV+2VwPzOCw==
cozy-pouch-link@^32.7.3:
version "32.7.3"
resolved "https://registry.yarnpkg.com/cozy-pouch-link/-/cozy-pouch-link-32.7.3.tgz#3658fe42115d6c9f95d71cf9cdfc17cdc29d87f4"
integrity sha512-xb3HMn7ON+vSFz0wzxJEg5wgE0TsdISwfuy9CjplAGvaFHnCiCGa2xf7yTX8TF0Z8PSppBRJSYqoNfOfCPDOZA==
dependencies:
cozy-client "^32.7.0"
cozy-client "^32.7.3"
pouchdb-browser "^7.2.2"
pouchdb-find "^7.2.2"

Expand Down Expand Up @@ -6252,10 +6252,10 @@ cozy-stack-client@^27.21.0:
mime "^2.4.0"
qs "^6.7.0"

cozy-stack-client@^32.7.0:
version "32.7.0"
resolved "https://registry.yarnpkg.com/cozy-stack-client/-/cozy-stack-client-32.7.0.tgz#7990c54427a56436b2685750c9d4665fecb6edd4"
integrity sha512-UxAooLfgKVYdoyCvG/Qrx5h0niRBmIiFA8mDKnWUkZMMaOHs3s5X3DqYqmF3ki+tKlhMO4l9eugsbdwoKItK3w==
cozy-stack-client@^32.7.3:
version "32.7.3"
resolved "https://registry.yarnpkg.com/cozy-stack-client/-/cozy-stack-client-32.7.3.tgz#f2b46e8e31d17bb27467d189e5956f004d2fbcdf"
integrity sha512-TakiZnPIZ4idQmTfyyDc2MkEEVcfOAPbQNj7/BhtYFX+2p1ocNfHA0EAWF2fd/ijfcxOgj3i5lxRjDbilxy9PQ==
dependencies:
detect-node "^2.0.4"
mime "^2.4.0"
Expand Down

0 comments on commit 6e15528

Please sign in to comment.