mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-05-23 09:09:36 +02:00
Merge pull request #29180 from overleaf/mj-linked-files-reindex
[web] Ensure we reindex after refreshing linked file GitOrigin-RevId: 0c7d561a556525e9db30a8a1cec78b31a4d1d5de
This commit is contained in:
committed by
Copybot
parent
48a3d6a10a
commit
d75c5f72fb
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user