Skip to content

Commit

Permalink
Added crash reports reminder
Browse files Browse the repository at this point in the history
  • Loading branch information
Aragas committed Jul 2, 2024
1 parent a4200a9 commit 322e740
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 2 deletions.
21 changes: 21 additions & 0 deletions src/BUTR.Site.NexusMods.Client/Pages/User/CrashReportsViewer.razor
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,20 @@
</CardTitle>
</CardHeader>
<CardBody>
<Alert Color="Color.Warning" @bind-Visible="@_hideReminder">
<Heading Size="HeadingSize.Is4" TextColor="TextColor.Secondary">
Reminder!
<CloseButton Clicked="OnCloseAlarm" />
</Heading>
<AlertMessage>
Don't see any crash reports? Make sure you've linked your mods in the <Link href="mods">Mods</Link> page!
<br/>
Still not seeing any? Make sure your mod contains a SubModule.xml file with the <Link href="https://github.com/BUTR/Bannerlord.BLSE?tab=readme-ov-file#community-metadata">Url tag</Link> pointing to the NexusMods page!
<br/>
You can also contact <Link href="https://discord.com/users/219563269680136192">Aragas (BUTR)</Link> on Discord for help!
</AlertMessage>
</Alert>

<DataGridStreamingPaging @ref="@_datagridPagingRef" TItem="CrashReportModel2" GetFilters="@GetFilters" GetItems="@GetCrashReports" Sortable Filterable DefaultPageSize="@UserSettings.DefaultCrashReportPageSize" PageSizes="@UserSettings.AvailableCrashReportPageSizes" GetPageSize="@(x => x.CrashReportPageSize)" FixedHeader>
<DataGridColumns>
<DataGridColumnText TItem="CrashReportModel2" ElementId="game-version" Field="@nameof(CrashReportModel2.GameVersion)" Caption="Game Version" Filterable Placeholder="v1.0.0" Sortable SortField="@nameof(EntityFields.GameVersion)"/>
Expand Down Expand Up @@ -95,12 +109,14 @@
private enum EntityFields { GameVersion, Version, TopInvolvedModuleId, ExceptionType, CreatedAt, Status, Comment }

private Modal _modalRef = default!;
private bool _hideReminder;
private DataGridStreamingPaging<CrashReportModel2>? _datagridPagingRef;
private UserSettings? _userSettings;

/// <inheritdoc />
protected override async Task OnInitializedAsync()
{
_hideReminder = await _localStorage.GetItemAsync<bool?>("cr_hide_reminder") ?? true;
_userSettings = await _localStorage.GetItemAsync<UserSettings>("settings") ?? new();
}

Expand Down Expand Up @@ -194,4 +210,9 @@
await _datagridPagingRef.Reload();
}

private async Task OnCloseAlarm()
{
await _localStorage.SetItemAsync<bool?>("cr_hide_reminder", false);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,9 @@ public async Task GenerateAutoCompleteForGameVersionsAsync(CancellationToken ct)

public async Task<Paging<UserCrashReportModel>> GetCrashReportsPaginatedAsync(NexusModsUserEntity user, PaginatedQuery query, ApplicationRole applicationRole, CancellationToken ct)
{
var moduleIds = user.ToModules.Select(x => x.Module.ModuleId).ToHashSet();
var nexusModsModIds = user.ToNexusModsMods.Select(x => x.NexusModsMod.NexusModsModId).ToHashSet();
moduleIds.AddRange(_dbContext.NexusModsModModules.Where(x => nexusModsModIds.Contains(x.NexusModsModId)).Select(x => x.ModuleId));
var moduleIds = _dbContext.NexusModsModModules.Where(x => nexusModsModIds.Contains(x.NexusModsModId)).Select(x => x.ModuleId)
.Concat(user.ToModules.Select(x => x.Module.ModuleId));

IQueryable<UserCrashReportModel> DbQueryBase(Expression<Func<CrashReportEntity, bool>> predicate) => _dbContext.CrashReports
.Include(x => x.ToUsers).ThenInclude(x => x.NexusModsUser)
Expand Down

0 comments on commit 322e740

Please sign in to comment.