mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2024-11-22 01:36:29 -05:00
fix: retrieve read-only state for y-doc-sync-server-adapter from connection
Signed-off-by: Tilman Vatteroth <git@tilmanvatteroth.de>
This commit is contained in:
parent
29afcce555
commit
eebbb79d08
3 changed files with 5 additions and 5 deletions
|
@ -46,7 +46,7 @@ export class RealtimeConnection {
|
||||||
this.yDocSyncAdapter = new YDocSyncServerAdapter(
|
this.yDocSyncAdapter = new YDocSyncServerAdapter(
|
||||||
this.transporter,
|
this.transporter,
|
||||||
realtimeNote.getRealtimeDoc(),
|
realtimeNote.getRealtimeDoc(),
|
||||||
acceptEdits,
|
() => acceptEdits,
|
||||||
);
|
);
|
||||||
this.realtimeUserStateAdapter = new RealtimeUserStatusAdapter(
|
this.realtimeUserStateAdapter = new RealtimeUserStatusAdapter(
|
||||||
this.user?.username ?? null,
|
this.user?.username ?? null,
|
||||||
|
|
|
@ -105,13 +105,13 @@ describe('message transporter', () => {
|
||||||
const yDocSyncAdapterServerTo1 = new YDocSyncServerAdapter(
|
const yDocSyncAdapterServerTo1 = new YDocSyncServerAdapter(
|
||||||
transporterServerTo1,
|
transporterServerTo1,
|
||||||
docServer,
|
docServer,
|
||||||
true
|
() => true
|
||||||
)
|
)
|
||||||
|
|
||||||
const yDocSyncAdapterServerTo2 = new YDocSyncServerAdapter(
|
const yDocSyncAdapterServerTo2 = new YDocSyncServerAdapter(
|
||||||
transporterServerTo2,
|
transporterServerTo2,
|
||||||
docServer,
|
docServer,
|
||||||
true
|
() => true
|
||||||
)
|
)
|
||||||
|
|
||||||
const waitForClient1Sync = new Promise<void>((resolve) => {
|
const waitForClient1Sync = new Promise<void>((resolve) => {
|
||||||
|
|
|
@ -11,14 +11,14 @@ export class YDocSyncServerAdapter extends YDocSyncAdapter {
|
||||||
constructor(
|
constructor(
|
||||||
readonly messageTransporter: MessageTransporter,
|
readonly messageTransporter: MessageTransporter,
|
||||||
readonly doc: RealtimeDoc,
|
readonly doc: RealtimeDoc,
|
||||||
readonly acceptEdits: boolean
|
private readonly acceptEditsProvider: () => boolean
|
||||||
) {
|
) {
|
||||||
super(messageTransporter, doc)
|
super(messageTransporter, doc)
|
||||||
this.markAsSynced()
|
this.markAsSynced()
|
||||||
}
|
}
|
||||||
|
|
||||||
protected applyIncomingUpdatePayload(update: number[]): void {
|
protected applyIncomingUpdatePayload(update: number[]): void {
|
||||||
if (!this.acceptEdits) {
|
if (!this.acceptEditsProvider()) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
super.applyIncomingUpdatePayload(update)
|
super.applyIncomingUpdatePayload(update)
|
||||||
|
|
Loading…
Reference in a new issue