Skip to content

Commit

Permalink
core/remote/cozy: Use cozy-stack-client methods
Browse files Browse the repository at this point in the history
  Methods from cozy-client use a redux store to keep a local data cache
  which creates a large memory footprint for Desktop without benefits
  since we don't use that store.

  These methods wrap cozy-stack-client methods which make the calls to
  the remote Cozy without dealing with redux.
  Using them should make Desktop a little lighter.
  • Loading branch information
taratatach committed Aug 16, 2022
1 parent 40eaa10 commit f5a4375
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
1 change: 1 addition & 0 deletions core/remote/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ module.exports = {
// Doctypes
FILES_DOCTYPE: 'io.cozy.files',
OAUTH_CLIENTS_DOCTYPE: 'io.cozy.oauth.clients',
SETTINGS_DOCTYPE: 'io.cozy.settings',
VERSIONS_DOCTYPE: 'io.cozy.files.versions',

// Files document type
Expand Down
8 changes: 5 additions & 3 deletions core/remote/cozy.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ const {
DIR_TYPE,
INITIAL_SEQ,
MAX_FILE_SIZE,
OAUTH_CLIENTS_DOCTYPE
OAUTH_CLIENTS_DOCTYPE,
SETTINGS_DOCTYPE
} = require('./constants')
const { DirectoryNotFound } = require('./errors')
const {
Expand Down Expand Up @@ -450,7 +451,7 @@ class RemoteCozy {
.sortBy([{ dir_id: 'asc' }, { name: 'asc' }])
.limitBy(batchSize)

const data = await client.queryAll(queryDef)
const data = await client.findAll(queryDef)

const remoteDocs = []
for (const j of data) {
Expand Down Expand Up @@ -541,11 +542,12 @@ class RemoteCozy {

async capabilities() /*: Promise<{ flatSubdomains: boolean }> */ {
const client = await this.newClient()
const settings = client.collection(SETTINGS_DOCTYPE)
const {
data: {
attributes: { flat_subdomains: flatSubdomains }
}
} = await client.query(Q('io.cozy.settings').getById('capabilities'))
} = await settings.get('capabilities')
return { flatSubdomains }
}

Expand Down

0 comments on commit f5a4375

Please sign in to comment.