From 202b4cfb3a2df10351ffb874a2bc2ef3a32c4080 Mon Sep 17 00:00:00 2001 From: ImoutoChan Date: Sun, 31 Mar 2024 13:39:40 +0500 Subject: [PATCH] Add in-memory settings to enable/disable imouto pics upload --- CHANGELOG.md | 5 + .../IImoutoPicsUploaderStateService.cs | 10 + .../ImoutoPicsUploaderStateService.cs | 20 + .../Services/ServiceLocator.cs | 2 +- .../View/Flyouts/SettingsView.xaml | 9 + .../ViewModel/MainWindowVM.cs | 1 + .../ViewModel/SettingsVM.cs | 34 ++ .../EnableImoutoPicsUploaderCommand.cs | 34 ++ .../IsImoutoPicsUploaderEnabledQuery.cs | 21 + .../Cqrs/OverseeCollectionCommand.cs | 7 +- .../ServiceCollectionExtensions.cs | 3 + .../Services/IImoutoPicsUploaderRepository.cs | 18 + .../ImoutoPicsUploaderState.cs | 10 + .../CollectionFileSystemTests.cs | 53 +++ .../Fixtures/TestWebApplicationFactory.cs | 8 + .../ImoutoPicsUploaderEnabledTests.cs | 43 ++ ...ImoutoRebirth.Room.IntegrationTests.csproj | 1 + .../WebApi/EndpointsMappings.cs | 18 + .../WebApi/WebApiStartup.cs | 1 + .../Clients.cs | 407 +++++++++++++++++- 20 files changed, 683 insertions(+), 22 deletions(-) create mode 100644 Source/ImoutoRebirth.Navigator/ImoutoRebirth.Navigator/Services/Collections/IImoutoPicsUploaderStateService.cs create mode 100644 Source/ImoutoRebirth.Navigator/ImoutoRebirth.Navigator/Services/Collections/ImoutoPicsUploaderStateService.cs create mode 100644 Source/ImoutoRebirth.Room/ImoutoRebirth.Room.Application/Cqrs/ImoutoPicsUploadStateSlice/EnableImoutoPicsUploaderCommand.cs create mode 100644 Source/ImoutoRebirth.Room/ImoutoRebirth.Room.Application/Cqrs/ImoutoPicsUploadStateSlice/IsImoutoPicsUploaderEnabledQuery.cs create mode 100644 Source/ImoutoRebirth.Room/ImoutoRebirth.Room.Application/Services/IImoutoPicsUploaderRepository.cs create mode 100644 Source/ImoutoRebirth.Room/ImoutoRebirth.Room.Domain/ImoutoPicsUploaderState.cs create mode 100644 Source/ImoutoRebirth.Room/ImoutoRebirth.Room.IntegrationTests/ImoutoPicsUploaderEnabledTests.cs diff --git a/CHANGELOG.md b/CHANGELOG.md index 75cab577..8948485b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,10 +5,15 @@ ### Navigator * Fix webp previews in the list view +* Add button to enable/disable imouto pics upload in Room ### Viewer * Add jfif to the list of supported image formats +### Room +* Add in-memory settings to enable/disable imouto pics upload and api for it +* Add tests for the imouto pics upload settings + # 4.24.0 ### Navigator diff --git a/Source/ImoutoRebirth.Navigator/ImoutoRebirth.Navigator/Services/Collections/IImoutoPicsUploaderStateService.cs b/Source/ImoutoRebirth.Navigator/ImoutoRebirth.Navigator/Services/Collections/IImoutoPicsUploaderStateService.cs new file mode 100644 index 00000000..17115500 --- /dev/null +++ b/Source/ImoutoRebirth.Navigator/ImoutoRebirth.Navigator/Services/Collections/IImoutoPicsUploaderStateService.cs @@ -0,0 +1,10 @@ +namespace ImoutoRebirth.Navigator.Services.Collections; + +public interface IImoutoPicsUploaderStateService +{ + Task EnableAsync(); + + Task DisableAsync(); + + Task IsEnabledAsync(); +} diff --git a/Source/ImoutoRebirth.Navigator/ImoutoRebirth.Navigator/Services/Collections/ImoutoPicsUploaderStateService.cs b/Source/ImoutoRebirth.Navigator/ImoutoRebirth.Navigator/Services/Collections/ImoutoPicsUploaderStateService.cs new file mode 100644 index 00000000..8c7eafab --- /dev/null +++ b/Source/ImoutoRebirth.Navigator/ImoutoRebirth.Navigator/Services/Collections/ImoutoPicsUploaderStateService.cs @@ -0,0 +1,20 @@ +using ImoutoRebirth.Room.WebApi.Client; + +namespace ImoutoRebirth.Navigator.Services.Collections; + +internal class ImoutoPicsUploaderStateService : IImoutoPicsUploaderStateService +{ + private readonly ImoutoPicsUploaderEnabledClient _imoutoPicsUploaderEnabledClient; + + public ImoutoPicsUploaderStateService(ImoutoPicsUploaderEnabledClient imoutoPicsUploaderEnabledClient) + => _imoutoPicsUploaderEnabledClient = imoutoPicsUploaderEnabledClient; + + public async Task EnableAsync() + => await _imoutoPicsUploaderEnabledClient.EnableImoutoPicsUploaderAsync(); + + public async Task DisableAsync() + => await _imoutoPicsUploaderEnabledClient.DisableImoutoPicsUploaderAsync(); + + public async Task IsEnabledAsync() + => await _imoutoPicsUploaderEnabledClient.IsImoutoPicsUploaderEnabledAsync(); +} diff --git a/Source/ImoutoRebirth.Navigator/ImoutoRebirth.Navigator/Services/ServiceLocator.cs b/Source/ImoutoRebirth.Navigator/ImoutoRebirth.Navigator/Services/ServiceLocator.cs index 7f4a8587..0c238513 100644 --- a/Source/ImoutoRebirth.Navigator/ImoutoRebirth.Navigator/Services/ServiceLocator.cs +++ b/Source/ImoutoRebirth.Navigator/ImoutoRebirth.Navigator/Services/ServiceLocator.cs @@ -23,7 +23,7 @@ static ServiceLocator() sc.AddTransient(); sc.AddTransient(); sc.AddTransient(); - + sc.AddTransient(); sc.AddTransient(); sc.AddTransient(); diff --git a/Source/ImoutoRebirth.Navigator/ImoutoRebirth.Navigator/View/Flyouts/SettingsView.xaml b/Source/ImoutoRebirth.Navigator/ImoutoRebirth.Navigator/View/Flyouts/SettingsView.xaml index 2bd38bcd..1188562d 100644 --- a/Source/ImoutoRebirth.Navigator/ImoutoRebirth.Navigator/View/Flyouts/SettingsView.xaml +++ b/Source/ImoutoRebirth.Navigator/ImoutoRebirth.Navigator/View/Flyouts/SettingsView.xaml @@ -123,6 +123,15 @@ Header="Auto shuffle on every load" IsOn="{Binding AutoShuffle}" /> + + +