[lib.content-controller] added channel DELETE/CREATE/UPDATE [MUST TEST]
This commit is contained in:
parent
b76d2f8499
commit
40c0686400
|
@ -91,7 +91,7 @@ export default class ChannelController{
|
|||
for(let c of channels){
|
||||
|
||||
// add 'users' field (will be filled by GET channel/cid)
|
||||
c.users = [];
|
||||
!( c.users instanceof Array ) && ( c.users = [] );
|
||||
|
||||
this.list.push(c);
|
||||
|
||||
|
@ -235,7 +235,7 @@ export default class ChannelController{
|
|||
return false;
|
||||
|
||||
/* (3) Reload channel list */
|
||||
this.fetch();
|
||||
// this.fetch();
|
||||
|
||||
}.bind(this), auth.token);
|
||||
|
||||
|
@ -258,7 +258,7 @@ export default class ChannelController{
|
|||
gs.get.popup.hide();
|
||||
|
||||
/* (2) Reload channel list */
|
||||
this.fetch();
|
||||
// this.fetch();
|
||||
|
||||
}.bind(this), auth.token);
|
||||
|
||||
|
|
|
@ -254,13 +254,16 @@ export default class ContentController{
|
|||
---------------------------------------------------------*/
|
||||
for( let c of _dat.channels.rem ){
|
||||
|
||||
console.log(c);
|
||||
for( let ci in gs.get.channel.list ){
|
||||
|
||||
// gs.get.channel.dump({
|
||||
// id: parseInt(c.id),
|
||||
// label: c.name,
|
||||
// link: c.link
|
||||
// }, true);
|
||||
// 1. Local copy channel data
|
||||
let channel = gs.get.channel.list[ci];
|
||||
|
||||
// 2. If id matches -> REMOVE
|
||||
if( channel.id === c.id )
|
||||
gs.get.channel.list.splice(ci, 1);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
@ -273,11 +276,35 @@ export default class ContentController{
|
|||
gs.get.channel.dump({
|
||||
id: parseInt(c.id),
|
||||
label: c.name,
|
||||
link: c.link
|
||||
link: c.link,
|
||||
users: c.users || []
|
||||
}, true);
|
||||
|
||||
}
|
||||
|
||||
|
||||
/* (5) Manage channels UPDATE
|
||||
---------------------------------------------------------*/
|
||||
for( let c of _dat.channels.upd ){
|
||||
|
||||
for( let ci in gs.get.channel.list ){
|
||||
|
||||
// 1. Local copy channel data
|
||||
let channel = gs.get.channel.list[ci];
|
||||
|
||||
// 2. If id matches -> UPDATE
|
||||
if( channel.id === c.id ){
|
||||
|
||||
gs.get.channel.list[ci].label = c.name;
|
||||
gs.get.channel.list[ci].link = c.link;
|
||||
gs.get.channel.list[ci].users = c.users;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue