Local draft resent and default app mode settings.
This commit is contained in:
@@ -5,7 +5,7 @@ namespace Wino.Mail.WinUI.Activation;
|
||||
|
||||
internal static class AppModeActivationResolver
|
||||
{
|
||||
public static WinoApplicationMode Resolve(string? launchArguments, string? tileId, string? appId)
|
||||
public static WinoApplicationMode Resolve(string? launchArguments, string? tileId, string? appId, WinoApplicationMode defaultMode = WinoApplicationMode.Mail)
|
||||
{
|
||||
if (TryResolveFromText(launchArguments, out var mode))
|
||||
return mode;
|
||||
@@ -16,7 +16,7 @@ internal static class AppModeActivationResolver
|
||||
if (TryResolveFromText(appId, out mode))
|
||||
return mode;
|
||||
|
||||
return WinoApplicationMode.Mail;
|
||||
return defaultMode;
|
||||
}
|
||||
|
||||
private static bool TryResolveFromText(string? value, out WinoApplicationMode mode)
|
||||
|
||||
@@ -198,7 +198,10 @@ public partial class App : WinoApplication,
|
||||
if (activationArgs.Kind == ExtendedActivationKind.AppNotification)
|
||||
return true;
|
||||
|
||||
var launchMode = AppModeActivationResolver.Resolve(args?.Arguments, GetCurrentLaunchTileId(), Environment.CommandLine);
|
||||
var launchMode = AppModeActivationResolver.Resolve(args?.Arguments,
|
||||
GetCurrentLaunchTileId(),
|
||||
Environment.CommandLine,
|
||||
_preferencesService?.DefaultApplicationMode ?? WinoApplicationMode.Mail);
|
||||
bool shouldRegister = launchMode == WinoApplicationMode.Mail;
|
||||
|
||||
if (!shouldRegister)
|
||||
@@ -313,6 +316,7 @@ public partial class App : WinoApplication,
|
||||
{
|
||||
// Pass null for args since we're handling toast navigation
|
||||
await CreateAndActivateWindow(null!);
|
||||
navigationService.ChangeApplicationMode(Core.Domain.Enums.WinoApplicationMode.Mail);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -453,7 +457,7 @@ public partial class App : WinoApplication,
|
||||
return;
|
||||
}
|
||||
|
||||
if (TryResolveActivationMode(activationArgs, out var activationMode))
|
||||
if (TryResolveActivationMode(activationArgs, _preferencesService?.DefaultApplicationMode ?? WinoApplicationMode.Mail, out var activationMode))
|
||||
{
|
||||
shellWindow.HandleAppActivation(GetModeLaunchArgument(activationMode));
|
||||
return;
|
||||
@@ -684,7 +688,7 @@ public partial class App : WinoApplication,
|
||||
{
|
||||
shellWindow.HandleAppActivation(launchArgs.Arguments, launchArgs.TileId);
|
||||
}
|
||||
else if (TryResolveActivationMode(args, out var redirectedMode))
|
||||
else if (TryResolveActivationMode(args, _preferencesService?.DefaultApplicationMode ?? WinoApplicationMode.Mail, out var redirectedMode))
|
||||
{
|
||||
shellWindow.HandleAppActivation(GetModeLaunchArgument(redirectedMode));
|
||||
}
|
||||
@@ -700,9 +704,9 @@ public partial class App : WinoApplication,
|
||||
private static string GetModeLaunchArgument(WinoApplicationMode mode)
|
||||
=> mode == WinoApplicationMode.Calendar ? "--mode=calendar" : "--mode=mail";
|
||||
|
||||
private static bool TryResolveActivationMode(AppActivationArguments activationArgs, out WinoApplicationMode mode)
|
||||
private static bool TryResolveActivationMode(AppActivationArguments activationArgs, WinoApplicationMode defaultMode, out WinoApplicationMode mode)
|
||||
{
|
||||
mode = WinoApplicationMode.Mail;
|
||||
mode = defaultMode;
|
||||
|
||||
if (activationArgs.Kind == ExtendedActivationKind.Protocol &&
|
||||
activationArgs.Data is IProtocolActivatedEventArgs protocolArgs)
|
||||
@@ -746,7 +750,7 @@ public partial class App : WinoApplication,
|
||||
if (activationArgs.Kind == ExtendedActivationKind.Launch &&
|
||||
activationArgs.Data is ILaunchActivatedEventArgs launchArgs)
|
||||
{
|
||||
mode = AppModeActivationResolver.Resolve(launchArgs.Arguments, launchArgs.TileId, null);
|
||||
mode = AppModeActivationResolver.Resolve(launchArgs.Arguments, launchArgs.TileId, null, defaultMode);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -290,6 +290,19 @@ public class PreferencesService(IConfigurationService configurationService) : Ob
|
||||
set => SetPropertyAndSave(nameof(EmailSyncIntervalMinutes), value);
|
||||
}
|
||||
|
||||
public WinoApplicationMode DefaultApplicationMode
|
||||
{
|
||||
get
|
||||
{
|
||||
var configuredMode = _configurationService.Get(nameof(DefaultApplicationMode), WinoApplicationMode.Mail);
|
||||
|
||||
return Enum.IsDefined(typeof(WinoApplicationMode), configuredMode)
|
||||
? configuredMode
|
||||
: WinoApplicationMode.Mail;
|
||||
}
|
||||
set => SaveProperty(propertyName: nameof(DefaultApplicationMode), value);
|
||||
}
|
||||
|
||||
public CalendarSettings GetCurrentCalendarSettings()
|
||||
{
|
||||
var workingDays = GetDaysBetween(WorkingDayStart, WorkingDayEnd);
|
||||
|
||||
@@ -111,7 +111,7 @@ public sealed partial class ShellWindow : WindowEx, IWinoShellWindow,
|
||||
|
||||
public void HandleAppActivation(string? launchArguments, string? tileId = null, string? appId = null)
|
||||
{
|
||||
var targetMode = AppModeActivationResolver.Resolve(launchArguments, tileId, appId);
|
||||
var targetMode = AppModeActivationResolver.Resolve(launchArguments, tileId, appId, PreferencesService.DefaultApplicationMode);
|
||||
_currentMode = targetMode;
|
||||
|
||||
_isApplyingActivationMode = true;
|
||||
|
||||
@@ -227,11 +227,23 @@
|
||||
<coreControls:WinoFontIcon Icon="Delete" />
|
||||
</AppBarButton.Icon>
|
||||
</AppBarButton>
|
||||
<AppBarButton Command="{x:Bind ViewModel.SendCommand}" Label="{x:Bind domain:Translator.Buttons_Send}">
|
||||
<AppBarButton
|
||||
Command="{x:Bind ViewModel.SendCommand}"
|
||||
Label="{x:Bind domain:Translator.Buttons_Send}"
|
||||
Visibility="{x:Bind ViewModel.ShouldShowSendButton, Mode=OneWay}">
|
||||
<AppBarButton.Icon>
|
||||
<coreControls:WinoFontIcon Icon="Send" />
|
||||
</AppBarButton.Icon>
|
||||
</AppBarButton>
|
||||
<AppBarButton
|
||||
Command="{x:Bind ViewModel.SendToServerCommand}"
|
||||
Label="{x:Bind domain:Translator.Buttons_SendToServer}"
|
||||
ToolTipService.ToolTip="{x:Bind domain:Translator.Composer_LocalDraftSyncInfo}"
|
||||
Visibility="{x:Bind ViewModel.ShouldShowSendToServerButton, Mode=OneWay}">
|
||||
<AppBarButton.Icon>
|
||||
<coreControls:WinoFontIcon Icon="SendNew" />
|
||||
</AppBarButton.Icon>
|
||||
</AppBarButton>
|
||||
</toolkit:TabbedCommandBarItem>
|
||||
</toolkit:TabbedCommandBar.PaneCustomContent>
|
||||
<toolkit:TabbedCommandBar.MenuItems>
|
||||
|
||||
@@ -280,7 +280,14 @@ public sealed partial class MailListPage : MailListPageAbstract,
|
||||
// No active mail item. Go to empty page.
|
||||
if (message.SelectedMailItemViewModel == null)
|
||||
{
|
||||
WeakReferenceMessenger.Default.Send(new CancelRenderingContentRequested());
|
||||
if (IsRenderingPageActive())
|
||||
{
|
||||
WeakReferenceMessenger.Default.Send(new CancelRenderingContentRequested());
|
||||
}
|
||||
|
||||
// Ensure rendering frame actually navigates away from Compose/Rendering pages.
|
||||
// Otherwise those pages keep their messenger registrations alive.
|
||||
ViewModel.NavigationService.Navigate(WinoPage.IdlePage, null, NavigationReferenceFrame.RenderingFrame, NavigationTransitionType.DrillIn);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -30,6 +30,13 @@
|
||||
</controls:SettingsCard.HeaderIcon>
|
||||
</controls:SettingsCard>
|
||||
|
||||
<controls:SettingsCard Description="{x:Bind domain:Translator.SettingsAppPreferences_ApplicationMode_Description}" Header="{x:Bind domain:Translator.SettingsAppPreferences_ApplicationMode_Title}">
|
||||
<ComboBox ItemsSource="{x:Bind ViewModel.ApplicationModes, Mode=OneWay}" SelectedItem="{x:Bind ViewModel.SelectedDefaultApplicationMode, Mode=TwoWay}" />
|
||||
<controls:SettingsCard.HeaderIcon>
|
||||
<PathIcon Data="F1 M 2.5 3.125 C 2.5 2.955729 2.561849 2.809245 2.685547 2.685547 C 2.809244 2.56185 2.955729 2.5 3.125 2.5 L 16.875 2.5 C 17.044271 2.5 17.190756 2.56185 17.314453 2.685547 C 17.43815 2.809245 17.5 2.955729 17.5 3.125 L 17.5 16.875 C 17.5 17.044271 17.43815 17.190756 17.314453 17.314453 C 17.190756 17.43815 17.044271 17.5 16.875 17.5 L 3.125 17.5 C 2.955729 17.5 2.809244 17.43815 2.685547 17.314453 C 2.561849 17.190756 2.5 17.044271 2.5 16.875 Z M 3.75 3.75 L 3.75 16.25 L 16.25 16.25 L 16.25 3.75 Z M 9.375 5 C 9.375 4.830729 9.436849 4.684245 9.560547 4.560547 C 9.684244 4.43685 9.830729 4.375 10 4.375 C 10.169271 4.375 10.315755 4.43685 10.439453 4.560547 C 10.56315 4.684245 10.625 4.830729 10.625 5 L 10.625 15 C 10.625 15.169271 10.56315 15.315756 10.439453 15.439453 C 10.315755 15.56315 10.169271 15.625 10 15.625 C 9.830729 15.625 9.684244 15.56315 9.560547 15.439453 C 9.436849 15.315756 9.375 15.169271 9.375 15 Z " />
|
||||
</controls:SettingsCard.HeaderIcon>
|
||||
</controls:SettingsCard>
|
||||
|
||||
<controls:SettingsCard Description="{x:Bind domain:Translator.SettingsAppPreferences_EmailSyncInterval_Description}" Header="{x:Bind domain:Translator.SettingsAppPreferences_EmailSyncInterval_Title}">
|
||||
<NumberBox
|
||||
Minimum="1"
|
||||
|
||||
Reference in New Issue
Block a user