Explorar o código

app: wait for loadFile before opening file tab

Brendan Allan hai 5 meses
pai
achega
eda71373b0
Modificáronse 1 ficheiros con 5 adicións e 3 borrados
  1. 5 3
      packages/app/src/pages/session/helpers.ts

+ 5 - 3
packages/app/src/pages/session/helpers.ts

@@ -24,13 +24,15 @@ export const createOpenReviewFile = (input: {
   showAllFiles: () => void
   tabForPath: (path: string) => string
   openTab: (tab: string) => void
-  loadFile: (path: string) => void
+  loadFile: (path: string) => any | Promise<void>
 }) => {
   return (path: string) => {
     batch(() => {
       input.showAllFiles()
-      input.openTab(input.tabForPath(path))
-      input.loadFile(path)
+      const maybePromise = input.loadFile(path)
+      const openTab = () => input.openTab(input.tabForPath(path))
+      if (maybePromise instanceof Promise) maybePromise.then(openTab)
+      else openTab()
     })
   }
 }