Skip to content

Commit

Permalink
Use file link
Browse files Browse the repository at this point in the history
  • Loading branch information
erri120 committed Nov 5, 2024
1 parent 7b31000 commit 7054a5d
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using NexusMods.Abstractions.NexusWebApi.Types;
using NexusMods.Abstractions.NexusWebApi.Types.V2;
using NexusMods.Abstractions.NexusWebApi.Types.V2.Uid;
using NexusMods.Abstractions.Telemetry;
using NexusMods.MnemonicDB.Abstractions.Attributes;
using NexusMods.MnemonicDB.Abstractions.Models;

Expand Down Expand Up @@ -50,4 +51,15 @@ public partial class NexusModsFileMetadata : IModelDefinition
/// Library Files that link to this file.
/// </summary>
public static readonly BackReferenceAttribute<NexusModsLibraryItem> LibraryFiles = new(NexusModsLibraryItem.FileMetadata);

public partial struct ReadOnly
{
public Uri GetUri()
{
// NOTE(erri120): This URI shows a single download button for the exact file
// The nmm=1 turns the button into a nxm:// link, without nmm=1 the button will download the file through the browser
// Example: https://www.nexusmods.com/stardewvalley/mods/29140?tab=files&file_id=115276&nmm=1
return NexusModsUrlBuilder.CreateGenericUri($"{ModPage.GetUri()}?tab=files&file_id={Uid.FileId}&nmm=1");
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ private async ValueTask DownloadOrOpenPage(NexusModsFileMetadata.ReadOnly fileMe
}
else
{
await _osInterop.OpenUrl(fileMetadata.ModPage.GetUri(), logOutput: false, fireAndForget: true, cancellationToken: cancellationToken);
await _osInterop.OpenUrl(fileMetadata.GetUri(), logOutput: false, fireAndForget: true, cancellationToken: cancellationToken);
}
}

Expand Down

0 comments on commit 7054a5d

Please sign in to comment.