Deep link on purchase success.
This commit is contained in:
@@ -50,6 +50,9 @@ public partial class App : WinoApplication,
|
||||
{
|
||||
private const int InboxSyncsPerFullSync = 20;
|
||||
private const string ToggleDefaultModeLaunchArgument = "--mode=toggle-default";
|
||||
private const string WinoProtocolScheme = "wino";
|
||||
private const string BillingProtocolHost = "billing";
|
||||
private const string BillingSuccessPath = "/success";
|
||||
private ISynchronizationManager? _synchronizationManager;
|
||||
private IPreferencesService? _preferencesService;
|
||||
private IAccountService? _accountService;
|
||||
@@ -257,7 +260,11 @@ public partial class App : WinoApplication,
|
||||
// Initialize theme service after window creation.
|
||||
// Theme service requires the window to exist to properly load and apply themes.
|
||||
await NewThemeService.InitializeAsync();
|
||||
|
||||
// Wino account loading and activation.
|
||||
await LoadInitialWinoAccountAsync();
|
||||
await HandlePostActivationAsync(AppInstance.GetCurrent().GetActivatedEventArgs());
|
||||
|
||||
LogActivation("Theme service initialized.");
|
||||
|
||||
// If startup task launch, keep window hidden (system tray only).
|
||||
@@ -836,7 +843,7 @@ public partial class App : WinoApplication,
|
||||
|
||||
if (winoAccount != null)
|
||||
{
|
||||
WeakReferenceMessenger.Default.Send(new WinoAccountSignedInMessage(winoAccount));
|
||||
WeakReferenceMessenger.Default.Send(new WinoAccountProfileUpdatedMessage(winoAccount));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -941,7 +948,7 @@ public partial class App : WinoApplication,
|
||||
public void HandleRedirectedActivation(AppActivationArguments args)
|
||||
{
|
||||
// Dispatch to UI thread since this is called from Program.OnActivated
|
||||
MainWindow?.DispatcherQueue.TryEnqueue(() =>
|
||||
MainWindow?.DispatcherQueue.TryEnqueue(async () =>
|
||||
{
|
||||
// Handle different activation kinds
|
||||
if (args.Kind == ExtendedActivationKind.AppNotification)
|
||||
@@ -972,6 +979,8 @@ public partial class App : WinoApplication,
|
||||
}
|
||||
}
|
||||
|
||||
await HandlePostActivationAsync(args);
|
||||
|
||||
// Bring the existing window to front after handling redirected activation.
|
||||
MainWindow?.BringToFront();
|
||||
MainWindow?.Activate();
|
||||
@@ -1017,6 +1026,13 @@ public partial class App : WinoApplication,
|
||||
mode = WinoApplicationMode.Mail;
|
||||
return true;
|
||||
}
|
||||
|
||||
if (string.Equals(scheme, WinoProtocolScheme, StringComparison.OrdinalIgnoreCase) &&
|
||||
string.Equals(protocolArgs.Uri?.Host, BillingProtocolHost, StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
mode = WinoApplicationMode.Settings;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
if (activationArgs.Kind == ExtendedActivationKind.File &&
|
||||
@@ -1060,6 +1076,55 @@ public partial class App : WinoApplication,
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private async Task HandlePostActivationAsync(AppActivationArguments activationArgs)
|
||||
{
|
||||
if (await TryHandleBillingProtocolActivationAsync(activationArgs).ConfigureAwait(false))
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
private async Task<bool> TryHandleBillingProtocolActivationAsync(AppActivationArguments activationArgs)
|
||||
{
|
||||
if (!TryGetBillingCallbackUri(activationArgs, out var callbackUri))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
Services.GetRequiredService<INavigationService>().Navigate(
|
||||
WinoPage.SettingsPage,
|
||||
WinoPage.WinoAccountManagementPage,
|
||||
NavigationReferenceFrame.ShellFrame,
|
||||
NavigationTransitionType.None);
|
||||
|
||||
var winoAccountProfileService = Services.GetRequiredService<IWinoAccountProfileService>();
|
||||
await winoAccountProfileService.ProcessBillingCallbackAsync(callbackUri).ConfigureAwait(false);
|
||||
return true;
|
||||
}
|
||||
|
||||
private static bool TryGetBillingCallbackUri(AppActivationArguments activationArgs, out Uri callbackUri)
|
||||
{
|
||||
callbackUri = null!;
|
||||
|
||||
if (activationArgs.Kind != ExtendedActivationKind.Protocol ||
|
||||
activationArgs.Data is not IProtocolActivatedEventArgs protocolArgs ||
|
||||
protocolArgs.Uri == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
var uri = protocolArgs.Uri;
|
||||
if (!string.Equals(uri.Scheme, WinoProtocolScheme, StringComparison.OrdinalIgnoreCase) ||
|
||||
!string.Equals(uri.Host, BillingProtocolHost, StringComparison.OrdinalIgnoreCase) ||
|
||||
!string.Equals(uri.AbsolutePath, BillingSuccessPath, StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
callbackUri = uri;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -90,6 +90,13 @@
|
||||
</uap:Protocol>
|
||||
</uap:Extension>
|
||||
|
||||
<!-- Protocol activation: Wino deep links -->
|
||||
<uap:Extension Category="windows.protocol">
|
||||
<uap:Protocol Name="wino">
|
||||
<uap:DisplayName>Wino Mail Protocol</uap:DisplayName>
|
||||
</uap:Protocol>
|
||||
</uap:Extension>
|
||||
|
||||
<!-- Protocol activation: webcal -->
|
||||
<uap:Extension Category="windows.protocol">
|
||||
<uap:Protocol Name="webcal">
|
||||
|
||||
@@ -31,8 +31,8 @@ public sealed partial class ShellWindow : WindowEx, IWinoShellWindow,
|
||||
IRecipient<TitleBarShellContentUpdated>,
|
||||
IRecipient<SynchronizationActionsAdded>,
|
||||
IRecipient<SynchronizationActionsCompleted>,
|
||||
IRecipient<WinoAccountSignedInMessage>,
|
||||
IRecipient<WinoAccountSignedOutMessage>
|
||||
IRecipient<WinoAccountProfileUpdatedMessage>,
|
||||
IRecipient<WinoAccountProfileDeletedMessage>
|
||||
{
|
||||
public IStatePersistanceService StatePersistanceService { get; } = WinoApplication.Current.Services.GetService<IStatePersistanceService>() ?? throw new Exception("StatePersistanceService not registered in DI container.");
|
||||
public IPreferencesService PreferencesService { get; } = WinoApplication.Current.Services.GetService<IPreferencesService>() ?? throw new Exception("PreferencesService not registered in DI container.");
|
||||
@@ -213,12 +213,12 @@ public sealed partial class ShellWindow : WindowEx, IWinoShellWindow,
|
||||
});
|
||||
}
|
||||
|
||||
public void Receive(WinoAccountSignedInMessage message)
|
||||
public void Receive(WinoAccountProfileUpdatedMessage message)
|
||||
{
|
||||
DispatcherQueue.TryEnqueue(() => UpdateWinoAccountState(message.Account));
|
||||
}
|
||||
|
||||
public void Receive(WinoAccountSignedOutMessage message)
|
||||
public void Receive(WinoAccountProfileDeletedMessage message)
|
||||
{
|
||||
DispatcherQueue.TryEnqueue(() => UpdateWinoAccountState(null));
|
||||
}
|
||||
@@ -326,8 +326,8 @@ public sealed partial class ShellWindow : WindowEx, IWinoShellWindow,
|
||||
WeakReferenceMessenger.Default.Register<InfoBarMessageRequested>(this);
|
||||
WeakReferenceMessenger.Default.Register<SynchronizationActionsAdded>(this);
|
||||
WeakReferenceMessenger.Default.Register<SynchronizationActionsCompleted>(this);
|
||||
WeakReferenceMessenger.Default.Register<WinoAccountSignedInMessage>(this);
|
||||
WeakReferenceMessenger.Default.Register<WinoAccountSignedOutMessage>(this);
|
||||
WeakReferenceMessenger.Default.Register<WinoAccountProfileUpdatedMessage>(this);
|
||||
WeakReferenceMessenger.Default.Register<WinoAccountProfileDeletedMessage>(this);
|
||||
}
|
||||
|
||||
private void UnregisterRecipients()
|
||||
@@ -337,8 +337,8 @@ public sealed partial class ShellWindow : WindowEx, IWinoShellWindow,
|
||||
WeakReferenceMessenger.Default.Unregister<InfoBarMessageRequested>(this);
|
||||
WeakReferenceMessenger.Default.Unregister<SynchronizationActionsAdded>(this);
|
||||
WeakReferenceMessenger.Default.Unregister<SynchronizationActionsCompleted>(this);
|
||||
WeakReferenceMessenger.Default.Unregister<WinoAccountSignedInMessage>(this);
|
||||
WeakReferenceMessenger.Default.Unregister<WinoAccountSignedOutMessage>(this);
|
||||
WeakReferenceMessenger.Default.Unregister<WinoAccountProfileUpdatedMessage>(this);
|
||||
WeakReferenceMessenger.Default.Unregister<WinoAccountProfileDeletedMessage>(this);
|
||||
}
|
||||
|
||||
private void ShowInfoBarMessage(InfoBarMessageRequested message)
|
||||
|
||||
Reference in New Issue
Block a user