From 21c125471b96176bbee0ea8cb8e3ef3b708eb7eb Mon Sep 17 00:00:00 2001 From: ilotterytea Date: Tue, 30 Sep 2025 01:05:24 +0500 Subject: fix: uploaded file section doesn't appear after the first upload --- public/index.php | 16 +++++++++++++++- public/static/scripts/upload.js | 4 ++++ 2 files changed, 19 insertions(+), 1 deletion(-) (limited to 'public') diff --git a/public/index.php b/public/index.php index e64dd65..735f49d 100644 --- a/public/index.php +++ b/public/index.php @@ -555,6 +555,8 @@ $privacy_exists = is_file($_SERVER['DOCUMENT_ROOT'] . '/static/PRIVACY.txt'); showFile(null); fileUploadWrapper.style.display = 'block'; fileURL.value = ''; + + document.querySelector('#uploaded-files').parentElement.style.display = 'grid'; }); const fileURLWrapper = document.querySelector('#form-upload-wrapper>div'); @@ -609,7 +611,19 @@ $privacy_exists = is_file($_SERVER['DOCUMENT_ROOT'] . '/static/PRIVACY.txt'); }); setFormDetailsVisiblity(false); - displayTab('file-tabs', 'uploaded-files'); + const uploadedFileCount = getUploadedFiles().length; + const favoriteFileCount = getFavoriteFiles().length; + if (uploadedFileCount > 0) { + document.querySelector('#uploaded-files').parentElement.style.display = 'grid'; + displayTab('file-tabs', 'uploaded-files'); + } + + if (favoriteFileCount > 0) { + document.querySelector('#favorite-files').parentElement.style.display = 'grid'; + if (uploadedFileCount == 0) { + displayTab('file-tabs', 'favorite-files'); + } + } diff --git a/public/static/scripts/upload.js b/public/static/scripts/upload.js index 226257d..72b8ef5 100644 --- a/public/static/scripts/upload.js +++ b/public/static/scripts/upload.js @@ -67,6 +67,10 @@ function createUploadedFileItem(data) { const btn = document.createElement("button"); btn.addEventListener("click", () => { deleteUploadedFile(data.urls.deletion_url, data.id); + base.remove(); + if (getUploadedFiles().length == 0) { + document.querySelector('#uploaded-files').parentElement.style.display = 'none'; + } }); const img = document.createElement("img"); -- cgit v1.2.3