Skip to content

Commit

Permalink
Merge pull request #163 from rwth-acis/synchronization-issues
Browse files Browse the repository at this point in the history
Fix Synchronization issues
  • Loading branch information
lakhoune authored May 26, 2023
2 parents c32439a + d01b96c commit 78c7e56
Show file tree
Hide file tree
Showing 8 changed files with 17 additions and 24 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@rwth-acis/syncmeta-widgets",
"description": "SyncMeta is a near real-time collaborative modeling framework. This package only contains the used widgets. If you want to use the SyncMeta app in a docker container, see https://github.com/rwth-acis/syncmeta.",
"version": "2.4.3",
"version": "2.4.4",
"author": {
"name": "ACIS Group, RWTH Aachen",
"email": "[email protected]"
Expand Down
5 changes: 0 additions & 5 deletions src/es6/attribute_widget/Value.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,6 @@ class Value extends AbstractValue {
};

this.registerYType = (ytext) => {

if (!ytext) {
throw new Error("YText not found");
}
Expand All @@ -117,10 +116,6 @@ class Value extends AbstractValue {
_$editorRef,
window.yjsConnection.websocketProvider.awareness
);
_ytext?.observe(function () {
_value = _ytext.toString();
});
_value = _ytext.toString();
//loging
window.syncmetaLog.initializedYTexts += 1;
if (window.syncmetaLog.hasOwnProperty(this.getEntityId()))
Expand Down
22 changes: 11 additions & 11 deletions src/es6/canvas_widget/Manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -8610,14 +8610,7 @@ export class Value extends AbstractValue {
if (!yMap) {
throw new Error("yMap is undefined");
}
y.transact(() => {
if (!yMap.has(id) || !(yMap.get(id) instanceof YText)) {
_ytext = new YText();
yMap.set(id, _ytext);
} else {
_ytext = yMap.get(id);
}
});


var that = this;
/**
Expand All @@ -8641,8 +8634,6 @@ export class Value extends AbstractValue {
this.setValue = function (value) {
_value = value;
_$node.text(value);

this.value = _ytext.toString();
};

/**
Expand Down Expand Up @@ -8683,6 +8674,14 @@ export class Value extends AbstractValue {
};

this.registerYType = function () {
y.transact(() => {
if (!yMap.has(id) || !(yMap.get(id) instanceof YText)) {
_ytext = new YText(_value);
yMap.set(id, _ytext);
} else {
_ytext = yMap.get(id);
}
});
_ytext.observe(
_.debounce(function (event) {
_value = _ytext.toString().replace(/\n/g, "");
Expand Down Expand Up @@ -8713,8 +8712,9 @@ export class Value extends AbstractValue {
);
}, 500)
);

window.onbeforeunload = () => {
_ytext.unobserve()
_ytext.unobserve();
};
};

Expand Down
1 change: 0 additions & 1 deletion src/es6/canvas_widget/MultiValue.js
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,6 @@ export class MultiValue extends AbstractValue {
}
);
}
EntityManagerInstance.storeDataYjs();
});
//initialize the map with the values
for (const [key, value] of Object.entries(this._value)) {
Expand Down
2 changes: 1 addition & 1 deletion src/es6/lib/yjs-sync.js
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ export function getInstance({ spaceTitle, host, protocol, port }) {
});
}
window.onbeforeunload = function () {
window.yjsConnection.websocketProvider.destroy();
window.yjsConnection?.websocketProvider.destroy();
window.yjsConnection = null;
};
return window.yjsConnection;
Expand Down
3 changes: 1 addition & 2 deletions src/es6/shared.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
intent_listener.push(f);
};
window._reloadPage = function () {
console.log("Reloading Everything");
var message = {
action: "RELOAD",
component: "",
Expand All @@ -29,6 +28,7 @@
extras: {
reload: true,
},
sender: "syncmeta",
};
iwcClient.publishGlobal(message);
};
Expand Down Expand Up @@ -57,7 +57,6 @@
intent_listener.push(f);
};
window._reloadPage = function () {
console.log("Reloading Everything");
var message = {
action: "RELOAD",
component: "syncmeta",
Expand Down
2 changes: 1 addition & 1 deletion src/es6/shared.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ export default function () {
intent_listener.push(f);
};
window._reloadPage = function () {
console.log("Reloading Everything");
var message = {
action: "RELOAD",
component: "",
Expand All @@ -28,6 +27,7 @@ export default function () {
extras: {
reload: true,
},
sender: "syncmeta",
};
iwcClient.publish(message);
};
Expand Down

0 comments on commit 78c7e56

Please sign in to comment.