mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-14 21:27:20 +00:00
fix: seriailize update as list, not merge then on yrs side, which is broken
This commit is contained in:
@@ -42,11 +42,17 @@ export class TauriIPCProvider extends LocalProvider {
|
||||
|
||||
async #initDocFromIPC(workspaceID: string, doc: Y.Doc) {
|
||||
this._logger(`Loading ${workspaceID}...`);
|
||||
const updates = await ipcMethods.getYDocument({ id: workspaceID });
|
||||
if (updates) {
|
||||
const result = await ipcMethods.getYDocument({ id: workspaceID });
|
||||
if (result) {
|
||||
await new Promise(resolve => {
|
||||
doc.once('update', resolve);
|
||||
Y.applyUpdate(doc, new Uint8Array(updates.update));
|
||||
const updates = result.updates.map(
|
||||
binaryUpdate => new Uint8Array(binaryUpdate)
|
||||
);
|
||||
const mergedUpdate = Y.mergeUpdates(updates);
|
||||
// DEBUG: console mergedUpdate
|
||||
console.log(`mergedUpdate`, mergedUpdate);
|
||||
Y.applyUpdate(doc, new Uint8Array(mergedUpdate));
|
||||
});
|
||||
this._logger(`Loaded: ${workspaceID}`);
|
||||
}
|
||||
|
||||
@@ -12,6 +12,16 @@
|
||||
},
|
||||
"additionalProperties": false
|
||||
},
|
||||
{
|
||||
"type": "object",
|
||||
"required": ["CreateDocumentParameter"],
|
||||
"properties": {
|
||||
"CreateDocumentParameter": {
|
||||
"$ref": "#/definitions/CreateDocumentParameter"
|
||||
}
|
||||
},
|
||||
"additionalProperties": false
|
||||
},
|
||||
{
|
||||
"type": "object",
|
||||
"required": ["GetDocumentParameter"],
|
||||
@@ -34,6 +44,18 @@
|
||||
}
|
||||
],
|
||||
"definitions": {
|
||||
"CreateDocumentParameter": {
|
||||
"type": "object",
|
||||
"required": ["workspace_id", "workspace_name"],
|
||||
"properties": {
|
||||
"workspace_id": {
|
||||
"type": "string"
|
||||
},
|
||||
"workspace_name": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
},
|
||||
"GetDocumentParameter": {
|
||||
"type": "object",
|
||||
"required": ["id"],
|
||||
@@ -45,14 +67,17 @@
|
||||
},
|
||||
"GetDocumentResponse": {
|
||||
"type": "object",
|
||||
"required": ["update"],
|
||||
"required": ["updates"],
|
||||
"properties": {
|
||||
"update": {
|
||||
"updates": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "integer",
|
||||
"format": "uint8",
|
||||
"minimum": 0.0
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "integer",
|
||||
"format": "uint8",
|
||||
"minimum": 0.0
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,6 +9,9 @@ export type IDocumentParameters =
|
||||
| {
|
||||
YDocumentUpdate: YDocumentUpdate;
|
||||
}
|
||||
| {
|
||||
CreateDocumentParameter: CreateDocumentParameter;
|
||||
}
|
||||
| {
|
||||
GetDocumentParameter: GetDocumentParameter;
|
||||
}
|
||||
@@ -21,11 +24,16 @@ export interface YDocumentUpdate {
|
||||
update: number[];
|
||||
[k: string]: unknown;
|
||||
}
|
||||
export interface CreateDocumentParameter {
|
||||
workspace_id: string;
|
||||
workspace_name: string;
|
||||
[k: string]: unknown;
|
||||
}
|
||||
export interface GetDocumentParameter {
|
||||
id: string;
|
||||
[k: string]: unknown;
|
||||
}
|
||||
export interface GetDocumentResponse {
|
||||
update: number[];
|
||||
updates: number[][];
|
||||
[k: string]: unknown;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user