From fa36bb72aa47cc2f61cc22db273a86c9169eff19 Mon Sep 17 00:00:00 2001 From: Thomas Mathews Date: Mon, 9 Jan 2023 11:53:30 -0800 Subject: [PATCH] Fix to close modal & reply input --- index.html | 10 ++++------ js/ui/state.js | 8 ++++++++ js/ui/util.js | 9 ++------- 3 files changed, 14 insertions(+), 13 deletions(-) diff --git a/index.html b/index.html index 4e371c9..d1941a9 100644 --- a/index.html +++ b/index.html @@ -257,18 +257,16 @@ diff --git a/js/ui/state.js b/js/ui/state.js index 2449ff9..f2c5d99 100644 --- a/js/ui/state.js +++ b/js/ui/state.js @@ -488,6 +488,14 @@ function init_postbox(model) { find_node("button[role='send']").addEventListener("click", onclick_send); find_node("button[role='toggle-cw']") .addEventListener("click", onclick_toggle_cw); + // Do reply box + // TODO refactor & cleanup reply modal init + find_node("#reply-content").addEventListener("input", oninput_post); + find_node("#reply-button").addEventListener("click", onclick_reply); +} +async function onclick_reply(ev) { + // Temp method + do_send_reply(); } async function onclick_send(ev) { const el = view_get_timeline_el(); diff --git a/js/ui/util.js b/js/ui/util.js index dbc7ab0..30cef1e 100644 --- a/js/ui/util.js +++ b/js/ui/util.js @@ -77,11 +77,6 @@ function close_media_preview() { find_node("#media-preview").classList.add("closed"); } -function close_reply() { - const modal = document.querySelector("#reply-modal") - modal.classList.add("closed"); -} - function delete_post_confirm(evid) { if (!confirm("Are you sure you want to delete this post?")) return; @@ -100,7 +95,7 @@ async function do_send_reply() { const content = reply_content_el.value; await send_reply(content, evid, all); reply_content_el.value = ""; - close_reply(); + close_modal(modal); } function reply(evid, all=false) { @@ -204,7 +199,7 @@ function open_faqs() { } function close_modal(el) { - while (el.parentElement) { + while (el) { if (el.classList.contains("modal")) { el.classList.add("closed"); break;