diff --git a/apps/auth-service/src/web/account.rs b/apps/auth-service/src/web/account.rs index 122a625d8..ff3fa1946 100644 --- a/apps/auth-service/src/web/account.rs +++ b/apps/auth-service/src/web/account.rs @@ -101,6 +101,33 @@ impl NoChange { } } +/// The change of an [`AccountPage`] without a form, written in its `impl`: its +/// `Change` is [`NoChange`], so nothing reopens a row or makes a change. +macro_rules! no_change { + () => { + type Change = $crate::web::account::NoChange; + + fn reopened(change: &Self::Change) -> Self::Row { + change.absurd() + } + + fn apply( + _: &$crate::web::WebApplication, + _: &::topcoat::context::Cx, + _: $crate::account::Owner, + change: Self::Change, + ) -> impl Future< + Output = Result< + $crate::web::account::Applied, + $crate::account::AccountError, + >, + > + Send { + std::future::ready(change.absurd()) + } + }; +} +pub(super) use no_change; + /// What a change did, which its page answers. pub(super) enum Applied { /// The page says the notice, which a cookie carries, so a link can never claim diff --git a/apps/auth-service/src/web/developers/app.rs b/apps/auth-service/src/web/developers/app.rs index b6c9c0cf0..70a453540 100644 --- a/apps/auth-service/src/web/developers/app.rs +++ b/apps/auth-service/src/web/developers/app.rs @@ -11,7 +11,7 @@ use crate::{ }, web::{ Failure, WebApplication, - account::{AccountPage, Applied, NoChange, Reader}, + account::{AccountPage, Applied, Reader, no_change}, }, }; use chrono::Utc; @@ -33,21 +33,8 @@ impl AccountPage for Overview { const SECTION: Section = Section::Developers; const PATH: &'static str = APP; const TITLE: &'static str = Title::App.as_str(); - type Change = NoChange; type Row = (); - - fn reopened(change: &NoChange) { - match *change {} - } - - fn apply( - _: &WebApplication, - _: &Cx, - _: Owner, - change: NoChange, - ) -> impl Future, AccountError>> + Send { - std::future::ready(change.absurd()) - } + no_change!(); async fn render( web: &WebApplication, diff --git a/apps/auth-service/src/web/developers/mod.rs b/apps/auth-service/src/web/developers/mod.rs index 528d6ee93..6fdf10947 100644 --- a/apps/auth-service/src/web/developers/mod.rs +++ b/apps/auth-service/src/web/developers/mod.rs @@ -16,7 +16,7 @@ pub(super) use app::{AppSecrets, AppSettings, Overview}; use super::{ Failure, WebApplication, - account::{AccountPage, Applied, Framed, NoChange, Reader}, + account::{AccountPage, Applied, Framed, Reader, no_change}, }; use crate::{ MAX_OWNED_CLIENTS, @@ -53,21 +53,8 @@ impl AccountPage for Apps { const SECTION: Section = Section::Developers; const PATH: &'static str = HOME; const TITLE: &'static str = Title::Developers.as_str(); - type Change = NoChange; type Row = (); - - fn reopened(change: &NoChange) { - match *change {} - } - - fn apply( - _: &WebApplication, - _: &Cx, - _: Owner, - change: NoChange, - ) -> impl Future, AccountError>> + Send { - std::future::ready(change.absurd()) - } + no_change!(); async fn render( web: &WebApplication, diff --git a/apps/auth-service/src/web/settings/notifications.rs b/apps/auth-service/src/web/settings/notifications.rs index 2cc33b7ab..0f2059d05 100644 --- a/apps/auth-service/src/web/settings/notifications.rs +++ b/apps/auth-service/src/web/settings/notifications.rs @@ -15,7 +15,7 @@ use crate::{ security::FETCH_SITE_HEADER, web::{ Failure, WebApplication, - account::{AccountPage, Applied, Framed, NoChange, Reader}, + account::{AccountPage, Applied, Framed, Reader, no_change}, }, }; use sourceorigin_common::{ @@ -159,21 +159,8 @@ impl AccountPage for NotificationPage { const SECTION: Section = Section::Account; const PATH: &'static str = settings::NOTIFICATION; const TITLE: &'static str = Tab::Notifications.label(); - type Change = NoChange; type Row = NotificationState; - - fn reopened(change: &NoChange) -> NotificationState { - change.absurd() - } - - fn apply( - _: &WebApplication, - _: &Cx, - _: Owner, - change: NoChange, - ) -> impl Future, AccountError>> + Send { - std::future::ready(change.absurd()) - } + no_change!(); /// Marks the notification read once opened from auth's own pages, unless to /// report its event, which marks it read once made, then shows it, with its history entry, the recovery's undo page while it can diff --git a/apps/auth-service/src/web/settings/overview.rs b/apps/auth-service/src/web/settings/overview.rs index 902362f41..58139b7be 100644 --- a/apps/auth-service/src/web/settings/overview.rs +++ b/apps/auth-service/src/web/settings/overview.rs @@ -1,11 +1,10 @@ //! `/settings`: the account at a glance. use crate::{ - account::{AccountError, Owner}, routes::page::settings, web::{ Failure, WebApplication, - account::{AccountPage, Applied, NoChange, Reader}, + account::{AccountPage, Reader, no_change}, }, }; use chrono::{Duration, Utc}; @@ -34,21 +33,8 @@ impl AccountPage for Overview { const SECTION: Section = Section::Account; const PATH: &'static str = settings::HOME; const TITLE: &'static str = Self::TAB.label(); - type Change = NoChange; type Row = (); - - fn reopened(change: &NoChange) { - match *change {} - } - - fn apply( - _: &WebApplication, - _: &Cx, - _: Owner, - change: NoChange, - ) -> impl Future, AccountError>> + Send { - std::future::ready(change.absurd()) - } + no_change!(); async fn render( web: &WebApplication,