|
|
@@ -15,6 +15,8 @@ import OLButton from '@/shared/components/ol/ol-button'
|
|
|
import { sendMB } from '@/infrastructure/event-tracking'
|
|
|
import useIsMounted from '@/shared/hooks/use-is-mounted'
|
|
|
import clientId from '@/utils/client-id'
|
|
|
+import { useReferencesContext } from '@/features/ide-react/context/references-context'
|
|
|
+import { useFeatureFlag } from '@/shared/context/split-test-context'
|
|
|
|
|
|
type FileViewRefreshButtonProps = {
|
|
|
setRefreshError: Dispatch<SetStateAction<Nullable<string>>>
|
|
|
@@ -35,14 +37,17 @@ export default function FileViewRefreshButton({
|
|
|
const { projectId } = useProjectContext()
|
|
|
const [refreshing, setRefreshing] = useState(false)
|
|
|
const isMountedRef = useIsMounted()
|
|
|
+ const { indexAllReferences } = useReferencesContext()
|
|
|
+ const clientSideReferences = useFeatureFlag('client-side-references')
|
|
|
|
|
|
const refreshFile = useCallback(
|
|
|
(isTPR: Nullable<boolean>) => {
|
|
|
setRefreshing(true)
|
|
|
// Replacement of the file handled by the file tree
|
|
|
window.expectingLinkedFileRefreshedSocketFor = file.name
|
|
|
+ const shouldReindexReferences = isTPR || /\.bib$/.test(file.name)
|
|
|
const body = {
|
|
|
- shouldReindexReferences: isTPR || /\.bib$/.test(file.name),
|
|
|
+ shouldReindexReferences,
|
|
|
clientId: clientId.get(),
|
|
|
}
|
|
|
postJSON(`/project/${projectId}/linked_file/${file.id}/refresh`, {
|
|
|
@@ -52,6 +57,9 @@ export default function FileViewRefreshButton({
|
|
|
if (isMountedRef.current) {
|
|
|
setRefreshing(false)
|
|
|
}
|
|
|
+ if (clientSideReferences && shouldReindexReferences) {
|
|
|
+ indexAllReferences(false)
|
|
|
+ }
|
|
|
sendMB('refresh-linked-file', {
|
|
|
provider: file.linkedFileData?.provider,
|
|
|
})
|
|
|
@@ -63,7 +71,14 @@ export default function FileViewRefreshButton({
|
|
|
}
|
|
|
})
|
|
|
},
|
|
|
- [file, projectId, setRefreshError, isMountedRef]
|
|
|
+ [
|
|
|
+ file,
|
|
|
+ projectId,
|
|
|
+ setRefreshError,
|
|
|
+ isMountedRef,
|
|
|
+ indexAllReferences,
|
|
|
+ clientSideReferences,
|
|
|
+ ]
|
|
|
)
|
|
|
|
|
|
if (tprFileViewRefreshButton.length > 0) {
|