-
Notifications
You must be signed in to change notification settings - Fork 110
enh: store awareness messages separately #3776
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
Merged
Merged
Changes from 1 commit
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
4fce40b
enh: store awareness messages separately
max-nextcloud bc8c78c
perf(ApiService): return early if steps are empty
max-nextcloud 88b6fa7
fix: handle awareness messages without steps
max-nextcloud ffaf7bb
fix: adjust cypress tests to session api changes
max-nextcloud e89201f
Compile assets
nextcloud-command 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
Next
Next commit
enh: store awareness messages separately
Signed-off-by: Max <[email protected]>
- Loading branch information
commit 4fce40bb616174c5e6281a1cb851b2af54abd0fa
There are no files selected for viewing
This file contains hidden or 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 |
|---|---|---|
|
|
@@ -11,7 +11,7 @@ | |
| - **💾 Open format:** Files are saved as [Markdown](https://en.wikipedia.org/wiki/Markdown), so you can edit them from any other text app too. | ||
| - **✊ Strong foundation:** We use [🐈 tiptap](https://tiptap.scrumpy.io) which is based on [🦉 ProseMirror](https://prosemirror.net) – huge thanks to them! | ||
| ]]></description> | ||
| <version>3.7.0</version> | ||
| <version>3.7.1</version> | ||
| <licence>agpl</licence> | ||
| <author mail="[email protected]">Julius Härtl</author> | ||
| <namespace>Text</namespace> | ||
|
|
||
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| <?php | ||
|
|
||
| declare(strict_types=1); | ||
|
|
||
| namespace OCA\Text\Migration; | ||
|
|
||
| use Closure; | ||
| use OCP\DB\ISchemaWrapper; | ||
| use OCP\Migration\IOutput; | ||
| use OCP\Migration\SimpleMigrationStep; | ||
|
|
||
| /** | ||
| * Auto-generated migration step: Please modify to your needs! | ||
| */ | ||
| class Version030701Date20230207131313 extends SimpleMigrationStep { | ||
|
|
||
| /** | ||
| * @param IOutput $output | ||
| * @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper` | ||
| * @param array $options | ||
| * @return null|ISchemaWrapper | ||
| */ | ||
| public function changeSchema(IOutput $output, Closure $schemaClosure, array $options) { | ||
| /** @var ISchemaWrapper $schema */ | ||
| $schema = $schemaClosure(); | ||
|
|
||
| $table = $schema->getTable('text_sessions'); | ||
| if (!$table->hasColumn('last_awareness_message')) { | ||
| $table->addColumn('last_awareness_message', \OCP\DB\Types::TEXT, [ | ||
| 'notnull' => false, | ||
| 'default' => '' | ||
| ]); | ||
| return $schema; | ||
| } | ||
|
|
||
| return null; | ||
| } | ||
| } |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 |
|---|---|---|
|
|
@@ -88,19 +88,33 @@ export default function initWebSocketPolyfill(syncService, fileId, initialSessio | |
| } | ||
|
|
||
| #initiateSending() { | ||
| let steps | ||
| let outbox | ||
| syncService.sendSteps(() => { | ||
| steps = this.#queue.map(s => encodeArrayBuffer(s)) | ||
| outbox = this.#queue | ||
|
Member
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.
Collaborator
Author
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. I suspect this is due to us replaying old awareness messages and creating an inconstent state. |
||
| const data = { | ||
| steps: this.#steps, | ||
| awareness: this.#awareness, | ||
| version: this.#version, | ||
| } | ||
| this.#queue = [] | ||
| const version = this.#version | ||
| logger.debug('sending steps ', { version, steps }) | ||
| return { version, steps } | ||
| logger.debug('sending steps ', data) | ||
| return data | ||
| })?.catch(() => { | ||
| // try again | ||
| this.send(...steps) | ||
| // try to send the steps again | ||
| this.#queue = [...outbox, ...this.#queue] | ||
| }) | ||
| } | ||
|
|
||
| get #steps() { | ||
| return this.#queue.map(s => encodeArrayBuffer(s)) | ||
| .filter(s => s < 'AQ') | ||
| } | ||
|
|
||
| get #awareness() { | ||
| return this.#queue.map(s => encodeArrayBuffer(s)) | ||
| .findLast(s => s > 'AQ') || '' | ||
| } | ||
|
|
||
| close() { | ||
| Object.entries(this.#handlers) | ||
| .forEach(([key, value]) => syncService.off(key, value)) | ||
|
|
||
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.

Uh oh!
There was an error while loading. Please reload this page.