more reodering fixes
This commit is contained in:
parent
169f56b5c5
commit
f0fd2e59b3
4 changed files with 30 additions and 35 deletions
2
build.ts
2
build.ts
|
@ -79,7 +79,7 @@ await build();
|
|||
if (process.argv.includes("watch")) {
|
||||
let last = Date.now();
|
||||
(async () => {
|
||||
for await (const thing of fs.watch(path.join(__dirname, "src"))) {
|
||||
for await (const thing of fs.watch(path.join(__dirname, "src"), {recursive: true})) {
|
||||
if (Date.now() - last < 100) {
|
||||
continue;
|
||||
}
|
||||
|
|
|
@ -530,8 +530,7 @@ class Channel extends SnowFlake {
|
|||
}
|
||||
return this.parent !== undefined;
|
||||
}
|
||||
calculateReorder(numbset: Set<number>) {
|
||||
let position = -1;
|
||||
calculateReorder(position: number) {
|
||||
const build: {
|
||||
id: string;
|
||||
position: number | undefined;
|
||||
|
@ -544,16 +543,9 @@ class Channel extends SnowFlake {
|
|||
parent_id: string | undefined;
|
||||
} = {id: thing.id, position: undefined, parent_id: undefined};
|
||||
|
||||
if (thing.position <= position) {
|
||||
thing.position = thisthing.position = position + 1;
|
||||
if (thing.position != position) {
|
||||
thisthing.position = thing.position = position;
|
||||
}
|
||||
while (numbset.has(thing.position)) {
|
||||
thing.position++;
|
||||
thisthing.position = thing.position;
|
||||
console.log(thing.position - 1);
|
||||
}
|
||||
numbset.add(thing.position);
|
||||
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;
|
||||
|
@ -563,8 +555,9 @@ class Channel extends SnowFlake {
|
|||
if (thisthing.position || thisthing.parent_id) {
|
||||
build.push(thisthing);
|
||||
}
|
||||
position++;
|
||||
}
|
||||
return build;
|
||||
return [build, position] as const;
|
||||
}
|
||||
static dragged: [Channel, HTMLDivElement] | [] = [];
|
||||
html: WeakRef<HTMLElement> | undefined;
|
||||
|
@ -804,6 +797,7 @@ class Channel extends SnowFlake {
|
|||
}
|
||||
|
||||
coatDropDiv(div: HTMLDivElement, container: HTMLElement | false = false) {
|
||||
div.style.position = "relative";
|
||||
div.addEventListener("dragenter", (event) => {
|
||||
console.log("enter");
|
||||
event.preventDefault();
|
||||
|
@ -889,17 +883,16 @@ class Channel extends SnowFlake {
|
|||
div.after(Channel.dragged[1]);
|
||||
}
|
||||
} else {
|
||||
div = div.parentElement as HTMLDivElement;
|
||||
if (!div) return;
|
||||
div = div.parentElement as HTMLDivElement;
|
||||
if (!div) return;
|
||||
let tdiv = div.parentElement as HTMLDivElement;
|
||||
if (!tdiv) return;
|
||||
tdiv = tdiv.parentElement as HTMLDivElement;
|
||||
if (!tdiv) return;
|
||||
|
||||
console.log(div);
|
||||
Channel.dragged[1].remove();
|
||||
if (before) {
|
||||
div.before(Channel.dragged[1]);
|
||||
tdiv.before(Channel.dragged[1]);
|
||||
} else {
|
||||
div.after(Channel.dragged[1]);
|
||||
tdiv.after(Channel.dragged[1]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1157,40 +1157,36 @@ class Guild extends SnowFlake {
|
|||
console.log(build);
|
||||
}
|
||||
calculateReorder(movedId?: string) {
|
||||
let position = -1;
|
||||
const build: {
|
||||
let position = 0;
|
||||
type buildtype = {
|
||||
id: string;
|
||||
position: number | undefined;
|
||||
parent_id: string | undefined | null;
|
||||
}[] = [];
|
||||
const numbset = new Set<number>();
|
||||
}[];
|
||||
const build: buildtype = [];
|
||||
for (const thing of this.headchannels) {
|
||||
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;
|
||||
if (thing.position != position) {
|
||||
thisthing.position = thing.position = position;
|
||||
}
|
||||
while (numbset.has(thing.position)) {
|
||||
thing.position++;
|
||||
thisthing.position = thing.position;
|
||||
console.log(thing.position - 1);
|
||||
}
|
||||
numbset.add(thing.position);
|
||||
position = thing.position;
|
||||
|
||||
console.log(position);
|
||||
if (thing.move_id && thing.move_id !== thing.parent_id) {
|
||||
thing.parent_id = thing.move_id;
|
||||
thisthing.parent_id = thing.parent?.id;
|
||||
thing.move_id = undefined;
|
||||
}
|
||||
if (thisthing.position || thisthing.parent_id) {
|
||||
if (thisthing.position !== undefined || thisthing.parent_id) {
|
||||
build.push(thisthing);
|
||||
}
|
||||
position++;
|
||||
if (thing.children.length > 0) {
|
||||
const things = thing.calculateReorder(numbset);
|
||||
let things: buildtype;
|
||||
[things, position] = thing.calculateReorder(position);
|
||||
for (const thing of things) {
|
||||
build.push(thing);
|
||||
}
|
||||
|
|
|
@ -3056,6 +3056,12 @@ img.error::after {
|
|||
top: 0;
|
||||
left: 0;
|
||||
}
|
||||
.dragBottomView {
|
||||
position: relative;
|
||||
}
|
||||
.dragTopView {
|
||||
position: relative;
|
||||
}
|
||||
.dragTopView::after {
|
||||
content: "";
|
||||
width: 100%;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue