Skip to content

Commit

Permalink
fixed a stupid bug
Browse files Browse the repository at this point in the history
  • Loading branch information
Yucked committed Nov 22, 2023
1 parent a8a459c commit 6001ed0
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
5 changes: 3 additions & 2 deletions src/Handlers/DatabaseHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,8 @@ public async Task<Manga> GetMangaAsync(string sourceId, string mangaId) {
}

public async Task<IReadOnlyCollection<Manga>> GetMangasAsync(string sourceId, bool fetchUpdates) {
var mangas = fetchUpdates
var collections = await (await database.ListCollectionNamesAsync()).ToListAsync();
var mangas = fetchUpdates || !collections.Contains(sourceId)
? await _sources
.First(x => x.Id == sourceId)
.GetMangasAsync()
Expand Down Expand Up @@ -133,7 +134,7 @@ public async Task<IReadOnlyCollection<Manga>> GetMangasAsync(string sourceId, bo
memoryCache.Set($"{sourceId}@{manga.Id}", path.WithCover(manga.Cover));
}

if (fetchUpdates) {
if (fetchUpdates || !collections.Contains(sourceId)) {
await database
.GetCollection<Manga>(manga.SourceId)
.ReplaceOneAsync(r => r.Id == manga.Id,
Expand Down
2 changes: 1 addition & 1 deletion src/Pages/MangaPage.razor
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ else {

<div class="card-footer">
<div class="d-grid d-md-flex justify-content-md-end">
<button type="button" class="btn btn-dark w-100" onclick="@AddToLibraryAsync()">
<button type="button" class="btn btn-dark w-100" onclick="@AddToLibraryAsync">
@(!_manga.IsInLibrary ? "❤️‍🔥 Add to library" : "🪅 Remove from library")
</button>
</div>
Expand Down
2 changes: 1 addition & 1 deletion src/Pages/SourcePage.razor
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
<span>@SourceId.GetNameFromId() | <span class="badge bg-dark">Mangas: @_book.ItemCount</span></span>

</h3>
<button class="btn btn-dark" onclick="@RefreshAsync()">Refresh 👀</button>
<button class="btn btn-dark" onclick="@RefreshAsync">Refresh 👀</button>
</div>
</div>
</div>
Expand Down

0 comments on commit 6001ed0

Please sign in to comment.