From f0fd2e59b3f7b6f22ddfaaaea63a93c124420141 Mon Sep 17 00:00:00 2001 From: MathMan05 Date: Fri, 2 May 2025 12:06:20 -0500 Subject: [PATCH] more reodering fixes --- build.ts | 2 +- src/webpage/channel.ts | 31 ++++++++++++------------------- src/webpage/guild.ts | 26 +++++++++++--------------- src/webpage/style.css | 6 ++++++ 4 files changed, 30 insertions(+), 35 deletions(-) diff --git a/build.ts b/build.ts index 845c6e0..3d34169 100644 --- a/build.ts +++ b/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; } diff --git a/src/webpage/channel.ts b/src/webpage/channel.ts index 47b7823..b47ee69 100644 --- a/src/webpage/channel.ts +++ b/src/webpage/channel.ts @@ -530,8 +530,7 @@ class Channel extends SnowFlake { } return this.parent !== undefined; } - calculateReorder(numbset: Set) { - 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 | 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]); } } } diff --git a/src/webpage/guild.ts b/src/webpage/guild.ts index 1ce5fe5..4277cb8 100644 --- a/src/webpage/guild.ts +++ b/src/webpage/guild.ts @@ -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(); + }[]; + 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); } diff --git a/src/webpage/style.css b/src/webpage/style.css index 2241239..04f5d99 100644 --- a/src/webpage/style.css +++ b/src/webpage/style.css @@ -3056,6 +3056,12 @@ img.error::after { top: 0; left: 0; } +.dragBottomView { + position: relative; +} +.dragTopView { + position: relative; +} .dragTopView::after { content: ""; width: 100%;