Opera10 commited on
Commit
c567e30
·
verified ·
1 Parent(s): adaa59b

Update templates/index.html

Browse files
Files changed (1) hide show
  1. templates/index.html +32 -0
templates/index.html CHANGED
@@ -1415,6 +1415,38 @@
1415
  document.querySelectorAll('.popover-menu').forEach(m => m.classList.remove('show'));
1416
  }
1417
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1418
  function openPremiumModal() {
1419
  document.getElementById('modalOverlay').classList.add('open');
1420
  document.getElementById('premiumModal').classList.add('open');
 
1415
  document.querySelectorAll('.popover-menu').forEach(m => m.classList.remove('show'));
1416
  }
1417
 
1418
+ // تابع تایید و حذف نهایی گفتگو و پیام‌ها از حافظه دیتابیس
1419
+ function confirmDeleteSession() {
1420
+ if (!sessionToDelete) return;
1421
+
1422
+ const tx = db.transaction(['sessions', 'messages'], 'readwrite');
1423
+ const sessionStore = tx.objectStore('sessions');
1424
+ const msgStore = tx.objectStore('messages');
1425
+
1426
+ // حذف جلسه از منو
1427
+ sessionStore.delete(sessionToDelete);
1428
+
1429
+ // حذف پیام‌های متصل به این جلسه
1430
+ const index = msgStore.index('sessionId');
1431
+ const request = index.getAll(sessionToDelete);
1432
+
1433
+ request.onsuccess = () => {
1434
+ request.result.forEach(msg => {
1435
+ msgStore.delete(msg.id);
1436
+ });
1437
+ };
1438
+
1439
+ tx.oncomplete = () => {
1440
+ // اگر گفتگوی در حال حذف فعال بود، صفحه چت خالی شود
1441
+ if (currentSessionId === sessionToDelete) {
1442
+ startNewSession();
1443
+ }
1444
+ closeAllModals();
1445
+ loadSessionsToMenu();
1446
+ };
1447
+ }
1448
+ // -----------------------
1449
+
1450
  function openPremiumModal() {
1451
  document.getElementById('modalOverlay').classList.add('open');
1452
  document.getElementById('premiumModal').classList.add('open');