[lib.channel-controller] invite(username) leave() remove()
This commit is contained in:
parent
0676b8d747
commit
dad14da4a8
|
@ -215,7 +215,7 @@ export default class ChannelController{
|
|||
gs.get.popup.hide();
|
||||
|
||||
/* (2) Manage error */
|
||||
if( rs.error !== 0 || rs.cid == null )
|
||||
if( rs.error !== 0 )
|
||||
return false;
|
||||
|
||||
/* (3) Reload channel list */
|
||||
|
@ -227,4 +227,73 @@ export default class ChannelController{
|
|||
|
||||
}
|
||||
|
||||
|
||||
/* (8) Removes the current channel
|
||||
*
|
||||
* @return removed<bool> Whether the channel has been removed
|
||||
*
|
||||
---------------------------------------------------------*/
|
||||
remove(){
|
||||
|
||||
/* (2) Try to remove channel in API */
|
||||
api.call(`DELETE /channel/${gs.get.content.cid}`, {}, function(rs){
|
||||
|
||||
/* (1) Hide popup */
|
||||
gs.get.popup.hide();
|
||||
|
||||
/* (2) Reload channel list */
|
||||
this.fetch();
|
||||
|
||||
}.bind(this), auth.token);
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/* (9) Invite a friend to the current channel
|
||||
*
|
||||
* @username<String> Username
|
||||
*
|
||||
---------------------------------------------------------*/
|
||||
invite(username=null) {
|
||||
|
||||
/* (1) Manage invalid @username */
|
||||
if( typeof username !== 'string' )
|
||||
return false;
|
||||
|
||||
/* (2) Try to remove channel in API */
|
||||
api.call(`POST /channel/subscribe/${gs.get.content.cid}/${username}`, {}, function(rs){
|
||||
|
||||
/* (1) Hide popup */
|
||||
gs.get.popup.hide();
|
||||
|
||||
}.bind(this), auth.token);
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/* (10) Leave the current channel
|
||||
*
|
||||
---------------------------------------------------------*/
|
||||
leave(){
|
||||
|
||||
/* (1) Try to leave channel in API */
|
||||
api.call(`DELETE /channel/subscribe/${gs.get.content.cid}`, {}, function(rs){
|
||||
|
||||
/* (1) Hide popup */
|
||||
gs.get.popup.hide();
|
||||
|
||||
/* (2) Reload channels */
|
||||
this.fetch();
|
||||
|
||||
|
||||
}.bind(this), auth.token);
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -105,7 +105,7 @@ export default class PopupController{
|
|||
/* (5) Remove channel */
|
||||
this.register('channel.remove', {
|
||||
reset(){ },
|
||||
submit(){ this.parent.loading = gs.get.channel.remove(); }
|
||||
submit(){ this.parent.loading = gs.get.channel.remove(gs.get.content.cid); }
|
||||
});
|
||||
|
||||
/* (6) Remove channel */
|
||||
|
@ -123,7 +123,7 @@ export default class PopupController{
|
|||
/* (7) Leave channel */
|
||||
this.register('channel.leave', {
|
||||
reset(){ },
|
||||
submit(){ this.parent.loading = gs.get.channel.remove(); }
|
||||
submit(){ this.parent.loading = gs.get.channel.leave(); }
|
||||
});
|
||||
|
||||
/* (8) Change password */
|
||||
|
|
Loading…
Reference in New Issue