chore(ui): remove debugging logs for sse connection
All checks were successful
Build MIPS Binary / build (push) Successful in 1m56s

This commit is contained in:
spinline
2026-02-21 00:44:50 +03:00
parent 566308d889
commit 50b83ebacf

View File

@@ -88,13 +88,10 @@ pub fn provide_torrent_store() {
let mut disconnect_notified = false;
loop {
log::info!("[SSE] Attempting to connect to /api/events...");
let es_result = EventSource::new("/api/events");
match es_result {
Ok(mut es) => {
log::info!("[SSE] EventSource instantiated successfully.");
if let Ok(mut stream) = es.subscribe("message") {
log::info!("[SSE] Subscribed to 'message' events.");
let mut got_first_message = false;
while let Some(Ok((_, msg))) = stream.next().await {
if !got_first_message {
@@ -108,40 +105,29 @@ pub fn provide_torrent_store() {
}
if let Some(data_str) = msg.data().as_string() {
log::info!("[SSE] Received message: {:?}", data_str.chars().take(50).collect::<String>());
match BASE64.decode(&data_str) {
Ok(bytes) => {
match rmp_serde::from_slice::<AppEvent>(&bytes) {
Ok(event) => {
match event {
AppEvent::FullList(list, _) => {
torrents_for_sse.update(|map| {
let new_hashes: std::collections::HashSet<String> = list.iter().map(|t| t.hash.clone()).collect();
map.retain(|hash, _| new_hashes.contains(hash));
for new_torrent in list { map.insert(new_torrent.hash.clone(), new_torrent); }
});
}
AppEvent::Update(patch) => {
if let Some(hash) = patch.hash.clone() {
torrents_for_sse.update(|map| { if let Some(t) = map.get_mut(&hash) { t.apply(patch); } });
}
}
AppEvent::Stats(stats) => { global_stats_for_sse.set(stats); }
AppEvent::Notification(n) => {
show_toast(n.level.clone(), n.message.clone());
if n.message.contains("tamamlandı") || n.level == shared::NotificationLevel::Error {
show_browser_notification("VibeTorrent", &n.message);
}
}
if let Ok(bytes) = BASE64.decode(&data_str) {
if let Ok(event) = rmp_serde::from_slice::<AppEvent>(&bytes) {
match event {
AppEvent::FullList(list, _) => {
torrents_for_sse.update(|map| {
let new_hashes: std::collections::HashSet<String> = list.iter().map(|t| t.hash.clone()).collect();
map.retain(|hash, _| new_hashes.contains(hash));
for new_torrent in list { map.insert(new_torrent.hash.clone(), new_torrent); }
});
}
AppEvent::Update(patch) => {
if let Some(hash) = patch.hash.clone() {
torrents_for_sse.update(|map| { if let Some(t) = map.get_mut(&hash) { t.apply(patch); } });
}
}
AppEvent::Stats(stats) => { global_stats_for_sse.set(stats); }
AppEvent::Notification(n) => {
show_toast(n.level.clone(), n.message.clone());
if n.message.contains("tamamlandı") || n.level == shared::NotificationLevel::Error {
show_browser_notification("VibeTorrent", &n.message);
}
},
Err(e) => {
log::error!("[SSE] Failed to deserialize AppEvent: {:?}", e);
}
}
},
Err(e) => {
log::error!("[SSE] Failed to decode base64: {:?}", e);
}
}
}