From 983fe0073b66e8af4a5756f1834b71b870bfa326 Mon Sep 17 00:00:00 2001 From: xdrm-brackets Date: Thu, 5 Apr 2018 10:51:54 +0200 Subject: [PATCH] [lib.channel-controller] remove WebSocket creation -> moved to [lib.room-controller] when the room is fetched then dumped (only when full dump(), with append: false) --- webpack/lib/channel-controller.js | 3 --- webpack/lib/room-controller.js | 7 ++++++- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/webpack/lib/channel-controller.js b/webpack/lib/channel-controller.js index f858217..045ce7d 100644 --- a/webpack/lib/channel-controller.js +++ b/webpack/lib/channel-controller.js @@ -47,9 +47,6 @@ export default class ChannelController{ /* (5) Load rooms */ gs.get.room.fetch(); - /* (6) Open channel websocket */ - gs.get.content.ws_connect(); - /* (6) Log channel */ // console.log(`[channel.current] ${channel.link} (${channel.label})`); diff --git a/webpack/lib/room-controller.js b/webpack/lib/room-controller.js index 90bbdcf..2e6099e 100644 --- a/webpack/lib/room-controller.js +++ b/webpack/lib/room-controller.js @@ -47,7 +47,7 @@ export default class RoomController{ this[type].current = room.id; /* (5) Tell websocket: new text room */ - if( type === 'text' && csock instanceof wscd ) + if( type === 'text' && window.csock instanceof wscd ) csock.send({ buffer: { rid: room.id } }); /* (6) Update buffer */ @@ -139,6 +139,11 @@ export default class RoomController{ } } + /* (3) If full dump (append: false) -> create websocket */ + if( append !== true ) + gs.get.content.ws_connect(); + + return true; }