@@ -2,6 +2,7 @@ import * as Comlink from 'comlink'
22import React , { useState , useEffect , ReactNode } from 'react'
33
44import { useClient } from 'cozy-client'
5+ import flag from 'cozy-flags'
56import Minilog from 'cozy-minilog'
67
78import {
@@ -83,7 +84,7 @@ export const SharedWorkerProvider = React.memo(
8384 const client = useClient ( )
8485
8586 useEffect ( ( ) => {
86- if ( ! client ) return
87+ if ( ! client || ! flag ( 'drive.shared-drive.enabled' ) ) return
8788
8889 if ( ! hasRealtimePlugin ( client . plugins ) ) {
8990 throw new Error (
@@ -139,13 +140,16 @@ export const SharedWorkerProvider = React.memo(
139140 // Cleanup any remaining local data
140141 await removeStaleLocalData ( )
141142
142- const { data : sharedDrives } = await client
143- . collection ( 'io.cozy.sharings' )
144- . fetchSharedDrives ( )
143+ let sharedDriveIds : string [ ] = [ ]
145144
146- const sharedDriveIds : string [ ] = sharedDrives . map (
147- ( drive : { id : string } ) => drive . id
148- )
145+ // Fetch shared drives only if the feature is enabled
146+ if ( flag ( 'drive.shared-drive.enabled' ) ) {
147+ const { data : sharedDrives } = await client
148+ . collection ( 'io.cozy.sharings' )
149+ . fetchSharedDrives ( )
150+
151+ sharedDriveIds = sharedDrives . map ( ( drive : { id : string } ) => drive . id )
152+ }
149153
150154 log . debug ( 'Init SharedWorker' )
151155
0 commit comments