Skip to content

Commit b07dd48

Browse files
committed
refactoring
1 parent 0c016db commit b07dd48

File tree

72 files changed

+720
-1485
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

72 files changed

+720
-1485
lines changed

Directory.Build.props

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<Project>
22
<PropertyGroup>
3-
<Version>1.3.1</Version>
3+
<Version>1.3.2</Version>
44
<TargetFramework>net9.0</TargetFramework>
55
<Nullable>enable</Nullable>
66
<LangVersion>latest</LangVersion>

Web.Blazor/ControllersV2/AddonsController.cs renamed to Web.Blazor/Controllers/AddonsController.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
using MediatR;
44
using Microsoft.AspNetCore.Mvc;
55

6-
namespace Web.Blazor.ControllersV2;
6+
namespace Web.Blazor.Controllers;
77

88
[ApiController]
99
[Route("api/addons")]

Web.Blazor/ControllersV2/ReleasesController.cs renamed to Web.Blazor/Controllers/ReleasesController.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
using MediatR;
44
using Microsoft.AspNetCore.Mvc;
55

6-
namespace Web.Blazor.ControllersV2;
6+
namespace Web.Blazor.Controllers;
77

88
[ApiController]
99
[Route("api/releases")]

Web.Blazor/ControllersV1/AddonsController.cs

Lines changed: 0 additions & 69 deletions
This file was deleted.

Web.Blazor/ControllersV1/ReleasesController.cs

Lines changed: 0 additions & 84 deletions
This file was deleted.

Web.Blazor/ControllersV1/StorageController.cs

Lines changed: 0 additions & 29 deletions
This file was deleted.

Web.Blazor/Helpers/S3Client.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
using Amazon.Runtime;
22
using Amazon.S3;
33
using Amazon.S3.Model;
4-
using Common.Helpers;
54

65
namespace Web.Blazor.Helpers;
76

Web.Blazor/Program.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,10 +56,10 @@ public static void Main(string[] args)
5656
_ = builder.Services.AddSingleton<DatabaseAddonsRetriever>();
5757
_ = builder.Services.AddSingleton<IRetriever<Dictionary<PortEnum, GeneralReleaseEntity>?>>();
5858

59-
_ = builder.Services.AddSingleton<HttpClient>(CreateHttpClient);
59+
_ = builder.Services.AddSingleton(CreateHttpClient);
6060
_ = builder.Services.AddSingleton<S3Client>();
6161

62-
_ = builder.Services.AddSingleton<DatabaseContextFactory>(x => new(builder.Environment.IsDevelopment()));
62+
_ = builder.Services.AddSingleton<DatabaseContextFactory>(_ => new(builder.Environment.IsDevelopment()));
6363

6464
_ = builder.Services.AddMediatR(cfg => cfg.RegisterServicesFromAssemblyContaining<Program>());
6565

Web.Blazor/Providers/DatabaseAddonsRetriever.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ public sealed class DatabaseAddonsRetriever
1313
private readonly ILogger<DatabaseAddonsRetriever> _logger;
1414
private readonly DatabaseContextFactory _dbContextFactory;
1515

16-
public GeneralReleaseEntity? AppRelease { get; private set; }
16+
public GeneralReleaseEntity? AppRelease { get; }
1717

1818
public DatabaseAddonsRetriever(
1919
ILogger<DatabaseAddonsRetriever> logger,
@@ -123,7 +123,7 @@ internal int IncreaseNumberOfInstalls(string addonId)
123123
}
124124
else
125125
{
126-
fix.Installs += 1;
126+
fix.Installs++;
127127
newInstalls = fix.Installs;
128128
}
129129

src/Addons/Addons/StandaloneAddon.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
11
namespace Addons.Addons;
22

3-
public sealed class StandaloneAddon : BaseAddon
4-
{
5-
}
3+
public sealed class StandaloneAddon : BaseAddon;

src/Addons/Helpers/AutoloadModsValidator.cs

Lines changed: 38 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ private static bool CheckDependencies(
8282
{
8383
continue;
8484
}
85-
85+
8686
if (dependentAddon.Value is null)
8787
{
8888
passedDependenciesCount++;
@@ -107,54 +107,52 @@ private static bool CheckDependencies(
107107
/// </summary>
108108
private static bool CheckIncompatibles(AutoloadMod autoloadMod, IAddon campaign, Dictionary<AddonVersion, IAddon> mods)
109109
{
110-
if (autoloadMod.IncompatibleAddons is not null)
110+
if (autoloadMod.IncompatibleAddons is null)
111+
{
112+
return true;
113+
}
114+
115+
foreach (var incompatibleAddon in autoloadMod.IncompatibleAddons)
111116
{
112-
foreach (var incompatibleAddon in autoloadMod.IncompatibleAddons)
117+
//What a fucking mess...
118+
//if campaign id equals addon id
119+
if (campaign.Id.Equals(incompatibleAddon.Key, StringComparison.InvariantCultureIgnoreCase) &&
120+
//AND either incompatible addon's version is null
121+
(incompatibleAddon.Value is null ||
122+
//OR campaign's version is null
123+
campaign.Version is null ||
124+
//OR addon's and campaigns's versions match
125+
VersionComparer.Compare(campaign.Version, incompatibleAddon.Value)
126+
))
113127
{
114-
//What a fucking mess...
115-
//if campaign id equals addon id
116-
if (campaign.Id.Equals(incompatibleAddon.Key, StringComparison.InvariantCultureIgnoreCase) &&
117-
//AND either incompatible addon's version is null
118-
(incompatibleAddon.Value is null ||
119-
//OR campaign's version is null
120-
campaign.Version is null ||
121-
//OR addon's version is not null and matches the comparer
122-
(incompatibleAddon.Value is not null && VersionComparer.Compare(campaign.Version, incompatibleAddon.Value))
123-
))
128+
//the addon is incompatible
129+
return false;
130+
}
131+
132+
foreach (var addon in mods)
133+
{
134+
if (incompatibleAddon.Key != addon.Key.Id)
124135
{
125-
//the addon is incompatible
126-
return false;
136+
continue;
127137
}
128138

129-
foreach (var addon in mods)
139+
if (addon.Value is AutoloadMod aMod &&
140+
!aMod.IsEnabled)
130141
{
131-
if (incompatibleAddon.Key != addon.Key.Id)
132-
{
133-
continue;
134-
}
142+
continue;
143+
}
135144

136-
if (addon.Value is AutoloadMod aMod &&
137-
!aMod.IsEnabled)
138-
{
139-
continue;
140-
}
141-
142-
if (incompatibleAddon.Value is null)
143-
{
144-
return false;
145-
}
146-
else if (VersionComparer.Compare(addon.Key.Version, incompatibleAddon.Value))
147-
{
148-
return false;
149-
}
145+
if (incompatibleAddon.Value is null)
146+
{
147+
return false;
148+
}
149+
else if (VersionComparer.Compare(addon.Key.Version, incompatibleAddon.Value))
150+
{
151+
return false;
150152
}
151153
}
152-
153-
return true;
154-
}
155-
else
156-
{
157-
return true;
158154
}
155+
156+
return true;
159157
}
160158
}

src/Addons/Providers/DownloadableAddonsProvider.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ public ImmutableList<IDownloadableAddon> GetDownloadableAddons(AddonTypeEnum add
142142
{
143143
downloadableAddon.Value.HasNewerVersion = true;
144144

145-
if (VersionComparer.Compare(downloadableAddon.Value.Version, existingVersion!, "<="))
145+
if (VersionComparer.Compare(downloadableAddon.Value.Version, existingVersion, "<="))
146146
{
147147
downloadableAddon.Value.HasNewerVersion = false;
148148
break;

src/Addons/Providers/InstalledAddonsProvider.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public sealed class InstalledAddonsProvider : IInstalledAddonsProvider
3131

3232
public event AddonChanged? AddonsChangedEvent;
3333

34-
[Obsolete($"Don't create directly. Use {nameof(InstalledAddonsProvider)}.")]
34+
[Obsolete($"Don't create directly. Use {nameof(InstalledAddonsProviderFactory)}.")]
3535
public InstalledAddonsProvider(
3636
IGame game,
3737
IConfigProvider config,

0 commit comments

Comments
 (0)