Remove paddle billing callbacks.

This commit is contained in:
Burak Kaan Köse
2026-04-06 00:27:57 +02:00
parent 81e476e699
commit c8265e75be
+22 -79
View File
@@ -1,6 +1,6 @@
using System;
using System.Collections.Concurrent; using System.Collections.Concurrent;
using System.Collections.Generic; using System.Collections.Generic;
using System;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
@@ -54,9 +54,6 @@ public partial class App : WinoApplication,
{ {
private const int InboxSyncsPerFullSync = 20; private const int InboxSyncsPerFullSync = 20;
private const string ToggleDefaultModeLaunchArgument = "--mode=toggle-default"; 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 ISynchronizationManager? _synchronizationManager;
private IPreferencesService? _preferencesService; private IPreferencesService? _preferencesService;
private IAccountService? _accountService; private IAccountService? _accountService;
@@ -444,7 +441,6 @@ public partial class App : WinoApplication,
{ {
// Wino account loading and activation. // Wino account loading and activation.
await LoadInitialWinoAccountAsync(); await LoadInitialWinoAccountAsync();
await HandlePostActivationAsync(AppInstance.GetCurrent().GetActivatedEventArgs());
} }
LogActivation("Theme service initialized."); LogActivation("Theme service initialized.");
@@ -589,7 +585,7 @@ public partial class App : WinoApplication,
var calendarService = Services.GetRequiredService<ICalendarService>(); var calendarService = Services.GetRequiredService<ICalendarService>();
var snoozedUntilLocal = DateTime.Now.AddMinutes(snoozeDurationMinutes); var snoozedUntilLocal = DateTime.Now.AddMinutes(snoozeDurationMinutes);
await calendarService.SnoozeCalendarItemAsync(calendarItemId, snoozedUntilLocal).ConfigureAwait(false); await calendarService.SnoozeCalendarItemAsync(calendarItemId, snoozedUntilLocal);
} }
private static bool TryGetSnoozeDurationMinutes(AppNotificationActivatedEventArgs toastArgs, out int snoozeDurationMinutes) private static bool TryGetSnoozeDurationMinutes(AppNotificationActivatedEventArgs toastArgs, out int snoozeDurationMinutes)
@@ -908,7 +904,7 @@ public partial class App : WinoApplication,
if (syncResult.CompletedState is SynchronizationCompletedState.Success or SynchronizationCompletedState.PartiallyCompleted) if (syncResult.CompletedState is SynchronizationCompletedState.Success or SynchronizationCompletedState.PartiallyCompleted)
{ {
await ClearInvalidCredentialAttentionIfNeededAsync(message.Options.AccountId).ConfigureAwait(false); await ClearInvalidCredentialAttentionIfNeededAsync(message.Options.AccountId);
} }
if (syncResult.CompletedState == SynchronizationCompletedState.Failed || if (syncResult.CompletedState == SynchronizationCompletedState.Failed ||
@@ -1107,7 +1103,7 @@ public partial class App : WinoApplication,
private async Task LoadInitialWinoAccountAsync() private async Task LoadInitialWinoAccountAsync()
{ {
var winoAccountProfileService = Services.GetRequiredService<IWinoAccountProfileService>(); var winoAccountProfileService = Services.GetRequiredService<IWinoAccountProfileService>();
var winoAccount = await winoAccountProfileService.GetActiveAccountAsync().ConfigureAwait(false); var winoAccount = await winoAccountProfileService.GetActiveAccountAsync();
if (winoAccount != null) if (winoAccount != null)
{ {
@@ -1119,13 +1115,13 @@ public partial class App : WinoApplication,
{ {
try try
{ {
await ExecuteAutoSynchronizationAsync(cancellationToken).ConfigureAwait(false); await ExecuteAutoSynchronizationAsync(cancellationToken);
using var timer = new PeriodicTimer(interval); using var timer = new PeriodicTimer(interval);
while (await timer.WaitForNextTickAsync(cancellationToken).ConfigureAwait(false)) while (await timer.WaitForNextTickAsync(cancellationToken))
{ {
await ExecuteAutoSynchronizationAsync(cancellationToken).ConfigureAwait(false); await ExecuteAutoSynchronizationAsync(cancellationToken);
} }
} }
catch (OperationCanceledException) catch (OperationCanceledException)
@@ -1147,11 +1143,11 @@ public partial class App : WinoApplication,
try try
{ {
lockTaken = await _autoSynchronizationSemaphore.WaitAsync(0, cancellationToken).ConfigureAwait(false); lockTaken = await _autoSynchronizationSemaphore.WaitAsync(0, cancellationToken);
if (!lockTaken) if (!lockTaken)
return; return;
var accounts = await _accountService.GetAccountsAsync().ConfigureAwait(false); var accounts = await _accountService.GetAccountsAsync();
var currentAccountIds = accounts.Select(a => a.Id).ToHashSet(); var currentAccountIds = accounts.Select(a => a.Id).ToHashSet();
foreach (var staleAccountId in _inboxSyncCounters.Keys.Where(a => !currentAccountIds.Contains(a)).ToList()) foreach (var staleAccountId in _inboxSyncCounters.Keys.Where(a => !currentAccountIds.Contains(a)).ToList())
{ {
@@ -1162,7 +1158,7 @@ public partial class App : WinoApplication,
.Select(account => ExecuteAutoSynchronizationForAccountAsync(account, cancellationToken)) .Select(account => ExecuteAutoSynchronizationForAccountAsync(account, cancellationToken))
.ToList(); .ToList();
await Task.WhenAll(synchronizationTasks).ConfigureAwait(false); await Task.WhenAll(synchronizationTasks);
} }
finally finally
{ {
@@ -1189,11 +1185,11 @@ public partial class App : WinoApplication,
Type = MailSynchronizationType.InboxOnly Type = MailSynchronizationType.InboxOnly
}; };
var inboxSyncResult = await _synchronizationManager.SynchronizeMailAsync(inboxSyncOptions, cancellationToken).ConfigureAwait(false); var inboxSyncResult = await _synchronizationManager.SynchronizeMailAsync(inboxSyncOptions, cancellationToken);
if (inboxSyncResult.CompletedState is SynchronizationCompletedState.Success or SynchronizationCompletedState.PartiallyCompleted) if (inboxSyncResult.CompletedState is SynchronizationCompletedState.Success or SynchronizationCompletedState.PartiallyCompleted)
{ {
await ClearInvalidCredentialAttentionIfNeededAsync(account.Id).ConfigureAwait(false); await ClearInvalidCredentialAttentionIfNeededAsync(account.Id);
var inboxSyncCount = _inboxSyncCounters.AddOrUpdate(account.Id, 1, (_, currentCount) => currentCount + 1); var inboxSyncCount = _inboxSyncCounters.AddOrUpdate(account.Id, 1, (_, currentCount) => currentCount + 1);
@@ -1205,7 +1201,7 @@ public partial class App : WinoApplication,
Type = MailSynchronizationType.FullFolders Type = MailSynchronizationType.FullFolders
}; };
await _synchronizationManager.SynchronizeMailAsync(fullSyncOptions, cancellationToken).ConfigureAwait(false); await _synchronizationManager.SynchronizeMailAsync(fullSyncOptions, cancellationToken);
_inboxSyncCounters[account.Id] = 0; _inboxSyncCounters[account.Id] = 0;
} }
} }
@@ -1219,7 +1215,7 @@ public partial class App : WinoApplication,
Type = CalendarSynchronizationType.CalendarMetadata Type = CalendarSynchronizationType.CalendarMetadata
}; };
await _synchronizationManager.SynchronizeCalendarAsync(calendarOptions, cancellationToken).ConfigureAwait(false); await _synchronizationManager.SynchronizeCalendarAsync(calendarOptions, cancellationToken);
} }
private async Task ClearInvalidCredentialAttentionIfNeededAsync(Guid accountId) private async Task ClearInvalidCredentialAttentionIfNeededAsync(Guid accountId)
@@ -1227,12 +1223,12 @@ public partial class App : WinoApplication,
if (_accountService == null) if (_accountService == null)
return; return;
var account = await _accountService.GetAccountAsync(accountId).ConfigureAwait(false); var account = await _accountService.GetAccountAsync(accountId);
if (account?.AttentionReason != AccountAttentionReason.InvalidCredentials) if (account?.AttentionReason != AccountAttentionReason.InvalidCredentials)
return; return;
await _accountService.ClearAccountAttentionAsync(accountId).ConfigureAwait(false); await _accountService.ClearAccountAttentionAsync(accountId);
} }
/// <summary> /// <summary>
@@ -1273,11 +1269,12 @@ public partial class App : WinoApplication,
} }
} }
await HandlePostActivationAsync(args); // Redirected launches can target a shell window that is currently hidden in the tray.
// Restore it through the window manager so Show/BringToFront/Activate happen together.
// Bring the existing window to front after handling redirected activation. if (MainWindow is WindowEx mainWindow)
MainWindow?.BringToFront(); {
MainWindow?.Activate(); Services.GetRequiredService<IWinoWindowManager>().ActivateWindow(mainWindow);
}
} }
}); });
} }
@@ -1321,12 +1318,6 @@ public partial class App : WinoApplication,
return true; 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 && if (activationArgs.Kind == ExtendedActivationKind.File &&
@@ -1371,54 +1362,6 @@ public partial class App : WinoApplication,
return null; 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;
}
} }