From f5a43759d43dc30b87283dce8178e0ff8a43b245 Mon Sep 17 00:00:00 2001 From: Erwan Guyader Date: Tue, 16 Aug 2022 15:08:33 +0200 Subject: [PATCH] core/remote/cozy: Use cozy-stack-client methods 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. --- core/remote/constants.js | 1 + core/remote/cozy.js | 8 +++++--- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/core/remote/constants.js b/core/remote/constants.js index fe940b7f7..92386a1c2 100644 --- a/core/remote/constants.js +++ b/core/remote/constants.js @@ -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 diff --git a/core/remote/cozy.js b/core/remote/cozy.js index acbb56bd6..63e017cca 100644 --- a/core/remote/cozy.js +++ b/core/remote/cozy.js @@ -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 { @@ -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) { @@ -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 } }