Skip to content

Commit 0f701f4

Browse files
committed
tmp 2
1 parent ee4499c commit 0f701f4

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

src/tiptap.js

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -214,21 +214,30 @@ export default Base.extend({
214214
new Promise((resolve) => provider.on("synced", resolve, { once: true }));
215215
await synced();
216216

217+
// Attempt 1: Only if the y_doc is the same as the document on the provider object,
218+
// which I believe should be returned from the hocuspocus server.
219+
// The problem here is, that also for the second connection with another browser
220+
// returns true for the following if clause.
221+
if (y_doc === provider.document) {
222+
// Initialize the tiptap editor later with some initial content.
223+
config["content"] = getText();
224+
}
225+
226+
// Attempt 2: Only for the first connecting user.
227+
// The problem here is that I apparently do not reliably get the number of connected users.
228+
// With two browsers connecting, one time I get 0 users, one time 1 user, another time 2.
217229
const connected_users = [...provider.awareness.states.values()].map(
218230
(it) => it.user
219231
);
220-
221232
if (connected_users.length === 1) {
222-
// it's only me.
233+
// Initialize the tiptap editor later with some initial content.
223234
config["content"] = getText();
224235
log.info(`
225236
This is the main instance and gets text from textfield.
226237
Other connected user will get their text from the collaboration server.
227238
`);
228239
}
229240

230-
debugger;
231-
232241
console.log("provider");
233242
console.log(provider);
234243

0 commit comments

Comments
 (0)