Explorar el Código

Now "it" should work

Joeri Exelmans hace 4 años
padre
commit
dc7563f39f
Se han modificado 2 ficheros con 8 adiciones y 6 borrados
  1. 7 5
      lib/screenshare.js
  2. 1 1
      src/main/webapp/plugins/cdf/screenshare.js

+ 7 - 5
lib/screenshare.js

@@ -144,22 +144,24 @@ class ScreenShare {
       },
       "init_screenshare": (from, graphSerialized, reply) => {
         const yes = () => {
-          const cells = decodeCells(graphSerialized);
-          this.graph.model.clear();
-          this.graph.importCells(cells);
+          const doc = mxUtils.parseXml(graphSerialized);
+          const codec = new mxCodec(doc);
+          codec.decode(doc.documentElement, graph.model);
           this.sharingWith[from] = true;
           reply(); // acknowledge
+          this.alert("You are now <b>screen sharing</b> with " + shortUUID(from));
         };
         const no = () => {
           reply("denied")
         };
-        this.confirm(`Peer ${shortUUID(from)} wants to <b>screen share</b>.<br /><br />Accept?`, yes, no);
+        this.confirm(`Peer ${shortUUID(from)} wants to <b>screen share</b>.<br />Your diagram will be erased and replaced by his/hers.<br /><br />Accept?`, yes, no);
       },
     });
   }
 
   initshare(peer) {
-    const graphSerialized = encodeCells(Object.values(this.graph.model.cells));
+    const codec = new mxCodec();
+    const graphSerialized = mxUtils.getXml(codec.encode(this.graph.model));
     this.p2p.send(peer, "init_screenshare", graphSerialized, (err, data) => {
       if (err) {
         this.alert(err)

+ 1 - 1
src/main/webapp/plugins/cdf/screenshare.js

@@ -25,7 +25,7 @@ Draw.loadPlugin(async function(ui) {
   ui.menus.put('screenshare', new Menu(function(menu, parent) {
     if (peers.peers.length > 0) {
       peers.peers.forEach(peer => {
-        menu.addItem("Peer " + shortUUID(peer), null, () => screenShare.initshare(peer), menu);
+        menu.addItem("Peer " + shortUUID(peer), screenShare.sharingWith.hasOwnProperty(peer) ? Editor.checkmarkImage : null, () => screenShare.initshare(peer), menu);
       });
     } else {
       menu.addItem("No peers ", null, null, menu, null, false);