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