mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-05-23 17:19:37 +02:00
[web] When main document is not set open last selected file (#28737)
* [web] if root doc is not found, open last selected file * call openInitialDoc even without rootdocid GitOrigin-RevId: fe629482c1827c6205d5cf2de497e593110bd36e
This commit is contained in:
committed by
Copybot
parent
6d84dfddcc
commit
bc6ae7816c
@@ -58,7 +58,7 @@ export type EditorManager = {
|
||||
openDoc: (document: Doc, options?: OpenDocOptions) => void
|
||||
openDocs: OpenDocuments
|
||||
openFileWithId: (fileId: string) => void
|
||||
openInitialDoc: (docId: string) => void
|
||||
openInitialDoc: (docId?: string) => void
|
||||
isLoading: boolean
|
||||
jumpToLine: (options: GotoLineOptions) => void
|
||||
debugTimers: React.MutableRefObject<Record<string, number>>
|
||||
@@ -513,7 +513,7 @@ export const EditorManagerProvider: FC<React.PropsWithChildren> = ({
|
||||
)
|
||||
|
||||
const openInitialDoc = useCallback(
|
||||
(fallbackDocId: string) => {
|
||||
(fallbackDocId?: string) => {
|
||||
const docId =
|
||||
customLocalStorage.getItem(currentDocumentIdStorageKey) || fallbackDocId
|
||||
if (docId) {
|
||||
|
||||
@@ -134,12 +134,7 @@ export const FileTreeOpenProvider: FC<React.PropsWithChildren> = ({
|
||||
// Open a document once the file tree and project are ready
|
||||
const initialOpenDoneRef = useRef(false)
|
||||
useEffect(() => {
|
||||
if (
|
||||
rootDocId &&
|
||||
fileTreeReady &&
|
||||
projectJoined &&
|
||||
!initialOpenDoneRef.current
|
||||
) {
|
||||
if (fileTreeReady && projectJoined && !initialOpenDoneRef.current) {
|
||||
initialOpenDoneRef.current = true
|
||||
openInitialDoc(rootDocId)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user