Skip to content

Commit

Permalink
Fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Aragas committed Oct 16, 2024
1 parent 71e2383 commit 8087118
Show file tree
Hide file tree
Showing 10 changed files with 2,079 additions and 24 deletions.
6 changes: 3 additions & 3 deletions src/BUTR.Site.NexusMods.Client/Pages/User/Mods.razor
Original file line number Diff line number Diff line change
Expand Up @@ -241,10 +241,10 @@

private async Task<bool> DoSteamWorkshopLinkMod(LinkModModel model)
{
if (!NexusModsUtils.TryParseModUrl(model.ModUrl, out _, out var modId) && !uint.TryParse(model.ModUrl, out modId))
return false;
if (!SteamUtils.TryParseWorkshopId(model.ModUrl, out var modId))
modId = model.ModUrl;

return await _userClient.AddSteamWorkshopModLinkAsync((int) modId) is { Error: null };
return await _userClient.AddSteamWorkshopModLinkAsync(modId) is { Error: null };
}

private async Task<bool> DoNexusModsUnlinkMod(UserLinkedNexusModsModModel model)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,17 +127,17 @@ public async Task<UserAvailableSteamWorkshopModModelPagingDataApiResultModel> Ge
return await _implementation.GetSteamWorkshopModsPaginateAvailabledAsync(body, ct);
}

public async Task<StringApiResultModel> AddSteamWorkshopModLinkAsync(int modId, int? userId = null, string? username = null, CancellationToken ct = default)
public async Task<StringApiResultModel> AddSteamWorkshopModLinkAsync(string modId, int? userId = null, string? username = null, CancellationToken ct = default)
{
return await _implementation.AddSteamWorkshopModLinkAsync(modId, userId, username, ct);
}

public async Task<StringApiResultModel> UpdateSteamWorkshopModLinkAsync(int modId, int? userId = null, string? username = null, CancellationToken ct = default)
public async Task<StringApiResultModel> UpdateSteamWorkshopModLinkAsync(string modId, int? userId = null, string? username = null, CancellationToken ct = default)
{
return await _implementation.UpdateSteamWorkshopModLinkAsync(modId, userId, username, ct);
}

public async Task<StringApiResultModel> RemoveSteamWorkshopModLinkAsync(int modId, int? userId = null, string? username = null, CancellationToken ct = default)
public async Task<StringApiResultModel> RemoveSteamWorkshopModLinkAsync(string modId, int? userId = null, string? username = null, CancellationToken ct = default)
{
return await _implementation.RemoveSteamWorkshopModLinkAsync(modId, userId, username, ct);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ public static bool TryFromModel(

var steamWorkshopModId = SteamWorkshopModId.DefaultValue;
steamWorkshopModId = SteamWorkshopModId.TryParseUrl(x.Url, out var steamWorkshopModIdVal) ? steamWorkshopModIdVal : steamWorkshopModId;
steamWorkshopModId = x.AdditionalMetadata.FirstOrDefault(x => x.Key == "SteamWorkshopModId") is { Value: { } steamWorkshopModIdStr } && int.TryParse(steamWorkshopModIdStr, out var steamWorkshopModIdRaw) ? SteamWorkshopModId.From(steamWorkshopModIdRaw) : steamWorkshopModId;
steamWorkshopModId = x.AdditionalMetadata.FirstOrDefault(x => x.Key == "SteamWorkshopModId") is { Value: { } steamWorkshopModIdStr } ? SteamWorkshopModId.From(steamWorkshopModIdStr) : steamWorkshopModId;

return new CrashReportToModuleMetadataEntity
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ private static bool TryFromModel(

var steamWorkshopModId = SteamWorkshopModId.DefaultValue;
steamWorkshopModId = SteamWorkshopModId.TryParseUrl(x.Url, out var steamWorkshopModIdVal) ? steamWorkshopModIdVal : steamWorkshopModId;
steamWorkshopModId = x.AdditionalMetadata.FirstOrDefault(x => x.Key == "SteamWorkshopModId") is { Value: { } steamWorkshopModIdStr } && int.TryParse(steamWorkshopModIdStr, out var steamWorkshopModIdRaw) ? SteamWorkshopModId.From(steamWorkshopModIdRaw) : steamWorkshopModId;
steamWorkshopModId = x.AdditionalMetadata.FirstOrDefault(x => x.Key == "SteamWorkshopModId") is { Value: { } steamWorkshopModIdStr } ? SteamWorkshopModId.From(steamWorkshopModIdStr) : steamWorkshopModId;

return new CrashReportToModuleMetadataEntity
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
using System.Globalization;

namespace BUTR.Site.NexusMods.Server.Models;

using TType = SteamWorkshopModId;
using TValueType = Int32;
using TValueType = String;

[ValueObject<TValueType>(conversions: Conversions.EfCoreValueConverter | Conversions.SystemTextJson | Conversions.TypeConverter)]
public readonly partial struct SteamWorkshopModId : IHasDefaultValue<TType>
{
public static readonly TType None = new(0);
public static readonly TType None = new(string.Empty);

public static TType DefaultValue => None;

Expand All @@ -29,6 +31,6 @@ public static bool TryParseUrl(string? urlRaw, out TType modId)
if (!string.Equals(mods, "mods", StringComparison.OrdinalIgnoreCase))
return false;

return TryParse(modIdRaw, out modId);
return TryParse(modIdRaw, CultureInfo.InvariantCulture, out modId);
}
}
Loading

0 comments on commit 8087118

Please sign in to comment.