mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-11-14 14:13:43 +01:00
[web] save doc to sessionStorage while editing offline (#35519)
* save doc to session storage when offline * scope offline doc backup key to user id * clear offline doc backups on logout * handle anonymous users * include trackChanges GitOrigin-RevId: 3fe6a1523cb10cf76a1fcf4ee46790f6673bd84f
This commit is contained in:
@@ -29,6 +29,7 @@ import {
|
||||
import { ThreadId } from '../../../../../types/review-panel/review-panel'
|
||||
import getMeta from '@/utils/meta'
|
||||
import OError from '@overleaf/o-error'
|
||||
import { OfflineDocBackup } from '@/features/ide-react/editor/offline-doc-backup'
|
||||
import {
|
||||
HistoryOTShareDoc,
|
||||
ShareLatexOTShareDoc,
|
||||
@@ -104,6 +105,7 @@ export class DocumentContainer extends EventEmitter {
|
||||
doc?: ShareJsDoc
|
||||
cm6?: EditorFacade
|
||||
oldInflightOp?: ShareJsOperation
|
||||
private offlineBackup?: OfflineDocBackup
|
||||
|
||||
ranges?: _RangesTracker | RangesTrackerWithResolvedThreadIds
|
||||
|
||||
@@ -607,6 +609,8 @@ export class DocumentContainer extends EventEmitter {
|
||||
|
||||
this.detachDoc(this.doc_id, this)
|
||||
|
||||
this.offlineBackup?.destroy()
|
||||
|
||||
this.unBindFromEditorEvents()
|
||||
this.unBindFromSocketEvents()
|
||||
}
|
||||
@@ -616,6 +620,11 @@ export class DocumentContainer extends EventEmitter {
|
||||
return
|
||||
}
|
||||
|
||||
this.offlineBackup = new OfflineDocBackup(
|
||||
this.doc,
|
||||
getMeta('ol-project_id')
|
||||
)
|
||||
|
||||
this.doc.on('error', (error: Error, meta: ErrorMetadata) =>
|
||||
this.onError(error, meta)
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user