From f5ef62c6bb6c1c15ff8dc068f14c425dc302c794 Mon Sep 17 00:00:00 2001 From: Jakub Doka Date: Thu, 17 Oct 2024 15:48:22 +0200 Subject: [PATCH] fixing nasty bug --- depell/src/index.js | 17 +- depell/src/main.rs | 5 +- lang/README.md | 8 + lang/src/codegen.rs | 17 +- lang/tests/codegen_tests_arrays.txt | 29 ++- lang/tests/codegen_tests_generic_types.txt | 13 +- lang/tests/codegen_tests_struct_operators.txt | 173 ++++++++++++------ lang/tests/codegen_tests_struct_patterns.txt | 25 ++- lang/tests/codegen_tests_wide_ret.txt | 5 +- 9 files changed, 178 insertions(+), 114 deletions(-) diff --git a/depell/src/index.js b/depell/src/index.js index 304d317..5654892 100644 --- a/depell/src/index.js +++ b/depell/src/index.js @@ -331,10 +331,11 @@ function cacheInputs(target) { } } -function updaetTab() { +/** @param {string} [path] */ +function updaetTab(path) { for (const elem of document.querySelectorAll("button[hx-push-url]")) { if (elem instanceof HTMLButtonElement) - elem.disabled = elem.getAttribute("hx-push-url") === window.location.pathname; + elem.disabled = elem.getAttribute("hx-push-url") === (path ?? window.location.pathname); } } @@ -368,17 +369,11 @@ if (window.location.hostname === 'localhost') { document.body.addEventListener('htmx:afterSwap', (ev) => { if (!(ev.target instanceof HTMLElement)) never(); wireUp(ev.target); - if (ev.target.tagName == "MAIN") updaetTab(); + if (ev.target.tagName == "MAIN" || ev.target.tagName == "BODY") + updaetTab(ev['detail'].pathInfo.finalRequestPath); + console.log(ev); }); -//document.body.addEventListener('htmx:beforeSend', (ev) => { -// const target = ev.target; -// if (target instanceof HTMLButtonElement && target.hasAttribute("hx-push-url")) { -// -// document.getElementById("extra-style").textContent = `[hx-push-url="${target.getAttribute("hx-push-url")}"]{background: var(--primary)}` -// } -//}); - getFmtInstance().then(inst => { document.body.addEventListener('htmx:configRequest', (ev) => { const details = ev['detail']; diff --git a/depell/src/main.rs b/depell/src/main.rs index 1c71391..3aa6fd7 100644 --- a/depell/src/main.rs +++ b/depell/src/main.rs @@ -175,8 +175,8 @@ impl Page for Feed { let mut last_timestamp = None; for post in cursor { write!(buf, "{}", post).unwrap(); - last_timestamp = Some(post.timestamp); if buf.len() - base_len > MAX_FEED_SIZE { + last_timestamp = Some(post.timestamp); break; } } @@ -561,9 +561,6 @@ fn base(body: impl FnOnce(&mut String), path: &str, session: Option<&Session>) - - //