Add immediate refresh when new external calendars are created
When users add a new external calendar, events now appear instantly instead of waiting for the next 5-minute auto-refresh cycle or manual refresh. Changes: - Modified ExternalCalendarModal to return newly created calendar ID - Enhanced on_success callback to immediately fetch events for new calendar - Added proper visibility checking and error handling - Removed unused imports to clean up compilation warnings User experience improvement: - Before: Add calendar → wait 5 minutes → see events - After: Add calendar → events appear immediately 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -7,7 +7,7 @@ use crate::services::calendar_service::CalendarService;
|
||||
pub struct ExternalCalendarModalProps {
|
||||
pub is_open: bool,
|
||||
pub on_close: Callback<()>,
|
||||
pub on_success: Callback<()>,
|
||||
pub on_success: Callback<i32>, // Pass the newly created calendar ID
|
||||
}
|
||||
|
||||
#[function_component(ExternalCalendarModal)]
|
||||
@@ -75,9 +75,9 @@ pub fn external_calendar_modal(props: &ExternalCalendarModalProps) -> Html {
|
||||
|
||||
wasm_bindgen_futures::spawn_local(async move {
|
||||
match CalendarService::create_external_calendar(&name, &url, &color).await {
|
||||
Ok(_) => {
|
||||
Ok(new_calendar) => {
|
||||
is_loading.set(false);
|
||||
on_success.emit(());
|
||||
on_success.emit(new_calendar.id);
|
||||
on_close.emit(());
|
||||
}
|
||||
Err(e) => {
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
use crate::components::CalendarListItem;
|
||||
use crate::services::calendar_service::{UserInfo, ExternalCalendar};
|
||||
use chrono::{DateTime, Local, TimeZone, Utc};
|
||||
use web_sys::HtmlSelectElement;
|
||||
use yew::prelude::*;
|
||||
use yew_router::prelude::*;
|
||||
|
||||
Reference in New Issue
Block a user