瀏覽代碼

app: wait for loadFile before opening file tab

Brendan Allan 7 月之前
父節點
當前提交
eda71373b0
共有 1 個文件被更改,包括 5 次插入3 次删除
  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
   showAllFiles: () => void
   tabForPath: (path: string) => string
   tabForPath: (path: string) => string
   openTab: (tab: string) => void
   openTab: (tab: string) => void
-  loadFile: (path: string) => void
+  loadFile: (path: string) => any | Promise<void>
 }) => {
 }) => {
   return (path: string) => {
   return (path: string) => {
     batch(() => {
     batch(() => {
       input.showAllFiles()
       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()
     })
     })
   }
   }
 }
 }