Implement last used calendar tracking with localStorage and database sync
- Add database migration for last_used_calendar field in user preferences - Update backend models and handlers to support last_used_calendar persistence - Modify frontend preferences service with update_last_used_calendar() method - Implement automatic saving of selected calendar on event creation - Add localStorage fallback for offline usage and immediate UI response - Update create event modal to default to last used calendar for new events - Clean up unused imports from event form components 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
		| @@ -95,6 +95,7 @@ pub struct UserPreferences { | ||||
|     pub calendar_theme: Option<String>, | ||||
|     pub calendar_style: Option<String>, | ||||
|     pub calendar_colors: Option<String>, // JSON string | ||||
|     pub last_used_calendar: Option<String>, | ||||
|     pub updated_at: DateTime<Utc>, | ||||
| } | ||||
|  | ||||
| @@ -109,6 +110,7 @@ impl UserPreferences { | ||||
|             calendar_theme: Some("light".to_string()), | ||||
|             calendar_style: Some("default".to_string()), | ||||
|             calendar_colors: None, | ||||
|             last_used_calendar: None, | ||||
|             updated_at: Utc::now(), | ||||
|         } | ||||
|     } | ||||
| @@ -266,8 +268,8 @@ impl<'a> PreferencesRepository<'a> { | ||||
|             sqlx::query( | ||||
|                 "INSERT INTO user_preferences  | ||||
|                  (user_id, calendar_selected_date, calendar_time_increment,  | ||||
|                   calendar_view_mode, calendar_theme, calendar_style, calendar_colors, updated_at)  | ||||
|                  VALUES (?, ?, ?, ?, ?, ?, ?, ?)", | ||||
|                   calendar_view_mode, calendar_theme, calendar_style, calendar_colors, last_used_calendar, updated_at)  | ||||
|                  VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)", | ||||
|             ) | ||||
|             .bind(&prefs.user_id) | ||||
|             .bind(&prefs.calendar_selected_date) | ||||
| @@ -276,6 +278,7 @@ impl<'a> PreferencesRepository<'a> { | ||||
|             .bind(&prefs.calendar_theme) | ||||
|             .bind(&prefs.calendar_style) | ||||
|             .bind(&prefs.calendar_colors) | ||||
|             .bind(&prefs.last_used_calendar) | ||||
|             .bind(&prefs.updated_at) | ||||
|             .execute(self.db.pool()) | ||||
|             .await?; | ||||
| @@ -290,7 +293,7 @@ impl<'a> PreferencesRepository<'a> { | ||||
|             "UPDATE user_preferences  | ||||
|              SET calendar_selected_date = ?, calendar_time_increment = ?,  | ||||
|                  calendar_view_mode = ?, calendar_theme = ?, calendar_style = ?, | ||||
|                  calendar_colors = ?, updated_at = ? | ||||
|                  calendar_colors = ?, last_used_calendar = ?, updated_at = ? | ||||
|              WHERE user_id = ?", | ||||
|         ) | ||||
|         .bind(&prefs.calendar_selected_date) | ||||
| @@ -299,6 +302,7 @@ impl<'a> PreferencesRepository<'a> { | ||||
|         .bind(&prefs.calendar_theme) | ||||
|         .bind(&prefs.calendar_style) | ||||
|         .bind(&prefs.calendar_colors) | ||||
|         .bind(&prefs.last_used_calendar) | ||||
|         .bind(Utc::now()) | ||||
|         .bind(&prefs.user_id) | ||||
|         .execute(self.db.pool()) | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Connor Johnstone
					Connor Johnstone