Skip to content

Commit

Permalink
feat: Configure CozyClient to also use StackLink (when online)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
Ldoppea committed Aug 26, 2024
1 parent 31f4803 commit e7e494e
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/pouchdb/getLinks.ts
Original file line number Diff line number Diff line change
@@ -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 = [
Expand All @@ -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]
}

0 comments on commit e7e494e

Please sign in to comment.