Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/text.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJulius Härtl <jus@bitgrid.net>2019-05-15 16:42:33 +0300
committerJulius Härtl <jus@bitgrid.net>2019-05-27 19:44:50 +0300
commit6016c09079800a5cdae4704109ee1a2f180a8b5e (patch)
tree0658ef2b26a38d757cdc06ad15f43c535caa13b2 /src/services
parentbd0818afd9803465fd8a54839342d6bc597f82d8 (diff)
Try to pull in tiptap
Signed-off-by: Julius Härtl <jus@bitgrid.net>
Diffstat (limited to 'src/services')
-rw-r--r--src/services/PollingBackend.js15
-rw-r--r--src/services/SyncService.js18
2 files changed, 19 insertions, 14 deletions
diff --git a/src/services/PollingBackend.js b/src/services/PollingBackend.js
index 26cfad284..df00cd206 100644
--- a/src/services/PollingBackend.js
+++ b/src/services/PollingBackend.js
@@ -116,7 +116,7 @@ class PollingBackend {
return
}
- this._authority._receiveSteps(response.data.steps)
+ this._authority._receiveSteps(response.data)
this.lock = false
this._forcedSave = false
this.resetRefetchTimer()
@@ -137,23 +137,24 @@ class PollingBackend {
this._forcedSave = false
}
- sendSteps(sendable) {
+ sendSteps(_sendable) {
this._authority.emit('stateChange', { dirty: true })
if (this.lock) {
setTimeout(() => {
- this._authority.sendSteps(sendable)
+ this._authority.sendSteps(_sendable)
}, 100)
return
}
this.lock = true
const authority = this
+ let sendable = (typeof _sendable === 'function') ? _sendable() : _sendable;
let steps = sendable.steps
axios.post(endpointUrl('session/push', !!this._authority.options.shareToken), {
documentId: this._authority.document.id,
sessionId: this._authority.session.id,
sessionToken: this._authority.session.token,
- steps: steps.map(s => s.toJSON()) || [],
- version: this._authority._getVersion(),
+ steps: steps.map(s => s.toJSON ? s.toJSON() : s) || [],
+ version: sendable.version,
token: this._authority.options.shareToken
}).then((response) => {
this._authority.emit('stateChange', { dirty: false })
@@ -165,9 +166,9 @@ class PollingBackend {
this.lock = false
this._fetchSteps()
- this.carefulRetry(() => {
+ /*this.carefulRetry(() => {
this.sendSteps(sendable)
- })
+ })*/
})
}
diff --git a/src/services/SyncService.js b/src/services/SyncService.js
index 88a8a6860..46f4338ca 100644
--- a/src/services/SyncService.js
+++ b/src/services/SyncService.js
@@ -28,7 +28,6 @@ import {getVersion, sendableSteps} from 'prosemirror-collab'
const defaultOptions = {
shareToken: null,
- schema: null,
serialize: (document) => document
};
@@ -131,8 +130,8 @@ class SyncService {
)
}
- sendSteps() {
- let sendable = sendableSteps(this.state)
+ sendSteps(_sendable) {
+ let sendable = _sendable ? _sendable : sendableSteps(this.state)
if (!sendable) {
return
}
@@ -146,15 +145,20 @@ class SyncService {
}
}
- _receiveSteps(steps) {
+ _receiveSteps({steps, document}) {
+ let newSteps = []
for (let i = 0; i < steps.length; i++) {
- let singleSteps = steps[i].data.map(j => Step.fromJSON(this.options.schema, j))
+ let singleSteps = steps[i].data
singleSteps.forEach(step => {
this.steps.push(step)
- this.stepClientIDs.push(steps[i].sessionId)
+ newSteps.push({
+ step,
+ clientID: steps[i].sessionId
+ })
})
}
- this.emit('sync', steps)
+ this.emit('sync', {steps: newSteps, document})
+ console.log('receivedSteps', 'newVersion', getVersion(this.state))
}
_getVersion() {