Skip to content

Commit

Permalink
fix breaking changes, may need to come back and cleanup warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
Yucked committed Nov 19, 2023
1 parent f8088d2 commit a8a459c
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 26 deletions.
10 changes: 4 additions & 6 deletions src/Components/MangaCard.razor
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@

@using Grimoire.Models
@using Grimoire.Models
@using Grimoire.Handlers
@using Grimoire.Helpers

@inject CacheHandler CacheHandler
@inject DatabaseHandler DatabaseHandler
@inject NavigationManager NavigationManager
@inject IConfiguration Configuration

<div class="card h-100 shadow-sm" @onclick="() => NavTo(Manga.Id)">
<img src="@Configuration.GetCover(CacheHandler.Get<string>($"{SourceId}@{Manga.Id}"), Manga.Cover)"
<img src="@Configuration.GetCover(DatabaseHandler.Get<string>($"{SourceId}@{Manga.Id}")!, Manga.Cover)"
class="card-img-top" alt="@Manga.Name">
<div class="card-body">
<h5 class="card-title">
Expand Down Expand Up @@ -48,8 +47,7 @@
}

private static string Truncate(string str) {
return str?.Length > 150 ?
$"{str[..150]}..." : str;
return str.Length > 150 ? $"{str[..150]}..." : str;
}

}
2 changes: 1 addition & 1 deletion src/Handlers/DatabaseHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ public async Task<Chapter> GetChapterAsync(string sourceId, string mangaId, int
return chapter;
}

public async Task<IReadOnlyList<IGrimoireSource>> ListSourcesAsync(string sourceId) {
public async Task<IReadOnlyList<IGrimoireSource>> ListSourcesAsync() {
if (!config.GetValue<bool>("Save:SourceIcon")) {
return _sources.ToArray();
}
Expand Down
10 changes: 5 additions & 5 deletions src/Pages/ChapterPage.razor
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
@using Grimoire.Handlers
@using Grimoire.Helpers

@inject CacheHandler CacheHandler
@inject DatabaseHandler DatabaseHandler

<div class="container-lg py-4">
<picture class="p-4">
Expand Down Expand Up @@ -43,10 +43,10 @@
=> $"Loading {MangaId.GetNameFromId()} {Chap}";

protected override async Task OnInitializedAsync() {
_chapter = await CacheHandler.GetChapterAsync(SourceId, MangaId, Chap);
_chapter = !string.IsNullOrWhiteSpace(Chapter) ?
await CacheHandler.GetChapterAsync(SourceId, MangaId, Chapter) :
await CacheHandler.GetChapterAsync(SourceId, MangaId, Chap);
_chapter = await DatabaseHandler.GetChapterAsync(SourceId, MangaId, Chap);
_chapter = !string.IsNullOrWhiteSpace(Chapter)
? await DatabaseHandler.GetChapterAsync(SourceId, MangaId, int.Parse(Chapter))
: await DatabaseHandler.GetChapterAsync(SourceId, MangaId, Chap);
}

}
6 changes: 3 additions & 3 deletions src/Pages/Index.razor
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
@using Grimoire.Handlers

@inject NavigationManager NavigationManager
@inject DbHandler DbHandler
@inject DatabaseHandler DbHandler

<div class="container-lg py-4">
<div class="row row-cols-1 g-5">
Expand All @@ -24,8 +24,8 @@
}
else {
@foreach (var manga in _mangas
.OrderByDescending(x => x.Chapters.FirstOrDefault().ReleasedOn)
.Take(10)) {
.OrderByDescending(x => x.Chapters.FirstOrDefault().ReleasedOn)

Check warning on line 27 in src/Pages/Index.razor

View workflow job for this annotation

GitHub Actions / Build

Dereference of a possibly null reference.
.Take(10)) {
var chapter = manga.Chapters.FirstOrDefault();
<a class="list-group-item d-flex justify-content-between align-items-start list-group-item-action"
@onclick="() => GoToChapter(manga.SourceId, manga.Id, chapter.Name)">

Check warning on line 31 in src/Pages/Index.razor

View workflow job for this annotation

GitHub Actions / Build

Dereference of a possibly null reference.
Expand Down
7 changes: 3 additions & 4 deletions src/Pages/MangaPage.razor
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@
@using Grimoire.Handlers
@using Grimoire.Helpers

@inject DbHandler DbHandler
@inject CacheHandler CacheHandler
@inject DatabaseHandler DbHandler
@inject IConfiguration Configuration
@inject NavigationManager NavigationManager

Expand All @@ -19,7 +18,7 @@ else {
<div class="card mb-3 shadow rounded-4">
<div class="row gy-4">
<div class="col-md-4">
<img src="@Configuration.GetCover(CacheHandler.Get<string>($"{SourceId}@{_manga.Id}"), _manga.Cover)"
<img src="@Configuration.GetCover(DbHandler.Get<string>($"{SourceId}@{_manga.Id}"), _manga.Cover)"

Check warning on line 21 in src/Pages/MangaPage.razor

View workflow job for this annotation

GitHub Actions / Build

Possible null reference argument for parameter 'localPath' in 'string Extensions.GetCover(IConfiguration configuration, string localPath, string url)'.
class="card-img" alt="@_manga.Name">
</div>

Expand Down Expand Up @@ -123,7 +122,7 @@ else {
=> $"Loading {MangaId.GetNameFromId()}";

protected override async Task OnInitializedAsync() {
_manga = await CacheHandler.GetMangaAsync(SourceId, MangaId);
_manga = await DbHandler.GetMangaAsync(SourceId, MangaId);
}

private void NavTo(int chapter) {
Expand Down
8 changes: 4 additions & 4 deletions src/Pages/SourcePage.razor
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
@using Grimoire.Helpers
@using Grimoire.Models

@inject CacheHandler CacheHandler
@inject DatabaseHandler DatabaseHandler
@inject NavigationManager NavigationManager

<div class="container-lg py-4">
Expand All @@ -19,7 +19,7 @@
<div class="card-header">
<div class="d-flex justify-content-between align-items-start">
<h3 class="card-title">
<img src="@CacheHandler.GetSourceIcon(SourceId)"
<img src="@DatabaseHandler.GetSourceIcon(SourceId)"
alt="@SourceId" width="20">
<span>@SourceId.GetNameFromId() | <span class="badge bg-dark">Mangas: @_book.ItemCount</span></span>

Expand Down Expand Up @@ -79,13 +79,13 @@
private Page _currentPage;

Check warning on line 79 in src/Pages/SourcePage.razor

View workflow job for this annotation

GitHub Actions / Build

Non-nullable field '_currentPage' must contain a non-null value when exiting constructor. Consider declaring the field as nullable.

protected override async Task OnInitializedAsync() {
var mangas = await CacheHandler.GetMangasAsync(SourceId, false);
var mangas = await DatabaseHandler.GetMangasAsync(SourceId, false);
_book = new Book(mangas);
_currentPage = _book.GoTo(PageNumber);
}

private async Task RefreshAsync() {
var mangas = await CacheHandler.GetMangasAsync(SourceId, true);
var mangas = await DatabaseHandler.GetMangasAsync(SourceId, true);
_book = new Book(mangas);
_currentPage = _book.GoTo(PageNumber);
}
Expand Down
6 changes: 3 additions & 3 deletions src/Pages/SourcesPage.razor
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
@using Grimoire.Handlers
@using Grimoire.Sources.Interfaces

@inject CacheHandler CacheHandler
@inject DatabaseHandler DatabaseHandler
@inject NavigationManager NavigationManager

<div class="container p-4">
Expand All @@ -14,7 +14,7 @@
<ul class="list-group list-group-flush">
@foreach (var source in _sources) {
<a class="list-group-item list-group-item-action" @onclick="() => NavTo(source.Id)">
<img src="@CacheHandler.GetSourceIcon(source.Id)" class="img-thumbnail" alt="@source.Name" width="70">
<img src="@DatabaseHandler.GetSourceIcon(source.Id)" class="img-thumbnail" alt="@source.Name" width="70">
<span>@source.Name</span>
</a>
}
Expand All @@ -27,7 +27,7 @@
private IReadOnlyList<IGrimoireSource> _sources;

Check warning on line 27 in src/Pages/SourcesPage.razor

View workflow job for this annotation

GitHub Actions / Build

Non-nullable field '_sources' must contain a non-null value when exiting constructor. Consider declaring the field as nullable.

protected override async Task OnInitializedAsync() {
_sources = await CacheHandler.GetSourcesAsync();
_sources = await DatabaseHandler.ListSourcesAsync();
}

private void NavTo(string sourceId) {
Expand Down

0 comments on commit a8a459c

Please sign in to comment.