From b6559b913a42401b75834e38102b2e886b08a51f Mon Sep 17 00:00:00 2001 From: AkiraFukushima Date: Tue, 26 Sep 2023 21:29:15 +0900 Subject: [PATCH] Ignore notifications that does not have account field --- src-tauri/src/streaming.rs | 24 ++++++++++++---------- src/components/timelines/Notifications.tsx | 2 +- 2 files changed, 14 insertions(+), 12 deletions(-) diff --git a/src-tauri/src/streaming.rs b/src-tauri/src/streaming.rs index 0b9d802c..12c40ee2 100644 --- a/src-tauri/src/streaming.rs +++ b/src-tauri/src/streaming.rs @@ -71,7 +71,7 @@ pub async fn start_user( ); let instance = client.get_instance().await.map_err(|e| e.to_string())?; let Some(urls) = instance.json.urls else { - return Err("Streaming does not exist".to_string()) + return Err("Streaming does not exist".to_string()); }; let streaming_url = urls.streaming_api; @@ -100,15 +100,17 @@ pub async fn start_user( } Message::Notification(mes) => { log::debug!("receive notification"); - app_handle - .emit_all( - "receive-notification", - ReceiveNotificationPayload { - server_id, - notification: mes, - }, - ) - .expect("Failed to send receive-notification event"); + if mes.account.is_some() { + app_handle + .emit_all( + "receive-notification", + ReceiveNotificationPayload { + server_id, + notification: mes, + }, + ) + .expect("Failed to send receive-notification event"); + } } Message::StatusUpdate(mes) => { log::debug!("receive status updated"); @@ -160,7 +162,7 @@ pub async fn start( ); let instance = client.get_instance().await.map_err(|e| e.to_string())?; let Some(urls) = instance.json.urls else { - return Err("Streaming does not exist".to_string()) + return Err("Streaming does not exist".to_string()); }; let streaming_url = urls.streaming_api; diff --git a/src/components/timelines/Notifications.tsx b/src/components/timelines/Notifications.tsx index 38baf67f..35b5dba7 100644 --- a/src/components/timelines/Notifications.tsx +++ b/src/components/timelines/Notifications.tsx @@ -125,7 +125,7 @@ const Notifications: React.FC = props => { options = Object.assign({}, options, { max_id: maxId }) } const res = await client.getNotifications(options) - return res.data + return res.data.filter(n => !!n.account) } const closeOptionPopover = () => triggerRef?.current.close()