make sure no dupes
This commit is contained in:
@@ -530,7 +530,7 @@ class Channel extends SnowFlake {
|
|||||||
}
|
}
|
||||||
return this.parent !== undefined;
|
return this.parent !== undefined;
|
||||||
}
|
}
|
||||||
calculateReorder() {
|
calculateReorder(numbset: Set<number>) {
|
||||||
let position = -1;
|
let position = -1;
|
||||||
const build: {
|
const build: {
|
||||||
id: string;
|
id: string;
|
||||||
@@ -544,9 +544,15 @@ class Channel extends SnowFlake {
|
|||||||
parent_id: string | undefined;
|
parent_id: string | undefined;
|
||||||
} = {id: thing.id, position: undefined, parent_id: undefined};
|
} = {id: thing.id, position: undefined, parent_id: undefined};
|
||||||
|
|
||||||
if (thing.position < position) {
|
if (thing.position <= position) {
|
||||||
thing.position = thisthing.position = position + 1;
|
thing.position = thisthing.position = position + 1;
|
||||||
}
|
}
|
||||||
|
while (numbset.has(thing.position)) {
|
||||||
|
thing.position++;
|
||||||
|
thisthing.position = thing.position;
|
||||||
|
console.log(thing.position - 1);
|
||||||
|
}
|
||||||
|
numbset.add(thing.position);
|
||||||
position = thing.position;
|
position = thing.position;
|
||||||
if (thing.move_id && thing.move_id !== thing.parent_id) {
|
if (thing.move_id && thing.move_id !== thing.parent_id) {
|
||||||
thing.parent_id = thing.move_id;
|
thing.parent_id = thing.move_id;
|
||||||
|
@@ -1163,6 +1163,7 @@ class Guild extends SnowFlake {
|
|||||||
position: number | undefined;
|
position: number | undefined;
|
||||||
parent_id: string | undefined | null;
|
parent_id: string | undefined | null;
|
||||||
}[] = [];
|
}[] = [];
|
||||||
|
const numbset = new Set<number>();
|
||||||
for (const thing of this.headchannels) {
|
for (const thing of this.headchannels) {
|
||||||
const thisthing: {
|
const thisthing: {
|
||||||
id: string;
|
id: string;
|
||||||
@@ -1172,6 +1173,12 @@ class Guild extends SnowFlake {
|
|||||||
if (thing.position <= position) {
|
if (thing.position <= position) {
|
||||||
thing.position = thisthing.position = position + 1;
|
thing.position = thisthing.position = position + 1;
|
||||||
}
|
}
|
||||||
|
while (numbset.has(thing.position)) {
|
||||||
|
thing.position++;
|
||||||
|
thisthing.position = thing.position;
|
||||||
|
console.log(thing.position - 1);
|
||||||
|
}
|
||||||
|
numbset.add(thing.position);
|
||||||
position = thing.position;
|
position = thing.position;
|
||||||
console.log(position);
|
console.log(position);
|
||||||
if (thing.move_id && thing.move_id !== thing.parent_id) {
|
if (thing.move_id && thing.move_id !== thing.parent_id) {
|
||||||
@@ -1183,7 +1190,7 @@ class Guild extends SnowFlake {
|
|||||||
build.push(thisthing);
|
build.push(thisthing);
|
||||||
}
|
}
|
||||||
if (thing.children.length > 0) {
|
if (thing.children.length > 0) {
|
||||||
const things = thing.calculateReorder();
|
const things = thing.calculateReorder(numbset);
|
||||||
for (const thing of things) {
|
for (const thing of things) {
|
||||||
build.push(thing);
|
build.push(thing);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user