Fix notification activation and calendar bootstrap flow

This commit is contained in:
Burak Kaan Köse
2026-04-16 01:32:48 +02:00
parent 94675eee9a
commit e13aaadc78
15 changed files with 844 additions and 209 deletions
@@ -169,6 +169,7 @@ public partial class CalendarAppShellViewModel : CalendarBaseViewModel,
var activationContext = parameters as ShellModeActivationContext;
var shouldRunStartupFlows = activationContext?.IsInitialActivation ?? true;
var navigationArgs = activationContext?.Parameter as CalendarPageNavigationArgs;
PreferencesService.PreferenceChanged -= PreferencesServiceChanged;
PreferencesService.PreferenceChanged += PreferencesServiceChanged;
@@ -178,7 +179,14 @@ public partial class CalendarAppShellViewModel : CalendarBaseViewModel,
await InitializeAccountCalendarsAsync();
ValidateConfiguredNewEventCalendar();
TodayClicked();
if (navigationArgs != null)
{
NavigationService.Navigate(WinoPage.CalendarPage, navigationArgs);
}
else if (shouldRunStartupFlows || _calendarPageViewModel.CurrentVisibleRange == null)
{
TodayClicked();
}
}
public override void OnNavigatedFrom(NavigationMode mode, object parameters)
@@ -634,7 +634,7 @@ public partial class CalendarPageViewModel : CalendarBaseViewModel,
}
}
public async Task ApplyDisplayRequestAsync(CalendarDisplayRequest request, bool forceReload = false)
public async Task ApplyDisplayRequestAsync(CalendarDisplayRequest request, bool forceReload = false, CalendarItemTarget pendingTarget = null)
{
var lifetimeVersion = CurrentPageLifetimeVersion;
var hasLoadingLock = await WaitForCalendarLoadingLockAsync(lifetimeVersion).ConfigureAwait(false);
@@ -718,6 +718,11 @@ public partial class CalendarPageViewModel : CalendarBaseViewModel,
await _notificationBuilder.ClearCalendarTaskbarBadgeAsync().ConfigureAwait(false);
_isCalendarBadgeClearedForPageLifetime = true;
}
if (loadSucceeded && pendingTarget != null && IsPageActive(lifetimeVersion))
{
await NavigateToPendingCalendarTargetAsync(pendingTarget).ConfigureAwait(false);
}
}
public Task ReloadCurrentVisibleRangeAsync()
@@ -745,6 +750,31 @@ public partial class CalendarPageViewModel : CalendarBaseViewModel,
NavigateEvent(new CalendarItemViewModel(calendarItem), CalendarEventTargetType.Single);
}
private async Task NavigateToPendingCalendarTargetAsync(CalendarItemTarget target)
{
CalendarItemViewModel calendarItemViewModel = null;
if (_loadedCalendarItems.TryGetValue(target.Item.Id, out var loadedCalendarItemViewModel))
{
calendarItemViewModel = loadedCalendarItemViewModel;
}
else
{
var targetItem = await _calendarService.GetCalendarItemTargetAsync(target).ConfigureAwait(false);
if (targetItem == null)
return;
targetItem.AssignedCalendar ??= AccountCalendarStateService.ActiveCalendars.FirstOrDefault(calendar => calendar.Id == targetItem.CalendarId);
calendarItemViewModel = new CalendarItemViewModel(targetItem);
}
await ExecuteUIThread(() =>
{
DisplayDetailsCalendarItemViewModel = calendarItemViewModel;
NavigateEvent(calendarItemViewModel, target.TargetType);
}).ConfigureAwait(false);
}
private async Task<List<CalendarItemViewModel>> LoadCalendarItemsAsync(DateRange loadedDateWindow, long lifetimeVersion)
{
var loadedItems = new Dictionary<Guid, CalendarItemViewModel>();
@@ -819,7 +849,7 @@ public partial class CalendarPageViewModel : CalendarBaseViewModel,
}
public async void Receive(LoadCalendarMessage message)
=> await ApplyDisplayRequestAsync(message.DisplayRequest, message.ForceReload);
=> await ApplyDisplayRequestAsync(message.DisplayRequest, message.ForceReload, message.PendingTarget);
public void Receive(CalendarSettingsUpdatedMessage message)
{