mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-11-14 22:23:42 +01:00
Merge pull request #22178 from overleaf/jpa-file-view-hash-2
[web] migrate file-view to download from history-v1 (via web) 2/2 GitOrigin-RevId: 93172cbbd2d19a55bb27f5b0ca0b494f815a3632
This commit is contained in:
@@ -33,7 +33,6 @@ import {
|
||||
} from '../errors'
|
||||
import { Folder } from '../../../../../types/folder'
|
||||
import { useReferencesContext } from '@/features/ide-react/context/references-context'
|
||||
import { useSnapshotContext } from '@/features/ide-react/context/snapshot-context'
|
||||
|
||||
type DroppedFile = File & {
|
||||
relativePath?: string
|
||||
@@ -221,7 +220,6 @@ export const FileTreeActionableProvider: FC = ({ children }) => {
|
||||
const { _id: projectId } = useProjectContext()
|
||||
const { fileTreeReadOnly } = useFileTreeData()
|
||||
const { indexAllReferences } = useReferencesContext()
|
||||
const { fileTreeFromHistory } = useSnapshotContext()
|
||||
|
||||
const [state, dispatch] = useReducer(
|
||||
fileTreeReadOnly
|
||||
@@ -494,17 +492,14 @@ export const FileTreeActionableProvider: FC = ({ children }) => {
|
||||
const selectedEntity = findInTree(fileTreeData, selectedEntityId)
|
||||
|
||||
if (selectedEntity?.type === 'fileRef') {
|
||||
if (fileTreeFromHistory) {
|
||||
return `/project/${projectId}/blob/${selectedEntity.entity.hash}`
|
||||
}
|
||||
return `/project/${projectId}/file/${selectedEntityId}`
|
||||
return `/project/${projectId}/blob/${selectedEntity.entity.hash}?fallback=${selectedEntityId}`
|
||||
}
|
||||
|
||||
if (selectedEntity?.type === 'doc') {
|
||||
return `/project/${projectId}/doc/${selectedEntityId}/download`
|
||||
}
|
||||
}
|
||||
}, [fileTreeData, projectId, selectedEntityIds, fileTreeFromHistory])
|
||||
}, [fileTreeData, projectId, selectedEntityIds])
|
||||
|
||||
// TODO: wrap in useMemo
|
||||
const value = {
|
||||
|
||||
@@ -10,7 +10,6 @@ import {
|
||||
pathInFolder,
|
||||
} from '@/features/file-tree/util/path'
|
||||
import { PreviewPath } from '../../../../../types/preview-path'
|
||||
import { useSnapshotContext } from '@/features/ide-react/context/snapshot-context'
|
||||
|
||||
type FileTreePathContextValue = {
|
||||
pathInFolder: (id: string) => string | null
|
||||
@@ -25,7 +24,6 @@ export const FileTreePathContext = createContext<
|
||||
|
||||
export const FileTreePathProvider: FC = ({ children }) => {
|
||||
const { fileTreeData }: { fileTreeData: Folder } = useFileTreeData()
|
||||
const { fileTreeFromHistory } = useSnapshotContext()
|
||||
const projectId = getMeta('ol-project_id')
|
||||
|
||||
const pathInFileTree = useCallback(
|
||||
@@ -39,9 +37,8 @@ export const FileTreePathProvider: FC = ({ children }) => {
|
||||
)
|
||||
|
||||
const previewByPathInFileTree = useCallback(
|
||||
(path: string) =>
|
||||
previewByPath(fileTreeData, projectId, path, fileTreeFromHistory),
|
||||
[fileTreeData, projectId, fileTreeFromHistory]
|
||||
(path: string) => previewByPath(fileTreeData, projectId, path),
|
||||
[fileTreeData, projectId]
|
||||
)
|
||||
|
||||
const dirnameInFileTree = useCallback(
|
||||
|
||||
Reference in New Issue
Block a user