diff --git a/webpack/lib/channel-controller.js b/webpack/lib/channel-controller.js index da5fce5..323be7d 100644 --- a/webpack/lib/channel-controller.js +++ b/webpack/lib/channel-controller.js @@ -14,6 +14,9 @@ export class ChannelController{ { id: -2, link: null, label: 'add', sub: null, icon: 'add', room: [], add: 1 } ]; + /* (3) Initialize channel data buffer */ + this.buffer = {}; + } @@ -170,8 +173,7 @@ export class ChannelController{ /* (2) Call API to get data */ setTimeout(() => { - let fetched = require('../mockup/api-channel-init.json'); - gs.get.main = fetched; + this.buffer = require('../mockup/api-channel-init.json'); }, 500); diff --git a/webpack/lib/content-controller.js b/webpack/lib/content-controller.js index 7ac0f45..1d91075 100644 --- a/webpack/lib/content-controller.js +++ b/webpack/lib/content-controller.js @@ -3,20 +3,47 @@ export class ContentController{ /* (1) Construct default attributes * ---------------------------------------------------------*/ - constructor(){ - /* (1) Initialize content data */ - this.messages = []; - this.users = []; + constructor(){} - } - - - /* (2) Getters + /* (2) Channel bindings + * + ---------------------------------------------------------*/ + get cid(){ return gs.get.channel.current; } + get cbuf(){ return gs.get.channel.buffer; } + + + /* (3) Room ID binding * ---------------------------------------------------------*/ - get cid(){ return gs.get.channel.current; } get rid(){ return gs.get.room.text.current; } + /* (4) Room buffer binding + * + ---------------------------------------------------------*/ + get rbuf(){ + + /* (1) Ignore: if no rooms empty */ + if( this.cbuf.room == null || this.cbuf.room.length === 0 ) + return {}; + + /* (2) Search for current room */ + for( let r of this.cbuf.room ){ + + // Return if room found // + if( r.rid === this.rid ) + return r; + + } + + + /* (3) If nothing found */ + return {}; + + } + + get messages(){ return this.rbuf.messages; } + get members(){ return this.rbuf.members; } + } \ No newline at end of file diff --git a/webpack/lib/room-controller.js b/webpack/lib/room-controller.js index 3ebdb05..8f53a21 100644 --- a/webpack/lib/room-controller.js +++ b/webpack/lib/room-controller.js @@ -147,4 +147,5 @@ export class RoomController{ } + } \ No newline at end of file diff --git a/webpack/vue/channel.vue b/webpack/vue/channel.vue index 8e65a97..412cb6e 100644 --- a/webpack/vue/channel.vue +++ b/webpack/vue/channel.vue @@ -7,6 +7,9 @@
+
+ {{ msg.msg }} +