From bcf4dafcc58295ed27dbda0e35ff5196c2f3b306 Mon Sep 17 00:00:00 2001 From: xdrm-brackets Date: Tue, 3 Apr 2018 20:34:16 +0200 Subject: [PATCH] [lib.room-controller] fix sending { rid: } --- webpack/lib/channel-controller.js | 10 +++++----- webpack/lib/room-controller.js | 21 ++++++++++----------- 2 files changed, 15 insertions(+), 16 deletions(-) diff --git a/webpack/lib/channel-controller.js b/webpack/lib/channel-controller.js index 5a07feb..020f801 100644 --- a/webpack/lib/channel-controller.js +++ b/webpack/lib/channel-controller.js @@ -27,7 +27,7 @@ export default class ChannelController{ ---------------------------------------------------------*/ nav(channel_id=null){ - console.log(`channel.nav(${channel_id})`); + // console.log(`channel.nav(${channel_id})`); /* (1) Get channel data */ var channel = this.get(channel_id); @@ -48,7 +48,7 @@ export default class ChannelController{ gs.get.room.fetch(); /* (6) Open channel websocket */ - ( window.csock != null ) && csock.close(); + ( window.csock != null ) && csock.close(); window.csock = new wscd(`wss://ws.douscord.xdrm.io/channel/${channel.id}`, { token: auth.token }); csock.onreceive = (_dat) => { @@ -62,7 +62,7 @@ export default class ChannelController{ csock.bind(); /* (6) Log channel */ - console.log(`[channel.current] ${channel.link} (${channel.label})`); + // console.log(`[channel.current] ${channel.link} (${channel.label})`); return true; } @@ -76,7 +76,7 @@ export default class ChannelController{ * ---------------------------------------------------------*/ dump(channels){ - console.log(`channel.dump([${channels instanceof Array?channels.length:0}])`); + // console.log(`channel.dump([${channels instanceof Array?channels.length:0}])`); /* (1) Check @channels type */ if( !(channels instanceof Array) ) @@ -197,7 +197,7 @@ export default class ChannelController{ } /* (4) Emulate navigatation from URL */ - console.log(`[restore.channel] ${redirect_id}`); + // console.log(`[restore.channel] ${redirect_id}`); this.nav(redirect_id); }.bind(this), auth.token); diff --git a/webpack/lib/room-controller.js b/webpack/lib/room-controller.js index c1adf63..32f1f19 100644 --- a/webpack/lib/room-controller.js +++ b/webpack/lib/room-controller.js @@ -29,7 +29,7 @@ export default class RoomController{ * ---------------------------------------------------------*/ nav(type=null, id=null){ - console.log(`room.nav(${type}, ${id})`); + // console.log(`room.nav(${type}, ${id})`); /* (1) Try to get current room from id */ let room = this.get(type, id); @@ -38,21 +38,21 @@ export default class RoomController{ if( Object.keys(room).length == 0 ) return false; - /* (3) Close last room */ - - /* (4) Open new room */ - - /* (5) Update @active room */ + /* (3) Update @active room */ this[type].current = room.id; - /* (6) Update buffer */ + /* (4) Open new room */ + if( type === 'text' && csock instanceof wscd ) + csock.send({ buffer: { rid: room.id } }); + + /* (5) Update buffer */ this._buffer[type] = {}; for( let r of this[type].list ) if( r.id === this[type].current ) this._buffer[type] = r; - console.log(`[room.${type}.opened] ${room.name} (${room.id})`, room.id); + // console.log(`[room.${type}.opened] ${room.name} (${room.id})`, room.id); return true; @@ -76,7 +76,7 @@ export default class RoomController{ ---------------------------------------------------------*/ dump(rooms, append=false){ - console.log(`room.dump([${rooms instanceof Array?rooms.length:-1}])`); + // console.log(`room.dump([${rooms instanceof Array?rooms.length:-1}])`); /* (1) Check @rooms type */ if( !(rooms instanceof Array) ) @@ -149,7 +149,7 @@ export default class RoomController{ * ---------------------------------------------------------*/ get(type=null, id=null){ - console.log(`room.get(${type}, ${id})`); + // console.log(`room.get(${type}, ${id})`); /* (1) Manage invalid @type */ if( typeof type !== 'string' || this[type] == null ) @@ -208,7 +208,6 @@ export default class RoomController{ /* (3) Store channel users */ gs.get.content.cbuf.users = rs.channel.users; - }.bind(this), auth.token); }