fixing bugs for re-order
This commit is contained in:
parent
19f08a6408
commit
e79e4affb4
6 changed files with 74 additions and 44 deletions
|
@ -330,18 +330,18 @@ class Channel{
|
|||
}
|
||||
calculateReorder(){
|
||||
let position=-1;
|
||||
const build:{id:SnowFlake<Channel>,position:number|undefined,parent_id:SnowFlake<Channel>|undefined}[]=[];
|
||||
const build:{id:string,position:number|undefined,parent_id:string|undefined}[]=[];
|
||||
for(const thing of this.children){
|
||||
const thisthing:{id:SnowFlake<Channel>,position:number|undefined,parent_id:SnowFlake<Channel>|undefined}={id: thing.snowflake,position: undefined,parent_id: undefined};
|
||||
const thisthing:{id:string,position:number|undefined,parent_id:string|undefined}={id: thing.id,position: undefined,parent_id: undefined};
|
||||
if(thing.position<position){
|
||||
thing.position=thisthing.position=position+1;
|
||||
}
|
||||
position=thing.position;
|
||||
if(thing.move_id&&thing.move_id!==thing.parent_id){
|
||||
thing.parent_id=thing.move_id;
|
||||
thisthing.parent_id=thing.parent_id;
|
||||
thisthing.parent_id=thing.parent?.id;
|
||||
thing.move_id=null;
|
||||
console.log(this.guild.channelids[thisthing.parent_id.id]);
|
||||
//console.log(this.guild.channelids[thisthing.parent_id.id]);
|
||||
}
|
||||
if(thisthing.position||thisthing.parent_id){
|
||||
build.push(thisthing);
|
||||
|
@ -933,8 +933,15 @@ class Channel{
|
|||
updateChannel(json:channeljson){
|
||||
this.type=json.type;
|
||||
this.name=json.name;
|
||||
this.parent_id=SnowFlake.getSnowFlakeFromID(json.parent_id,Channel);
|
||||
this.parent=null;
|
||||
const parent=this.guild.channelids[json.parent_id];
|
||||
if(parent){
|
||||
this.parent=parent;
|
||||
this.parent_id=parent.snowflake;
|
||||
}else{
|
||||
this.parent=null;
|
||||
this.parent_id=null;
|
||||
}
|
||||
|
||||
this.children=[];
|
||||
this.guild_id=json.guild_id;
|
||||
this.messageids=new Map();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue