From ee1faa94fba0e5474893fd393d33a2f0814c394d Mon Sep 17 00:00:00 2001 From: Ldoppea Date: Fri, 31 May 2024 16:44:40 +0200 Subject: [PATCH] feat: Configure CozyClient to also use StackLink (when online) In previous commit we configured cozy-client to use CozyPouchLink for its queries This commit also adds StackLink as the first Link so by default it will do its queries through the remote cozy-stack CozyClient has been modified to handle offline mode and redirect to the next link when it is detected Related PR: cozy/cozy-client#1507 --- src/pouchdb/getLinks.ts | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/pouchdb/getLinks.ts b/src/pouchdb/getLinks.ts index 5d3a91190..ac6e565f9 100644 --- a/src/pouchdb/getLinks.ts +++ b/src/pouchdb/getLinks.ts @@ -1,5 +1,6 @@ import { platformReactNative } from '/pouchdb/platformReactNative' +import { CozyLink, StackLink } from 'cozy-client' import { default as PouchLink } from 'cozy-pouch-link' export const offlineDoctypes = [ @@ -24,16 +25,20 @@ export const offlineDoctypes = [ 'io.cozy.permissions' ] -export const getLinks = () => { +export const getLinks = (): CozyLink[] => { const pouchLinkOptions = { doctypes: offlineDoctypes, initialSync: true, platform: platformReactNative } + const stackLink = new StackLink({ + platform: platformReactNative + }) + const pouchLink = new PouchLink({ ...pouchLinkOptions }) - return [pouchLink] + return [stackLink, pouchLink] }