tirbofish/kitgit · commit
dbfb44e6710bccfc98906cb97f596756091e91a5
merge: feat/theme-toggle into integrate/all-features
Type: SSH
SSH Key Fingerprint:
Verified
SgQHY4vUORbJC3ZtdixCl62ek/4QGh/iG2FRSyjfGPc
@@ -0,0 +1,10 @@ +-- Per-user appearance preference: light | dark | system + +ALTER TABLE users + ADD COLUMN IF NOT EXISTS theme TEXT NOT NULL DEFAULT 'system'; + +ALTER TABLE users + DROP CONSTRAINT IF EXISTS users_theme_check; + +ALTER TABLE users + ADD CONSTRAINT users_theme_check CHECK (theme IN ('light', 'dark', 'system')); @@ -17,10 +17,21 @@ pub struct User { pub is_suspended: bool, pub show_email: bool, pub vigilant_mode: bool, + /// `light`, `dark`, or `system` (follows prefers-color-scheme). + pub theme: String, pub created_at: DateTime<Utc>, pub updated_at: DateTime<Utc>, } +impl User { + pub fn theme_pref(&self) -> &str { + match self.theme.as_str() { + "light" | "dark" => self.theme.as_str(), + _ => "system", + } + } +} + #[derive(Debug, Clone, FromRow)] pub struct UserMfa { pub user_id: Uuid, @@ -2003,6 +2003,19 @@ pub async fn update_privacy( .await?) }
Large diffs are not rendered by default. Showing the first 50 of 317 lines. Show full diff