diff --git a/public/counter.html b/public/counter.html index 7e910cf02..681101db4 100644 --- a/public/counter.html +++ b/public/counter.html @@ -48,12 +48,8 @@ // 02. create a document then attach it into the client. const doc = new yorkie.Document('counter'); - doc.subscribe('my-presence', (event) => { - if (event.type === 'initialized') { - displayOnlineClients(doc.getPresences(), client.getID()); - } - }); - doc.subscribe('others', (event) => { + doc.subscribe('presence', (event) => { + if (event.type === 'presence-changed') return; displayOnlineClients(doc.getPresences(), client.getID()); }); diff --git a/public/drawing.html b/public/drawing.html index 7a0cc1ffe..b9d672d2a 100644 --- a/public/drawing.html +++ b/public/drawing.html @@ -50,16 +50,12 @@ // 02. create a document then attach it into the client. const doc = new yorkie.Document('drawing-panel'); - doc.subscribe('my-presence', (event) => { + doc.subscribe('presence', (event) => { displayOnlineClients(doc.getPresences(), client.getID()); - if (event.type === 'presence-changed' && doc.getRoot().shapes) { + if (event.type === 'presence-changed') { paintCanvas(); } }); - doc.subscribe('others', (event) => { - displayOnlineClients(doc.getPresences(), client.getID()); - paintCanvas(); - }); await client.attach(doc); let draftShape = null; @@ -77,6 +73,7 @@ context.clearRect(0, 0, 500, 500); const shapes = doc.getRoot().shapes; + if (!shapes) return; for (const shape of shapes) { context.beginPath(); let isMoved = false; diff --git a/public/index.html b/public/index.html index 0f53308b3..59b90e631 100644 --- a/public/index.html +++ b/public/index.html @@ -28,9 +28,6 @@