mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-11-14 06:03:45 +01:00
Merge pull request #36074 from overleaf/mj-reload-after-failed-catch-up
[web] Reload after failed intermittent-connection catchup GitOrigin-RevId: c9a6315ecb6ebe957ad85c05ebc84bb8165881ab
This commit is contained in:
committed by
Copybot
parent
35ba44f22b
commit
d1691345c5
+12
-1
@@ -14,6 +14,7 @@ import { uploadBatch } from '@/infrastructure/batch-file-uploader'
|
||||
import { debugConsole } from '@/utils/debugging'
|
||||
import Notification from '@/shared/components/notification'
|
||||
import { downloadFileContent } from '@/utils/download-file'
|
||||
import { useLocation } from '@/shared/hooks/use-location'
|
||||
|
||||
export type UnableToSyncModalProps = {
|
||||
baseContent: string
|
||||
@@ -22,6 +23,7 @@ export type UnableToSyncModalProps = {
|
||||
rootFolderId: string | undefined
|
||||
show: boolean
|
||||
onHide: () => void
|
||||
reloadAfterClose?: boolean
|
||||
}
|
||||
|
||||
// Generates the offline copy filename with a timestamp to avoid duplicates.
|
||||
@@ -52,11 +54,20 @@ function UnableToSyncModal({
|
||||
docName,
|
||||
rootFolderId,
|
||||
show,
|
||||
onHide,
|
||||
onHide: onHideProp,
|
||||
reloadAfterClose = false,
|
||||
}: UnableToSyncModalProps) {
|
||||
const { t } = useTranslation()
|
||||
const [saving, setSaving] = useState(false)
|
||||
const [saveError, setSaveError] = useState(false)
|
||||
const location = useLocation()
|
||||
|
||||
const onHide = useCallback(() => {
|
||||
onHideProp()
|
||||
if (reloadAfterClose) {
|
||||
location.reload()
|
||||
}
|
||||
}, [onHideProp, reloadAfterClose, location])
|
||||
|
||||
const handleDownload = useCallback(() => {
|
||||
downloadFileContent(targetContent, docName ?? 'document.txt')
|
||||
|
||||
@@ -606,6 +606,7 @@ export const EditorManagerProvider: FC<React.PropsWithChildren> = ({
|
||||
editorContent: editorContent || '',
|
||||
baseContent: backupRecord.snapshot,
|
||||
docName: document.docName,
|
||||
reloadAfterClose: true,
|
||||
})
|
||||
OfflineDocBackup.remove(projectId, document.doc_id)
|
||||
} else {
|
||||
@@ -644,13 +645,14 @@ export const EditorManagerProvider: FC<React.PropsWithChildren> = ({
|
||||
|
||||
useEffect(() => {
|
||||
const handleUnableToSync = ({
|
||||
detail: [{ editorContent, baseContent, docName }],
|
||||
detail: [{ editorContent, baseContent, docName, reloadAfterClose }],
|
||||
}: CustomEvent<IdeEvents['ide:unableToSyncOfflineChanges']>) => {
|
||||
showUnableToSyncModal({
|
||||
baseContent,
|
||||
targetContent: editorContent,
|
||||
docName,
|
||||
rootFolderId: fileTreeDataRef.current?._id,
|
||||
reloadAfterClose,
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@@ -32,7 +32,11 @@ type ModalsContextValue = {
|
||||
showUnableToSyncModal: (
|
||||
data: Pick<
|
||||
UnableToSyncModalProps,
|
||||
'baseContent' | 'targetContent' | 'docName' | 'rootFolderId'
|
||||
| 'baseContent'
|
||||
| 'targetContent'
|
||||
| 'docName'
|
||||
| 'rootFolderId'
|
||||
| 'reloadAfterClose'
|
||||
>
|
||||
) => void
|
||||
}
|
||||
@@ -64,13 +68,18 @@ export const ModalsContextProvider: FC<React.PropsWithChildren> = ({
|
||||
const [unableToSyncModalData, setUnableToSyncModalData] = useState<
|
||||
Pick<
|
||||
UnableToSyncModalProps,
|
||||
'baseContent' | 'targetContent' | 'docName' | 'rootFolderId'
|
||||
| 'baseContent'
|
||||
| 'targetContent'
|
||||
| 'docName'
|
||||
| 'rootFolderId'
|
||||
| 'reloadAfterClose'
|
||||
>
|
||||
>({
|
||||
baseContent: '',
|
||||
targetContent: '',
|
||||
docName: null,
|
||||
rootFolderId: undefined,
|
||||
reloadAfterClose: undefined,
|
||||
})
|
||||
|
||||
const handleHideGenericModal = useCallback(() => {
|
||||
@@ -122,7 +131,11 @@ export const ModalsContextProvider: FC<React.PropsWithChildren> = ({
|
||||
(
|
||||
data: Pick<
|
||||
UnableToSyncModalProps,
|
||||
'baseContent' | 'targetContent' | 'docName' | 'rootFolderId'
|
||||
| 'baseContent'
|
||||
| 'targetContent'
|
||||
| 'docName'
|
||||
| 'rootFolderId'
|
||||
| 'reloadAfterClose'
|
||||
>
|
||||
) => {
|
||||
setUnableToSyncModalData(data)
|
||||
|
||||
@@ -28,6 +28,7 @@ export type IdeEvents = {
|
||||
editorContent: string
|
||||
baseContent: string
|
||||
docName: string
|
||||
reloadAfterClose?: boolean
|
||||
},
|
||||
]
|
||||
'ide:offlineChangesSynced': [{ docId: string }]
|
||||
|
||||
Reference in New Issue
Block a user