-
Notifications
You must be signed in to change notification settings - Fork 91
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Keep base version etag during reload #5941
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
98cb9bf
fix(sessionApi): only mark api as closed on success
max-nextcloud 6093128
fix(reconnect): keep baseVersionEtag during reconnect
max-nextcloud a4ea9fc
refactor: hide connection in sync service
max-nextcloud eb9dcbb
test(cy): wait longer for initial sync to avoid timeouts
max-nextcloud 97da812
test(cy): also test failed reconnect attempt
max-nextcloud e214f6f
fix(Editor): separate close and disconnect functions
max-nextcloud 13c580c
refactor(yjs): move queue handling into helper
max-nextcloud File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -354,12 +354,12 @@ export default { | |
} | ||
unsubscribe('text:image-node:add', this.onAddImageNode) | ||
unsubscribe('text:image-node:delete', this.onDeleteImageNode) | ||
unsubscribe('text:translate-modal:show', this.showTranslateModal) | ||
if (this.dirty) { | ||
const timeout = new Promise((resolve) => setTimeout(resolve, 2000)) | ||
await Promise.any([timeout, this.$syncService.save()]) | ||
} | ||
this.$providers.forEach(p => p.destroy()) | ||
unsubscribe('text:translate-modal:show', this.showTranslateModal) | ||
this.close() | ||
}, | ||
methods: { | ||
initSession() { | ||
|
@@ -373,7 +373,7 @@ export default { | |
guestName, | ||
shareToken: this.shareToken, | ||
filePath: this.relativePath, | ||
baseVersionEtag: this.$syncService?.baseVersionEtag, | ||
baseVersionEtag: this.$baseVersionEtag, | ||
forceRecreate: this.forceRecreate, | ||
serialize: this.isRichEditor | ||
? (content) => createMarkdownSerializer(this.$editor.schema).serialize(content ?? this.$editor.state.doc) | ||
|
@@ -383,8 +383,6 @@ export default { | |
|
||
this.listenSyncServiceEvents() | ||
|
||
this.$providers.forEach(p => p?.destroy()) | ||
this.$providers = [] | ||
const syncServiceProvider = createSyncServiceProvider({ | ||
ydoc: this.$ydoc, | ||
syncService: this.$syncService, | ||
|
@@ -432,7 +430,7 @@ export default { | |
reconnect() { | ||
this.contentLoaded = false | ||
this.hasConnectionIssue = false | ||
this.close().then(this.initSession) | ||
this.disconnect().then(this.initSession) | ||
this.idle = false | ||
}, | ||
|
||
|
@@ -487,7 +485,7 @@ export default { | |
}) | ||
}, | ||
|
||
onLoaded({ documentSource, documentState }) { | ||
onLoaded({ document, documentSource, documentState }) { | ||
if (documentState) { | ||
applyDocumentState(this.$ydoc, documentState, this.$providers[0]) | ||
// distribute additional state that may exist locally | ||
|
@@ -500,6 +498,7 @@ export default { | |
this.setInitialYjsState(documentSource, { isRichEditor: this.isRichEditor }) | ||
} | ||
|
||
this.$baseVersionEtag = document.baseVersionEtag | ||
this.hasConnectionIssue = false | ||
const language = extensionHighlight[this.fileExtension] || this.fileExtension; | ||
|
||
|
@@ -661,17 +660,19 @@ export default { | |
await this.$syncService.save() | ||
}, | ||
|
||
async disconnect() { | ||
await this.$syncService.close() | ||
this.unlistenSyncServiceEvents() | ||
this.$providers.forEach(p => p?.destroy()) | ||
this.$providers = [] | ||
this.$syncService = null | ||
// disallow editing while still showing the content | ||
this.readOnly = true | ||
}, | ||
|
||
Comment on lines
+663
to
+672
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There's no |
||
async close() { | ||
if (this.currentSession && this.$syncService) { | ||
try { | ||
await this.$syncService.close() | ||
this.unlistenSyncServiceEvents() | ||
this.currentSession = null | ||
this.$syncService = null | ||
} catch (e) { | ||
// Ignore issues closing the session since those might happen due to network issues | ||
} | ||
} | ||
await this.$syncService.sendRemainingSteps(this.$queue) | ||
await this.disconnect() | ||
if (this.$editor) { | ||
try { | ||
this.unlistenEditorEvents() | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
reconnect
callingdisconnect
rather than close now.