add: option to clear all notifications when you open the page

This commit is contained in:
trisua 2025-06-27 01:38:35 -04:00
parent 45ea91a768
commit e7c4cf14aa
5 changed files with 19 additions and 3 deletions

View file

@ -49,6 +49,6 @@
(text "setTimeout(async () => {
await trigger(\"ui::io_data_load\", [\"/_swiss_army_timeline?user_id={{ profile.id }}&tag={{ tag }}&page=\", Number.parseInt(\"{{ page }}\") - 1, \"{{ paged }}\" === \"true\"]);
(await ns(\"ui\")).IO_DATA_DISABLE_RELOAD = true;
});"))
}, 500);"))
(text "{% endblock %}")

View file

@ -1536,6 +1536,11 @@
\"{{ profile.settings.paged_timelines }}\",
\"checkbox\",
],
[
[\"auto_clear_notifs\", \"Automatically clear all notifications when you open the notifications page\"],
\"{{ profile.settings.auto_clear_notifs }}\",
\"checkbox\",
],
[[], \"Fun\", \"title\"],
[
[\"disable_gpa_fun\", \"Disable GPA\"],

View file

@ -81,7 +81,7 @@ pub async fn stripe_webhook(
loop {
if retries >= 5 {
// we've already tried 5 times (10 seconds of waiting)... it's not
// we've already tried 5 times (25 seconds of waiting)... it's not
// going to happen
//
// we're going to report this error to the audit log so someone can
@ -111,7 +111,7 @@ pub async fn stripe_webhook(
Err(_) => {
tracing::info!("checkout session not stored in db yet");
retries += 1;
tokio::time::sleep(Duration::from_secs(2)).await;
tokio::time::sleep(Duration::from_secs(5)).await;
continue;
}
}

View file

@ -331,6 +331,14 @@ pub async fn notifications_request(
Err(e) => return Err(Html(render_error(e, &jar, &data, &Some(user)).await)),
};
// check and clear
if profile.settings.auto_clear_notifs {
if let Err(e) = data.0.delete_all_notifications(&user).await {
return Err(Html(render_error(e, &jar, &data, &Some(user)).await));
}
}
// ...
let lang = get_lang!(jar, data.0);
let mut context = initial_context(&data.0.0.0, lang, &Some(user)).await;

View file

@ -252,6 +252,9 @@ pub struct UserSettings {
/// Hide posts that are answering a question on the "All" timeline.
#[serde(default)]
pub all_timeline_hide_answers: bool,
/// Automatically clear all notifications when notifications are viewed.
#[serde(default)]
pub auto_clear_notifs: bool,
}
fn mime_avif() -> String {