mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-06-10 06:39:01 +02:00
[workbench] Improve asynchronous tool use (#30184)
GitOrigin-RevId: d1bd33469b557c29968049af99b9c3c85731151d
This commit is contained in:
@@ -54,11 +54,14 @@ export type EditorManager = {
|
||||
getCurrentDocValue: () => string | null
|
||||
getCurrentDocumentId: () => DocId | null
|
||||
setIgnoringExternalUpdates: (value: boolean) => void
|
||||
openDocWithId: (docId: string, options?: OpenDocOptions) => void
|
||||
openDocWithId: (
|
||||
docId: string,
|
||||
options?: OpenDocOptions
|
||||
) => Promise<Doc | undefined>
|
||||
openDoc: (document: Doc, options?: OpenDocOptions) => Promise<Doc | undefined>
|
||||
openDocs: OpenDocuments
|
||||
openFileWithId: (fileId: string) => void
|
||||
openInitialDoc: (docId?: string) => void
|
||||
openInitialDoc: (docId?: string) => Promise<Doc | undefined>
|
||||
isLoading: boolean
|
||||
jumpToLine: (options: GotoLineOptions) => void
|
||||
debugTimers: React.MutableRefObject<Record<string, number>>
|
||||
@@ -486,12 +489,12 @@ export const EditorManagerProvider: FC<React.PropsWithChildren> = ({
|
||||
)
|
||||
|
||||
const openDocWithId = useCallback(
|
||||
(docId: string, options: OpenDocOptions = {}) => {
|
||||
async (docId: string, options: OpenDocOptions = {}) => {
|
||||
const doc = findDocEntityById(fileTreeData, docId)
|
||||
if (!doc) {
|
||||
return
|
||||
}
|
||||
openDoc(doc, options)
|
||||
return await openDoc(doc, options)
|
||||
},
|
||||
[fileTreeData, openDoc]
|
||||
)
|
||||
@@ -513,11 +516,11 @@ export const EditorManagerProvider: FC<React.PropsWithChildren> = ({
|
||||
)
|
||||
|
||||
const openInitialDoc = useCallback(
|
||||
(fallbackDocId?: string) => {
|
||||
async (fallbackDocId?: string) => {
|
||||
const docId =
|
||||
customLocalStorage.getItem(currentDocumentIdStorageKey) || fallbackDocId
|
||||
if (docId) {
|
||||
openDocWithId(docId)
|
||||
return await openDocWithId(docId)
|
||||
}
|
||||
},
|
||||
[currentDocumentIdStorageKey, openDocWithId]
|
||||
@@ -580,7 +583,7 @@ export const EditorManagerProvider: FC<React.PropsWithChildren> = ({
|
||||
}
|
||||
|
||||
const handleProjectJoined = () => {
|
||||
openDoc(doc, { forceReopen: true })
|
||||
return openDoc(doc, { forceReopen: true })
|
||||
}
|
||||
|
||||
eventEmitter.once('project:joined', handleProjectJoined)
|
||||
|
||||
Reference in New Issue
Block a user