Skip to content

Commit

Permalink
feat: add recycling of chapters when they fail
Browse files Browse the repository at this point in the history
  • Loading branch information
Thundernerd committed Feb 22, 2024
1 parent 88e2e5c commit 0187679
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/Mangarr.Stack/Pages/Activity/Activity.razor
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
<tbody>
@foreach ((ChapterProgressDocument? item, int index) in _items.WithIndex())
{
<ActivityItem Item="@item" Index="@(index + 1)"/>
<ActivityItem OnDelete="Refresh" Item="@item" Index="@(index + 1)"/>
}
</tbody>
</table>
Expand Down
13 changes: 5 additions & 8 deletions src/Mangarr.Stack/Pages/Activity/ActivityItem.razor
Original file line number Diff line number Diff line change
@@ -1,11 +1,4 @@
@code {

[Parameter] public ChapterProgressDocument Item { get; set; } = null!;
[Parameter] public int Index { get; set; }

}

<tr class="@(Item.IsActive ? "table-active" : "")">
<tr class="@(Item.IsActive ? "table-active" : "")">
<td>@Index</td>
<td>
<a href="manga/@Item.MangaId">@Item.MangaTitle</a>
Expand All @@ -17,6 +10,10 @@
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" class="bi bi-exclamation-triangle-fill warning-fill" viewBox="0 0 16 16">
<path d="M8.982 1.566a1.13 1.13 0 0 0-1.96 0L.165 13.233c-.457.778.091 1.767.98 1.767h13.713c.889 0 1.438-.99.98-1.767zM8 5c.535 0 .954.462.9.995l-.35 3.507a.552.552 0 0 1-1.1 0L7.1 5.995A.905.905 0 0 1 8 5m.002 6a1 1 0 1 1 0 2 1 1 0 0 1 0-2"/>
</svg>

<svg xmlns="http://www.w3.org/2000/svg" @onclick="Recycle" style="cursor: pointer" width="16" height="16" fill="currentColor" class="bi bi-recycle ms-2" viewBox="0 0 16 16">
<path d="M9.302 1.256a1.5 1.5 0 0 0-2.604 0l-1.704 2.98a.5.5 0 0 0 .869.497l1.703-2.981a.5.5 0 0 1 .868 0l2.54 4.444-1.256-.337a.5.5 0 1 0-.26.966l2.415.647a.5.5 0 0 0 .613-.353l.647-2.415a.5.5 0 1 0-.966-.259l-.333 1.242zM2.973 7.773l-1.255.337a.5.5 0 1 1-.26-.966l2.416-.647a.5.5 0 0 1 .612.353l.647 2.415a.5.5 0 0 1-.966.259l-.333-1.242-2.545 4.454a.5.5 0 0 0 .434.748H5a.5.5 0 0 1 0 1H1.723A1.5 1.5 0 0 1 .421 12.24zm10.89 1.463a.5.5 0 1 0-.868.496l1.716 3.004a.5.5 0 0 1-.434.748h-5.57l.647-.646a.5.5 0 1 0-.708-.707l-1.5 1.5a.5.5 0 0 0 0 .707l1.5 1.5a.5.5 0 1 0 .708-.707l-.647-.647h5.57a1.5 1.5 0 0 0 1.302-2.244z"/>
</svg>
}
else if (Item.IsActive)
{
Expand Down
19 changes: 19 additions & 0 deletions src/Mangarr.Stack/Pages/Activity/ActivityItem.razor.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
using Mangarr.Stack.Database.Documents;
using Mangarr.Stack.Database.Repositories;
using Microsoft.AspNetCore.Components;

namespace Mangarr.Stack.Pages.Activity;

public partial class ActivityItem
{
[Inject] public ChapterProgressRepository ChapterProgressRepository { get; set; } = null!;
[Parameter] public ChapterProgressDocument Item { get; set; } = null!;
[Parameter] public int Index { get; set; }
[Parameter] public EventCallback OnDelete { get; set; }

private async Task Recycle()
{
await ChapterProgressRepository.DeleteAsync(Item);
await OnDelete.InvokeAsync();
}
}

0 comments on commit 0187679

Please sign in to comment.