From 829fdfc59a5b051dc87e20581da108a2597bbfb8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Th=C3=A9o=20Poizat?= Date: Tue, 5 Nov 2024 14:26:48 +0100 Subject: [PATCH] fix: Remove partialIndex with variable --- src/hooks/useCurrentAccountFolderLink.js | 4 ++-- src/queries/index.js | 17 ++++++----------- 2 files changed, 8 insertions(+), 13 deletions(-) diff --git a/src/hooks/useCurrentAccountFolderLink.js b/src/hooks/useCurrentAccountFolderLink.js index a93c791..dda72ed 100644 --- a/src/hooks/useCurrentAccountFolderLink.js +++ b/src/hooks/useCurrentAccountFolderLink.js @@ -20,7 +20,7 @@ const useCurrentAccountFolderLink = () => { accountQuery.options ) - if (!accountResult[0]?._id) { + if (!accountResult?.[0]?._id) { return } @@ -31,7 +31,7 @@ const useCurrentAccountFolderLink = () => { triggerQuery.options ) - if (!triggerResult[0]?.message?.folder_to_save) { + if (!triggerResult?.[0]?.message?.folder_to_save) { return } diff --git a/src/queries/index.js b/src/queries/index.js index 207e0ad..745d29f 100644 --- a/src/queries/index.js +++ b/src/queries/index.js @@ -128,13 +128,9 @@ export const buildPresenceQuery = sourceAccountIdentifier => ({ export const buildAccountQuery = () => ({ definition: () => - Q('io.cozy.accounts') - .where({ - account_type: 'pronote' - }) - .partialIndex({ - account_type: 'pronote' - }), + Q('io.cozy.accounts').partialIndex({ + account_type: 'pronote' + }), options: { as: 'io.cozy.files/account_type/pronote', fetchPolicy: defaultFetchPolicy @@ -146,16 +142,15 @@ export const buildTriggerQuery = accountId => ({ Q('io.cozy.triggers') .where({ message: { - account: accountId, - konnector: 'pronote' + account: accountId } }) .partialIndex({ message: { - account: accountId, konnector: 'pronote' } - }), + }) + .indexFields(['message.account']), options: { as: 'io.cozy.triggers/konnector/pronote/account/' + accountId, fetchPolicy: defaultFetchPolicy