feat(pwa): add PWA support and browser notifications for critical events

This commit is contained in:
spinline
2026-02-05 22:25:31 +03:00
parent 480604a97a
commit 3efe60a0f0
8 changed files with 255 additions and 21 deletions

View File

@@ -213,7 +213,30 @@ pub fn provide_torrent_store() {
global_stats.set(stats);
}
AppEvent::Notification(n) => {
show_toast_with_signal(notifications, n.level, n.message);
// Show toast notification
show_toast_with_signal(notifications, n.level.clone(), n.message.clone());
// Show browser notification for critical events
// (torrent completed, connection lost/restored, errors)
let is_critical = n.message.contains("tamamlandı")
|| n.message.contains("Reconnected")
|| n.message.contains("yeniden kuruldu")
|| n.message.contains("Lost connection")
|| n.level == shared::NotificationLevel::Error;
if is_critical {
let title = match n.level {
shared::NotificationLevel::Success => "✅ VibeTorrent",
shared::NotificationLevel::Error => "❌ VibeTorrent",
shared::NotificationLevel::Warning => "⚠️ VibeTorrent",
shared::NotificationLevel::Info => " VibeTorrent",
};
crate::utils::notification::show_notification_if_enabled(
title,
&n.message
);
}
}
}
}