Просмотр исходного кода

[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
Domagoj Kriskovic 10 месяцев назад
Родитель
Сommit
bc6ae7816c

+ 2 - 2
services/web/frontend/js/features/ide-react/context/editor-manager-context.tsx

@@ -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) {

+ 1 - 6
services/web/frontend/js/features/ide-react/context/file-tree-open-context.tsx

@@ -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)
     }