From e96bb2943469feb69e25938b376053cf85ba6af4 Mon Sep 17 00:00:00 2001 From: ZhenYi <434836402@qq.com> Date: Mon, 27 Apr 2026 11:01:59 +0800 Subject: [PATCH] fix: additional bugs - push notification unwraps and as any cleanup - Replace Option::unwrap() with let-chains for push subscription fields - Remove unsafe (repo as any).branch_count access in settings --- libs/service/lib.rs | 12 ++++-------- src/app/repository/settings/general.tsx | 2 +- 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/libs/service/lib.rs b/libs/service/lib.rs index 941ce95..0340dba 100644 --- a/libs/service/lib.rs +++ b/libs/service/lib.rs @@ -58,15 +58,11 @@ impl AppService { if let Ok(Some(prefs)) = prefs { if prefs.push_enabled - && prefs.push_subscription_endpoint.is_some() - && prefs.push_subscription_keys_p256dh.is_some() - && prefs.push_subscription_keys_auth.is_some() + && let Some(endpoint) = &prefs.push_subscription_endpoint + && let Some(p256dh) = &prefs.push_subscription_keys_p256dh + && let Some(auth) = &prefs.push_subscription_keys_auth { - let endpoint = prefs.push_subscription_endpoint.unwrap(); - let p256dh = prefs.push_subscription_keys_p256dh.unwrap(); - let auth = prefs.push_subscription_keys_auth.unwrap(); - - if let Err(e) = push.send(&endpoint, &p256dh, &auth, &payload).await { + if let Err(e) = push.send(endpoint, p256dh, auth, &payload).await { tracing::warn!(user_id = %user_id, error = %e, "WebPush send failed"); } } diff --git a/src/app/repository/settings/general.tsx b/src/app/repository/settings/general.tsx index 702f981..3b9db8b 100644 --- a/src/app/repository/settings/general.tsx +++ b/src/app/repository/settings/general.tsx @@ -269,7 +269,7 @@ export function RepoSettingsGeneral() {
{(repo as any).branch_count ?? 0}
+—