feat: toast notifications for all icon actions
- delete memory/preset/conversation/all/gallery/clear - save/reset profile - new chat, add preset, edit preset - clear file selection - rate up/down thumbs toasts
This commit is contained in:
+17
-2
@@ -706,6 +706,7 @@ async function deleteMemory(rowid) {
|
|||||||
if (currentRole !== 'admin') { requireAdminNotice(); return; }
|
if (currentRole !== 'admin') { requireAdminNotice(); return; }
|
||||||
if (!confirm('Delete this memory?')) return;
|
if (!confirm('Delete this memory?')) return;
|
||||||
try { await authFetch(`/api/memories/${rowid}`, { method: 'DELETE' }); } catch(e) { return; }
|
try { await authFetch(`/api/memories/${rowid}`, { method: 'DELETE' }); } catch(e) { return; }
|
||||||
|
showToast('Memory deleted');
|
||||||
await loadMemoryStats();
|
await loadMemoryStats();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -857,6 +858,7 @@ async function saveProfile() {
|
|||||||
try { await authFetch('/api/profile', { method: 'PUT', headers: {'Content-Type': 'application/json'}, body: JSON.stringify({ content: content }) }); } catch(e) { return; }
|
try { await authFetch('/api/profile', { method: 'PUT', headers: {'Content-Type': 'application/json'}, body: JSON.stringify({ content: content }) }); } catch(e) { return; }
|
||||||
cachedProfile = content;
|
cachedProfile = content;
|
||||||
updateTokenCount();
|
updateTokenCount();
|
||||||
|
showToast('Profile saved');
|
||||||
const btn = document.getElementById('saveProfileBtn');
|
const btn = document.getElementById('saveProfileBtn');
|
||||||
btn.textContent = 'Saved!';
|
btn.textContent = 'Saved!';
|
||||||
setTimeout(() => btn.textContent = 'Save Profile', 1500);
|
setTimeout(() => btn.textContent = 'Save Profile', 1500);
|
||||||
@@ -870,7 +872,8 @@ async function resetProfile() {
|
|||||||
const data = await resp.json();
|
const data = await resp.json();
|
||||||
document.getElementById('profileEditor').value = data.content;
|
document.getElementById('profileEditor').value = data.content;
|
||||||
await saveProfile();
|
await saveProfile();
|
||||||
} catch(e) {}
|
showToast('Profile reset');
|
||||||
|
} catch(e) { showToast('Profile reset failed'); }
|
||||||
}
|
}
|
||||||
|
|
||||||
function toggleProfile() { if (currentRole !== 'admin') { requireAdminNotice(); return; } profileEnabled = !profileEnabled; updateProfileUI(); saveSettings(); }
|
function toggleProfile() { if (currentRole !== 'admin') { requireAdminNotice(); return; } profileEnabled = !profileEnabled; updateProfileUI(); saveSettings(); }
|
||||||
@@ -1027,6 +1030,7 @@ async function addPreset() {
|
|||||||
const p = prompt('System prompt text:');
|
const p = prompt('System prompt text:');
|
||||||
if (!p) return;
|
if (!p) return;
|
||||||
try { await authFetch('/api/presets', { method: 'POST', headers: {'Content-Type': 'application/json'}, body: JSON.stringify({name, prompt: p}) }); } catch(e) { return; }
|
try { await authFetch('/api/presets', { method: 'POST', headers: {'Content-Type': 'application/json'}, body: JSON.stringify({name, prompt: p}) }); } catch(e) { return; }
|
||||||
|
showToast('Preset added');
|
||||||
await loadPresets();
|
await loadPresets();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1039,6 +1043,7 @@ async function editPreset(id) {
|
|||||||
const p = prompt('System prompt:', preset.prompt);
|
const p = prompt('System prompt:', preset.prompt);
|
||||||
if (p === null) return;
|
if (p === null) return;
|
||||||
try { await authFetch(`/api/presets/${id}`, { method: 'PUT', headers: {'Content-Type': 'application/json'}, body: JSON.stringify({name, prompt: p}) }); } catch(e) { return; }
|
try { await authFetch(`/api/presets/${id}`, { method: 'PUT', headers: {'Content-Type': 'application/json'}, body: JSON.stringify({name, prompt: p}) }); } catch(e) { return; }
|
||||||
|
showToast('Preset saved');
|
||||||
await loadPresets();
|
await loadPresets();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1046,6 +1051,7 @@ async function deletePreset(id) {
|
|||||||
if (currentRole !== 'admin') { requireAdminNotice(); return; }
|
if (currentRole !== 'admin') { requireAdminNotice(); return; }
|
||||||
if (!confirm('Delete this preset?')) return;
|
if (!confirm('Delete this preset?')) return;
|
||||||
try { await authFetch(`/api/presets/${id}`, { method: 'DELETE' }); } catch(e) { return; }
|
try { await authFetch(`/api/presets/${id}`, { method: 'DELETE' }); } catch(e) { return; }
|
||||||
|
showToast('Preset deleted');
|
||||||
await loadPresets();
|
await loadPresets();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1097,6 +1103,7 @@ async function deleteConversation(convId) {
|
|||||||
if (currentRole !== 'admin') { requireAdminNotice(); return; }
|
if (currentRole !== 'admin') { requireAdminNotice(); return; }
|
||||||
if (!confirm('Delete this conversation?')) return;
|
if (!confirm('Delete this conversation?')) return;
|
||||||
try { await authFetch(`/api/conversations/${convId}`, { method: 'DELETE' }); } catch(e) { return; }
|
try { await authFetch(`/api/conversations/${convId}`, { method: 'DELETE' }); } catch(e) { return; }
|
||||||
|
showToast('Conversation deleted');
|
||||||
if (currentConvId === convId) { currentConvId = null; showWelcome(); }
|
if (currentConvId === convId) { currentConvId = null; showWelcome(); }
|
||||||
await loadConversations();
|
await loadConversations();
|
||||||
}
|
}
|
||||||
@@ -1105,6 +1112,7 @@ async function deleteAllConversations() {
|
|||||||
if (currentRole !== 'admin') { requireAdminNotice(); return; }
|
if (currentRole !== 'admin') { requireAdminNotice(); return; }
|
||||||
if (!confirm('Delete ALL conversations? This cannot be undone.')) return;
|
if (!confirm('Delete ALL conversations? This cannot be undone.')) return;
|
||||||
try { await authFetch('/api/conversations', { method: 'DELETE' }); } catch(e) { return; }
|
try { await authFetch('/api/conversations', { method: 'DELETE' }); } catch(e) { return; }
|
||||||
|
showToast('All conversations deleted');
|
||||||
currentConvId = null;
|
currentConvId = null;
|
||||||
conversationHistory = [];
|
conversationHistory = [];
|
||||||
showWelcome();
|
showWelcome();
|
||||||
@@ -1116,6 +1124,7 @@ function newChat() {
|
|||||||
conversationHistory = [];
|
conversationHistory = [];
|
||||||
showWelcome();
|
showWelcome();
|
||||||
document.querySelectorAll('.conv-item').forEach(el => el.classList.remove('active'));
|
document.querySelectorAll('.conv-item').forEach(el => el.classList.remove('active'));
|
||||||
|
showToast('New conversation');
|
||||||
}
|
}
|
||||||
|
|
||||||
function escapeHtml(str) { const div = document.createElement('div'); div.textContent = str; return div.innerHTML; }
|
function escapeHtml(str) { const div = document.createElement('div'); div.textContent = str; return div.innerHTML; }
|
||||||
@@ -1246,6 +1255,7 @@ function clearFileSelection() {
|
|||||||
preview.classList.remove('visible');
|
preview.classList.remove('visible');
|
||||||
const thumb = document.getElementById('filePreviewThumb');
|
const thumb = document.getElementById('filePreviewThumb');
|
||||||
thumb.src = '';
|
thumb.src = '';
|
||||||
|
showToast('File removed');
|
||||||
}
|
}
|
||||||
function showGallery(convId) {
|
function showGallery(convId) {
|
||||||
document.getElementById('galleryOverlay').classList.add('visible');
|
document.getElementById('galleryOverlay').classList.add('visible');
|
||||||
@@ -1289,8 +1299,9 @@ async function deleteGalleryItem(contextId) {
|
|||||||
if (resp.ok) {
|
if (resp.ok) {
|
||||||
await loadGallery(currentConvId);
|
await loadGallery(currentConvId);
|
||||||
await loadConversations();
|
await loadConversations();
|
||||||
|
showToast('Attachment deleted');
|
||||||
}
|
}
|
||||||
} catch(e) {}
|
} catch(e) { showToast('Delete failed'); }
|
||||||
}
|
}
|
||||||
async function sendMessage() {
|
async function sendMessage() {
|
||||||
resetScrollLock();
|
resetScrollLock();
|
||||||
@@ -1547,17 +1558,21 @@ function addMessageToolbar(msgDiv) {
|
|||||||
upBtn.innerHTML = '👍';
|
upBtn.innerHTML = '👍';
|
||||||
upBtn.title = 'Rate up';
|
upBtn.title = 'Rate up';
|
||||||
upBtn.onclick = () => {
|
upBtn.onclick = () => {
|
||||||
|
const was = rating.value;
|
||||||
rating.value = rating.value === 1 ? 0 : 1;
|
rating.value = rating.value === 1 ? 0 : 1;
|
||||||
upBtn.classList.toggle('active', rating.value === 1);
|
upBtn.classList.toggle('active', rating.value === 1);
|
||||||
dnBtn.classList.toggle('active', false);
|
dnBtn.classList.toggle('active', false);
|
||||||
|
showToast(rating.value === 1 ? 'Rated up' : 'Rating removed');
|
||||||
};
|
};
|
||||||
const dnBtn = document.createElement('button');
|
const dnBtn = document.createElement('button');
|
||||||
dnBtn.innerHTML = '👎';
|
dnBtn.innerHTML = '👎';
|
||||||
dnBtn.title = 'Rate down';
|
dnBtn.title = 'Rate down';
|
||||||
dnBtn.onclick = () => {
|
dnBtn.onclick = () => {
|
||||||
|
const was = rating.value;
|
||||||
rating.value = rating.value === -1 ? 0 : -1;
|
rating.value = rating.value === -1 ? 0 : -1;
|
||||||
dnBtn.classList.toggle('active', rating.value === -1);
|
dnBtn.classList.toggle('active', rating.value === -1);
|
||||||
upBtn.classList.toggle('active', false);
|
upBtn.classList.toggle('active', false);
|
||||||
|
showToast(rating.value === -1 ? 'Rated down' : 'Rating removed');
|
||||||
};
|
};
|
||||||
toolbar.append(upBtn, dnBtn);
|
toolbar.append(upBtn, dnBtn);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user