Skip to content

Commit 0b683e8

Browse files
author
doubleface
committed
feat: Put shared drive search behind the shared drives flag
1 parent fe7f57a commit 0b683e8

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

src/dataproxy/worker/SharedWorkerProvider.tsx

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import * as Comlink from 'comlink'
22
import React, { useState, useEffect, ReactNode } from 'react'
33

44
import { useClient } from 'cozy-client'
5+
import flag from 'cozy-flags'
56
import Minilog from 'cozy-minilog'
67

78
import {
@@ -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

Comments
 (0)