[lib.channel-controller] no more 'rooms' field [lib.room-controller] added all fields removed from [lib.channel-controller]
This commit is contained in:
parent
6a76d9cd6f
commit
ff4f26f903
|
@ -71,9 +71,8 @@ export default class ChannelController{
|
|||
this.list.splice(1);
|
||||
|
||||
/* (4) Apply new channels */
|
||||
this.buffer = {};
|
||||
for(let c of channels)
|
||||
( this.list.push(c) === 2 ) && ( this.buffer = c );
|
||||
this.list.push(c);
|
||||
|
||||
/* (5) Restore LAST */
|
||||
this.list.push(last_item);
|
||||
|
|
|
@ -10,7 +10,6 @@ export default class ContentController{
|
|||
*
|
||||
---------------------------------------------------------*/
|
||||
get cid(){ return gs.get.channel.current; }
|
||||
get cbuf(){ return gs.get.channel.buffer; }
|
||||
|
||||
|
||||
/* (3) Room ID binding
|
||||
|
|
|
@ -84,33 +84,30 @@ export default class RoomController{
|
|||
continue;
|
||||
|
||||
// {2} Ignore: if missing field //
|
||||
if( isNaN(r.rid) || typeof r.type !== 'string' )
|
||||
if( isNaN(r.rid) || typeof r.type !== 'string' || typeof r.name !== 'string' )
|
||||
continue;
|
||||
|
||||
// {3} Ignore if cannot find name in buffer //
|
||||
var name = null;
|
||||
gs.get.content.cbuf.room.map( (v) => { ( v.rid === r.rid ) && ( name = v.name ); });
|
||||
|
||||
if( name === null )
|
||||
continue;
|
||||
|
||||
// {4} Default: missing messages //
|
||||
// {3} Default: missing messages //
|
||||
if( !( r.messages instanceof Array) )
|
||||
r.messages = [];
|
||||
|
||||
// {5} Default: missing members //
|
||||
// {4} Default: missing members //
|
||||
if( !( r.members instanceof Array) )
|
||||
r.members = [];
|
||||
|
||||
|
||||
// {6} Ignore: not available type //
|
||||
// {5} Ignore: not available type //
|
||||
if( this[r.type] == null )
|
||||
continue;
|
||||
|
||||
// {7} store data
|
||||
this[r.type].list.push({ id: r.rid, name: name, type: r.type, messages: r.messages });
|
||||
// {6} store data
|
||||
this[r.type].list.push({
|
||||
id: r.rid,
|
||||
name: r.name,
|
||||
type: r.type,
|
||||
messages: r.messages
|
||||
});
|
||||
|
||||
// {8} redirect if first element
|
||||
// {7} redirect if first element
|
||||
if( !redirected && r.type == 'text' ){
|
||||
redirected = true;
|
||||
this.nav('text', r.rid);
|
||||
|
@ -186,7 +183,6 @@ export default class RoomController{
|
|||
return;
|
||||
|
||||
/* (2) Dump data */
|
||||
console.log(rs.channel.room);
|
||||
this.dump(rs.channel.room);
|
||||
|
||||
}.bind(this), auth.token);
|
||||
|
@ -213,10 +209,19 @@ export default class RoomController{
|
|||
return false;
|
||||
|
||||
/* (3) Try to create room in API */
|
||||
console.log(`POST /channel/${gs.get.content.cid}/room/${type}`);
|
||||
api.call(`POST /channel/room/${gs.get.content.cid}`, { type: type, name: name }, function(rs){
|
||||
|
||||
/* (4) Add room -> update VueJS */
|
||||
/* (1) Manage error */
|
||||
if( rs.error !== 0 || rs.rid == null )
|
||||
return false;
|
||||
|
||||
/* (2) Reload room list */
|
||||
this.fetch();
|
||||
|
||||
/* (3) Hide popup */
|
||||
gs.get.popup.hide();
|
||||
|
||||
}.bind(this), auth.token);
|
||||
|
||||
return true;
|
||||
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
|
||||
{
|
||||
"rid": 0,
|
||||
"type": "text",
|
||||
|
||||
"members": [1,3,5],
|
||||
|
||||
|
@ -32,6 +33,7 @@
|
|||
|
||||
{
|
||||
"rid": 1,
|
||||
"type": "text",
|
||||
|
||||
"members": [1,4],
|
||||
|
||||
|
|
Loading…
Reference in New Issue