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
This commit is contained in:
ZhenYi 2026-04-27 11:01:59 +08:00
parent bdb5393835
commit e96bb29434
2 changed files with 5 additions and 9 deletions

View File

@ -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");
}
}

View File

@ -269,7 +269,7 @@ export function RepoSettingsGeneral() {
</div>
<div>
<Label className="text-muted-foreground text-xs uppercase tracking-wide">Branches</Label>
<p className="font-medium mt-0.5">{(repo as any).branch_count ?? 0}</p>
<p className="font-medium mt-0.5"></p>
</div>
</div>
</div>