Skip to content

Commit

Permalink
Code Quality: Add Dummy update service for dev builds (files-communit…
Browse files Browse the repository at this point in the history
  • Loading branch information
heftymouse committed May 15, 2024
1 parent 66212b7 commit 1886002
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 3 deletions.
4 changes: 3 additions & 1 deletion src/Files.App/Helpers/Application/AppLifecycleHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -175,8 +175,10 @@ public static IHost ConfigureHost()
.AddSingleton<IAddItemService, AddItemService>()
#if STABLE || PREVIEW
.AddSingleton<IUpdateService, SideloadUpdateService>()
#elif STORE
.AddSingleton<IUpdateService, StoreUpdateService>()
#else
.AddSingleton<IUpdateService, UpdateService>()
.AddSingleton<IUpdateService, DummyUpdateService>()
#endif
.AddSingleton<IPreviewPopupService, PreviewPopupService>()
.AddSingleton<IDateTimeFormatterFactory, DateTimeFormatterFactory>()
Expand Down
52 changes: 52 additions & 0 deletions src/Files.App/Services/DummyUpdateService.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Files.App.Services
{
internal sealed class DummyUpdateService : IUpdateService
{
public bool IsUpdateAvailable => false;

public bool IsUpdating => false;

public bool IsAppUpdated => true;

public bool IsReleaseNotesAvailable => true;

public event PropertyChangedEventHandler? PropertyChanged { add { } remove { } }

public Task CheckAndUpdateFilesLauncherAsync()
{
return Task.CompletedTask;
}

public Task CheckForUpdatesAsync()
{
return Task.CompletedTask;
}

public Task CheckLatestReleaseNotesAsync(CancellationToken cancellationToken = default)
{
return Task.CompletedTask;
}

public Task DownloadMandatoryUpdatesAsync()
{
return Task.CompletedTask;
}

public Task DownloadUpdatesAsync()
{
return Task.CompletedTask;
}

public Task<string?> GetLatestReleaseNotesAsync(CancellationToken cancellationToken = default)
{
// No localization for dev-only string
return Task.FromResult((string?)"No release notes available for Dev build.");
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

namespace Files.App.Services
{
internal sealed class UpdateService : ObservableObject, IUpdateService
internal sealed class StoreUpdateService : ObservableObject, IUpdateService
{
private StoreContext? _storeContext;
private List<StorePackageUpdate>? _updatePackages;
Expand Down Expand Up @@ -46,7 +46,7 @@ public bool IsAppUpdated
get => SystemInformation.Instance.IsAppUpdated;
}

public UpdateService()
public StoreUpdateService()
{
_updatePackages = [];
}
Expand Down

0 comments on commit 1886002

Please sign in to comment.