diff --git a/webpack/lib/channel-controller.js b/webpack/lib/channel-controller.js index 7fc7bf0..f858217 100644 --- a/webpack/lib/channel-controller.js +++ b/webpack/lib/channel-controller.js @@ -224,9 +224,6 @@ export default class ChannelController{ if( rs.error !== 0 ) return false; - /* (3) Reload channel list */ - // this.fetch(); - }.bind(this), auth.token); return true; @@ -247,9 +244,6 @@ export default class ChannelController{ /* (1) Hide popup */ gs.get.popup.hide(); - /* (2) Reload channel list */ - // this.fetch(); - }.bind(this), auth.token); return true; diff --git a/webpack/lib/content-controller.js b/webpack/lib/content-controller.js index 84c6ad9..ebab335 100644 --- a/webpack/lib/content-controller.js +++ b/webpack/lib/content-controller.js @@ -84,11 +84,6 @@ export default class ContentController{ tmp_user.username = username; auth.user = tmp_user; - // update username in channel - for( let u in this.cbuf.users ) - if( this.cbuf.users[u].uid == this.uid ) - this.cbuf.users[u].username = username; - }.bind(this), auth.token); /* (4) Error */ @@ -338,7 +333,6 @@ export default class ContentController{ /* (4) Manage channels CREATE ---------------------------------------------------------*/ for( let c of _dat.channels.add ){ - console.log(c); gs.get.channel.dump([{ id: parseInt(c.id), @@ -370,6 +364,60 @@ export default class ContentController{ } + + + + let userset = gs.get.content.cbuf.users; + + + /* (6) Manage users DELETE + ---------------------------------------------------------*/ + for( let u of _dat.users.rem ){ + + for( let ui in userset ){ + + // 1. Local copy user data + let user = userset[ui]; + + // 2. If id matches -> REMOVE + if( user.uid === u.id ) + userset.splice(ui, 1); + + } + + } + + + + /* (7) Manage users CREATE + ---------------------------------------------------------*/ + for( let u of _dat.users.add ){ + + userset.push({ + uid: parseInt(u.id), + username: u.name + }); + + } + + + /* (8) Manage users UPDATE + ---------------------------------------------------------*/ + for( let u of _dat.users.upd ){ + + for( let ui in userset ){ + + // 1. Local copy user data + let user = userset[ui]; + + // 2. If id matches -> UPDATE + if( user.uid === u.id ) + userset[ui].username = u.name; + + } + + } + }