Przeglądaj źródła

Merge pull request #8009 from overleaf/jpa-sync-pdf-url-update

[web] update clsiServerId and pdfUrl in the same update cycle

GitOrigin-RevId: 6791627c12c16aa71ad393edbf19d7fed00491a0
Alf Eaton 4 lat temu
rodzic
commit
a3459a1842

+ 1 - 1
services/web/frontend/js/features/pdf-preview/util/output-files.js

@@ -5,7 +5,7 @@ import { v4 as uuid } from 'uuid'
 
 const searchParams = new URLSearchParams(window.location.search)
 
-export const handleOutputFiles = async (outputFiles, projectId, data) => {
+export function handleOutputFiles(outputFiles, projectId, data) {
   const result = {}
 
   const pdfDownloadDomain = data.pdfDownloadDomain ?? ''

+ 38 - 39
services/web/frontend/js/shared/context/local-compile-context.js

@@ -247,49 +247,48 @@ export function LocalCompileProvider({ children }) {
         }
 
         // set the PDF URLs
-        handleOutputFiles(outputFiles, projectId, data).then(result => {
-          if (data.status === 'success') {
-            setPdfDownloadUrl(result.pdfDownloadUrl)
-            setPdfUrl(result.pdfUrl)
-          }
+        const result = handleOutputFiles(outputFiles, projectId, data)
+        if (data.status === 'success') {
+          setPdfDownloadUrl(result.pdfDownloadUrl)
+          setPdfUrl(result.pdfUrl)
+        }
 
-          setFileList(
-            buildFileList(outputFiles, data.clsiServerId, data.compileGroup)
-          )
-
-          // handle log files
-          // asynchronous (TODO: cancel on new compile?)
-          setLogEntryAnnotations(null)
-          setLogEntries(null)
-          setRawLog(null)
-
-          handleLogFiles(outputFiles, data, abortController.signal).then(
-            result => {
-              setRawLog(result.log)
-              setLogEntries(result.logEntries)
-              setLogEntryAnnotations(
-                buildLogEntryAnnotations(
-                  result.logEntries.all,
-                  ide.fileTreeManager
-                )
+        setFileList(
+          buildFileList(outputFiles, data.clsiServerId, data.compileGroup)
+        )
+
+        // handle log files
+        // asynchronous (TODO: cancel on new compile?)
+        setLogEntryAnnotations(null)
+        setLogEntries(null)
+        setRawLog(null)
+
+        handleLogFiles(outputFiles, data, abortController.signal).then(
+          result => {
+            setRawLog(result.log)
+            setLogEntries(result.logEntries)
+            setLogEntryAnnotations(
+              buildLogEntryAnnotations(
+                result.logEntries.all,
+                ide.fileTreeManager
               )
+            )
 
-              // sample compile stats for real users
-              if (!window.user.alphaProgram && data.status === 'success') {
-                sendMBSampled(
-                  'compile-result',
-                  {
-                    errors: result.logEntries.errors.length,
-                    warnings: result.logEntries.warnings.length,
-                    typesetting: result.logEntries.typesetting.length,
-                    newPdfPreview: true, // TODO: is this useful?
-                  },
-                  0.01
-                )
-              }
+            // sample compile stats for real users
+            if (!window.user.alphaProgram && data.status === 'success') {
+              sendMBSampled(
+                'compile-result',
+                {
+                  errors: result.logEntries.errors.length,
+                  warnings: result.logEntries.warnings.length,
+                  typesetting: result.logEntries.typesetting.length,
+                  newPdfPreview: true, // TODO: is this useful?
+                },
+                0.01
+              )
             }
-          )
-        })
+          }
+        )
       }
 
       switch (data.status) {