Remove connection manager.
This commit is contained in:
@@ -1,5 +1,4 @@
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Threading.Tasks;
|
||||
using CommunityToolkit.Mvvm.ComponentModel;
|
||||
using CommunityToolkit.Mvvm.Input;
|
||||
@@ -7,7 +6,6 @@ using Wino.Core.Domain;
|
||||
using Wino.Core.Domain.Enums;
|
||||
using Wino.Core.Domain.Interfaces;
|
||||
using Wino.Core.Domain.Models.Navigation;
|
||||
using Wino.Messaging.Server;
|
||||
|
||||
namespace Wino.Mail.ViewModels;
|
||||
|
||||
@@ -15,9 +13,6 @@ public partial class AppPreferencesPageViewModel : MailBaseViewModel
|
||||
{
|
||||
public IPreferencesService PreferencesService { get; }
|
||||
|
||||
[ObservableProperty]
|
||||
private List<string> _appTerminationBehavior;
|
||||
|
||||
[ObservableProperty]
|
||||
public partial List<string> SearchModes { get; set; }
|
||||
|
||||
@@ -41,18 +36,6 @@ public partial class AppPreferencesPageViewModel : MailBaseViewModel
|
||||
public bool IsStartupBehaviorDisabled => !IsStartupBehaviorEnabled;
|
||||
public bool IsStartupBehaviorEnabled => StartupBehaviorResult == StartupBehaviorResult.Enabled;
|
||||
|
||||
private string _selectedAppTerminationBehavior;
|
||||
public string SelectedAppTerminationBehavior
|
||||
{
|
||||
get => _selectedAppTerminationBehavior;
|
||||
set
|
||||
{
|
||||
SetProperty(ref _selectedAppTerminationBehavior, value);
|
||||
|
||||
PreferencesService.ServerTerminationBehavior = (ServerBackgroundMode)AppTerminationBehavior.IndexOf(value);
|
||||
}
|
||||
}
|
||||
|
||||
private string _selectedDefaultSearchMode;
|
||||
public string SelectedDefaultSearchMode
|
||||
{
|
||||
@@ -66,35 +49,22 @@ public partial class AppPreferencesPageViewModel : MailBaseViewModel
|
||||
}
|
||||
|
||||
private readonly IMailDialogService _dialogService;
|
||||
private readonly IWinoServerConnectionManager _winoServerConnectionManager;
|
||||
private readonly IStartupBehaviorService _startupBehaviorService;
|
||||
|
||||
public AppPreferencesPageViewModel(IMailDialogService dialogService,
|
||||
IPreferencesService preferencesService,
|
||||
IWinoServerConnectionManager winoServerConnectionManager,
|
||||
IStartupBehaviorService startupBehaviorService)
|
||||
{
|
||||
_dialogService = dialogService;
|
||||
PreferencesService = preferencesService;
|
||||
_winoServerConnectionManager = winoServerConnectionManager;
|
||||
_startupBehaviorService = startupBehaviorService;
|
||||
|
||||
// Load the app termination behavior options
|
||||
|
||||
_appTerminationBehavior =
|
||||
[
|
||||
Translator.SettingsAppPreferences_ServerBackgroundingMode_MinimizeTray_Title, // "Minimize to tray"
|
||||
Translator.SettingsAppPreferences_ServerBackgroundingMode_Invisible_Title, // "Invisible"
|
||||
Translator.SettingsAppPreferences_ServerBackgroundingMode_Terminate_Title // "Terminate"
|
||||
];
|
||||
|
||||
SearchModes =
|
||||
[
|
||||
Translator.SettingsAppPreferences_SearchMode_Local,
|
||||
Translator.SettingsAppPreferences_SearchMode_Online
|
||||
];
|
||||
|
||||
SelectedAppTerminationBehavior = _appTerminationBehavior[(int)PreferencesService.ServerTerminationBehavior];
|
||||
SelectedDefaultSearchMode = SearchModes[(int)PreferencesService.DefaultSearchMode];
|
||||
EmailSyncIntervalMinutes = PreferencesService.EmailSyncIntervalMinutes;
|
||||
}
|
||||
@@ -152,20 +122,7 @@ public partial class AppPreferencesPageViewModel : MailBaseViewModel
|
||||
}
|
||||
}
|
||||
|
||||
protected override async void OnPropertyChanged(PropertyChangedEventArgs e)
|
||||
{
|
||||
base.OnPropertyChanged(e);
|
||||
|
||||
if (e.PropertyName == nameof(SelectedAppTerminationBehavior))
|
||||
{
|
||||
var terminationModeChangedResult = await _winoServerConnectionManager.GetResponseAsync<bool, ServerTerminationModeChanged>(new ServerTerminationModeChanged(PreferencesService.ServerTerminationBehavior));
|
||||
|
||||
if (!terminationModeChangedResult.IsSuccess)
|
||||
{
|
||||
_dialogService.InfoBarMessage(Translator.GeneralTitle_Error, terminationModeChangedResult.Message, InfoBarMessageType.Error);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public override async void OnNavigatedTo(NavigationMode mode, object parameters)
|
||||
{
|
||||
|
||||
@@ -60,7 +60,6 @@ public partial class AppShellViewModel : MailBaseViewModel,
|
||||
private const string IsActivateStartupLaunchAskedKey = nameof(IsActivateStartupLaunchAskedKey);
|
||||
|
||||
public IStatePersistanceService StatePersistenceService { get; }
|
||||
public IWinoServerConnectionManager ServerConnectionManager { get; }
|
||||
public IPreferencesService PreferencesService { get; }
|
||||
public INavigationService NavigationService { get; }
|
||||
|
||||
@@ -81,9 +80,6 @@ public partial class AppShellViewModel : MailBaseViewModel,
|
||||
|
||||
private readonly SemaphoreSlim accountInitFolderUpdateSlim = new SemaphoreSlim(1);
|
||||
|
||||
[ObservableProperty]
|
||||
private WinoServerConnectionStatus activeConnectionStatus;
|
||||
|
||||
public AppShellViewModel(IMailDialogService dialogService,
|
||||
INavigationService navigationService,
|
||||
IMimeFileService mimeFileService,
|
||||
@@ -98,21 +94,10 @@ public partial class AppShellViewModel : MailBaseViewModel,
|
||||
IWinoRequestDelegator winoRequestDelegator,
|
||||
IFolderService folderService,
|
||||
IStatePersistanceService statePersistanceService,
|
||||
IWinoServerConnectionManager serverConnectionManager,
|
||||
IConfigurationService configurationService,
|
||||
IStartupBehaviorService startupBehaviorService)
|
||||
{
|
||||
StatePersistenceService = statePersistanceService;
|
||||
ServerConnectionManager = serverConnectionManager;
|
||||
|
||||
ActiveConnectionStatus = serverConnectionManager.Status;
|
||||
ServerConnectionManager.StatusChanged += async (sender, status) =>
|
||||
{
|
||||
await ExecuteUIThread(() =>
|
||||
{
|
||||
ActiveConnectionStatus = status;
|
||||
});
|
||||
};
|
||||
|
||||
PreferencesService = preferencesService;
|
||||
_dialogService = dialogService;
|
||||
@@ -132,9 +117,6 @@ public partial class AppShellViewModel : MailBaseViewModel,
|
||||
_winoRequestDelegator = winoRequestDelegator;
|
||||
}
|
||||
|
||||
[RelayCommand]
|
||||
private Task ReconnectServerAsync() => ServerConnectionManager.ConnectAsync();
|
||||
|
||||
protected override void OnDispatcherAssigned()
|
||||
{
|
||||
base.OnDispatcherAssigned();
|
||||
|
||||
@@ -22,7 +22,6 @@ using Wino.Core.Domain.Models.Folders;
|
||||
using Wino.Core.Domain.Models.MailItem;
|
||||
using Wino.Core.Domain.Models.Menus;
|
||||
using Wino.Core.Domain.Models.Reader;
|
||||
using Wino.Core.Domain.Models.Server;
|
||||
using Wino.Core.Domain.Models.Synchronization;
|
||||
using Wino.Mail.ViewModels.Collections;
|
||||
using Wino.Mail.ViewModels.Data;
|
||||
|
||||
Reference in New Issue
Block a user