Merge pull request 'allow lazy people to mark all notifcations as read' (#822) from mark-all-notifications-read into staging
Reviewed-on: #822
This commit is contained in:
commit
d01e6ea30b
@ -194,6 +194,15 @@ ORDER BY read_at DESC, created_at DESC;
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub(crate) async fn mark_all_read(db: &SqlitePool, user: &User) {
|
||||||
|
let notifications = Self::for_user(db, user).await;
|
||||||
|
|
||||||
|
for notification in notifications {
|
||||||
|
notification.mark_read(db).await;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pub(crate) async fn delete_by_action(db: &sqlx::Pool<Sqlite>, action: &str) {
|
pub(crate) async fn delete_by_action(db: &sqlx::Pool<Sqlite>, action: &str) {
|
||||||
sqlx::query!(
|
sqlx::query!(
|
||||||
"DELETE FROM notification WHERE action_after_reading=? and read_at is null",
|
"DELETE FROM notification WHERE action_after_reading=? and read_at is null",
|
||||||
|
@ -27,6 +27,12 @@ async fn mark_read(db: &State<SqlitePool>, user: User, notification_id: i64) ->
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn routes() -> Vec<Route> {
|
#[get("/read/all")]
|
||||||
routes![mark_read]
|
async fn mark_all_read(db: &State<SqlitePool>, user: User) -> Flash<Redirect> {
|
||||||
|
Notification::mark_all_read(db, &user).await;
|
||||||
|
Flash::success(Redirect::to("/"), "Alle Nachrichten als gelesen markiert")
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn routes() -> Vec<Route> {
|
||||||
|
routes![mark_read, mark_all_read]
|
||||||
}
|
}
|
||||||
|
@ -32,7 +32,7 @@
|
|||||||
<h2 class="h2">Nachrichten</h2>
|
<h2 class="h2">Nachrichten</h2>
|
||||||
{% if loggedin_user.amount_unread_notifications > 10 %}
|
{% if loggedin_user.amount_unread_notifications > 10 %}
|
||||||
<div class="text-primary-950 dark:text-white bg-gray-200 dark:bg-primary-950 bg-opacity-80 text-center pb-3 px-3">
|
<div class="text-primary-950 dark:text-white bg-gray-200 dark:bg-primary-950 bg-opacity-80 text-center pb-3 px-3">
|
||||||
Du hast viele ungelesene Benachrichtigungen. Um deine Oberfläche übersichtlich zu halten und wichtige Updates nicht zu verpassen, nimm dir bitte einen Moment Zeit sie zu überprüfen und als gelesen zu markieren (✓).
|
Du hast viele ungelesene Benachrichtigungen. Um deine Oberfläche übersichtlich zu halten und wichtige Updates nicht zu verpassen, nimm dir bitte in Zukunft einen kurzen Moment Zeit sie zu überprüfen und als gelesen zu markieren (✓).<br /><a href="/notification/read/all" class="underline">Du kannst hier ausnahmsweise alle als gelesen markieren.</a>
|
||||||
</div>
|
</div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
<div class="divide-y">
|
<div class="divide-y">
|
||||||
|
Loading…
Reference in New Issue
Block a user