File tree Expand file tree Collapse file tree 1 file changed +11
-1
lines changed
Expand file tree Collapse file tree 1 file changed +11
-1
lines changed Original file line number Diff line number Diff line change @@ -188,14 +188,24 @@ const dataProxy: DataProxyWorker = {
188188 return queryRes
189189 } ,
190190
191- forceSyncPouch : ( ) => {
191+ forceSyncPouch : async (
192+ options : { clean : boolean } = { clean : false }
193+ ) : Promise < void > => {
192194 if ( ! client ) {
193195 throw new Error (
194196 'Client is required to execute a forceSyncPouch, please initialize CozyClient'
195197 )
196198 }
197199 const pouchLink = getPouchLink ( client )
198200 if ( pouchLink ) {
201+ if ( options . clean ) {
202+ await pouchLink . reset ( )
203+ await pouchLink . registerClient ( client ) // because reset also resets the client
204+ await pouchLink . onLogin ( )
205+ } else {
206+ await pouchLink . pouches . waitForCurrentReplications ( )
207+ }
208+
199209 pouchLink . startReplication ( )
200210 }
201211 } ,
You can’t perform that action at this time.
0 commit comments