Self-hosted AI workspace.
Python
Show chat uploads in gallery immediately
pewdiepie-archdaemon99c87c7c7e80
diff --git a/static/js/fileHandler.js b/static/js/fileHandler.jsindex b5d24d4cf..d59e8d601 100644--- a/static/js/fileHandler.js+++ b/static/js/fileHandler.js@@ -183,6 +183,10 @@ export async function uploadPending() {}const data = await res.json();uploaded = (data.files || []);+ if (uploaded.some(x => x && x.gallery_id)) {+ try { localStorage.setItem('gallery-fresh-chat-upload', String(Date.now())); } catch (_) {}+ window.dispatchEvent(new CustomEvent('gallery-refresh', { detail: { source: 'chat-upload' } }));+ }pendingFiles = []; // clear only on success// Stash the full meta (incl. width/height for images) on the module so// callers that want it can grab it via getLastUploadedMeta(). Keep thediff --git a/static/js/gallery.js b/static/js/gallery.jsindex 822d0c8ec..09abbe322 100644--- a/static/js/gallery.js+++ b/static/js/gallery.js@@ -14,7 +14,12 @@ let _open = false;let _galleryResizeHandler = null;// Auto-refresh gallery when new image is generated-window.addEventListener('gallery-refresh', () => {+window.addEventListener('gallery-refresh', (e) => {+ if (e?.detail?.source === 'chat-upload' && _sort !== 'recent') {+ _sort = 'recent';+ const sortSel = document.getElementById('gallery-sort');+ if (sortSel) sortSel.value = 'recent';+ }if (_open) _fetchLibrary(false);});let _items = [];@@ -1894,6 +1899,13 @@ export function openGallery() {if (_open) return;_open = true;_galleryCascaded = false; // replay the domino-in cascade on each open+ let _freshChatUpload = false;+ try {+ const ts = Number(localStorage.getItem('gallery-fresh-chat-upload') || '0');+ _freshChatUpload = ts > 0 && Date.now() - ts < 5 * 60 * 1000;+ if (_freshChatUpload) localStorage.removeItem('gallery-fresh-chat-upload');+ } catch (_) {}+ if (_freshChatUpload) _sort = 'recent';// State is preserved across close/reopen — filters, album, sort, items,// albums, people — so reopening the gallery feels instant. Use the search// input or "All" chip to clear the active filter.@@ -1955,9 +1967,9 @@ export function openGallery() {<option value="">All sources</option></select><select class="gallery-sort" id="gallery-sort">- <option value="shuffle">Random</option>- <option value="recent">Recent</option>- <option value="oldest">Oldest</option>+ <option value="shuffle"${_sort === 'shuffle' ? ' selected' : ''}>Random</option>+ <option value="recent"${_sort === 'recent' ? ' selected' : ''}>Recent</option>+ <option value="oldest"${_sort === 'oldest' ? ' selected' : ''}>Oldest</option></select><button class="gallery-select-btn gallery-toolbar-action" id="gallery-select-btn" title="Select for bulk actions"><span style="position:relative;top:1px;">Select</span></button></div>