Skip to content

Commit

Permalink
fixed several bugs
Browse files Browse the repository at this point in the history
- Fixed a crash that occurred when clicking the Select All button in the Add from Library window
- The program will now add the manga's description in the epub file as the description
- The program will now accurately show the number of new chapters in bulk update checking (before it was just using maths, now it actually counts the number of new chapters, this especially affects mangas with a lot of decimal chapters)
- The program will now indicate to the user that they should add a link for mangas added from an external file
- Fixed a bug that caused the Delete Entry button and the Download New Chapters button to behave unpredictably when filtering
- Fixed a crash that occurred when an API error was encountered while checking for updates in bulk
- Fixed a small bug in the Edit Metadata window that kept the Update Cover button enabled when there was no link set
- Fixed a small bug that allowed a manga to be checked in bulk when it had no link set
- Error handling improvements
  • Loading branch information
ErisLoona committed Dec 16, 2024
1 parent 660f3f1 commit 3f833a4
Show file tree
Hide file tree
Showing 9 changed files with 100 additions and 93 deletions.
11 changes: 5 additions & 6 deletions .github/workflows/dotnet-desktop.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
name: .NET Core Desktop

on:
release:
types: [published]
push:
workflow_dispatch:

jobs:
Expand Down Expand Up @@ -34,7 +33,7 @@ jobs:
- name: Upload build artifacts
uses: actions/upload-artifact@v4
with:
name: Win64 Executable
name: Windows-MangaLibraryManager
path: bin/Release/net8.0/publish/win-x64/Manga Manager.exe

build-macos-arm:
Expand Down Expand Up @@ -73,7 +72,7 @@ jobs:
- name: Upload build artifacts
uses: actions/upload-artifact@v4
with:
name: macOS Apple Silicon Executable
name: macOSAppleSilicon-MangaLibraryManager
path: "Manga Library Manager.app/Contents/MacOS/Manga Manager"

build-macos-intel:
Expand Down Expand Up @@ -112,7 +111,7 @@ jobs:
- name: Upload build artifacts
uses: actions/upload-artifact@v4
with:
name: macOS Intel Executable
name: macOSIntel-MangaLibraryManager
path: "Manga Library Manager.app/Contents/MacOS/Manga Manager"

build-linux:
Expand Down Expand Up @@ -142,5 +141,5 @@ jobs:
- name: Upload build artifacts
uses: actions/upload-artifact@v4
with:
name: Linux Executable
name: Linux-MangaLibraryManager
path: bin/Release/net8.0/publish/linux-x64/Manga Manager
10 changes: 7 additions & 3 deletions BulkUpdateCheck.axaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,14 +49,18 @@ await Task.Run(() =>
MDLGetData.GetLastChapter();
if (apiError == true)
{
Dispatcher.UIThread.Post(async () => await MessageBoxManager.GetMessageBoxStandard("API error", "An error occurred while trying to contact the MangaDex API.\nPlease double-check the Manga link and try again later.", ButtonEnum.Ok).ShowAsync());
apiError = false;
return;
mangaIndexesNewChapters[i] = -1;
continue;
}
decimal onlineChapter = MDLGetData.GetLastChapter();
mangaList[i].OnlineLastChapter = onlineChapter;
mangaList[i].LastChecked = new DateOnly(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day);
mangaIndexesNewChapters[i] = Convert.ToInt32(Math.Ceiling(onlineChapter - mangaList[i].FileLastChapter));
int newChapters = 0;
for (int j = 0; j < MDLGetData.GetChapterNumbers().Count; j++)
if (MDLGetData.GetChapterNumbers()[j] > mangaList[i].FileLastChapter)
newChapters++;
mangaIndexesNewChapters[i] = newChapters;
progress.Report(0);
}
mangaIndexesNewChapters = mangaIndexesNewChapters.OrderByDescending(pair => pair.Value).ToDictionary();
Expand Down
5 changes: 1 addition & 4 deletions Downloader-AddFromLibrary.axaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,8 @@ private void SearchBox_KeyDown(object sender, KeyEventArgs e)

private void SelectAllButton_Clicked(object sender, RoutedEventArgs args)
{
foreach (Control child in MangaStackPanel.Children)
{
CheckBox checkBox = child as CheckBox;
foreach (CheckBox checkBox in checkBoxes)
checkBox.IsChecked = true;
}
}

private void ConfirmButton_Clicked(object sender, RoutedEventArgs args)
Expand Down
56 changes: 38 additions & 18 deletions Downloader.axaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -282,21 +282,19 @@ private void ChapterCheckBox_Checked(object sender, RoutedEventArgs e)
}
}

private async void AddMangaToQueue(string mangaID, bool isUpdate)
private void AddMangaToQueue(string mangaID, bool isUpdate)
{
MDLParameters.MangaID = mangaID;
QueuedManga newManga = new QueuedManga();
MDLGetData.GetTitles();
if (apiError == true)
{
await MessageBoxManager.GetMessageBoxStandard("API error", "An error occurred while trying to contact the MangaDex API.\nPlease double-check the Manga link and try again later.", ButtonEnum.Ok).ShowAsync();
apiError = false;
return;
}
MDLGetData.GetChapterIDs();
if (apiError == true)
{
await MessageBoxManager.GetMessageBoxStandard("API error", "An error occurred while trying to contact the MangaDex API.\nPlease double-check the Manga link and try again later.", ButtonEnum.Ok).ShowAsync();
apiError = false;
return;
}
Expand Down Expand Up @@ -671,6 +669,14 @@ private async void DownloadButton_Clicked(object sender, RoutedEventArgs args)
}
catch
{
try
{
Directory.Delete(tempFolderPath, true);
}
catch
{
Dispatcher.UIThread.Post(() => _ = MessageBoxManager.GetMessageBoxStandard("Write error", "Could not delete the temporary folder, please delete it yourself.").ShowAsync());
}
int indexHere3 = queueIndex;
Dispatcher.UIThread.Post(() =>
{
Expand Down Expand Up @@ -738,6 +744,14 @@ private async void DownloadButton_Clicked(object sender, RoutedEventArgs args)
{
if (skip == false)
{
try
{
Directory.Delete(tempFolderPath, true);
}
catch
{
Dispatcher.UIThread.Post(() => _ = MessageBoxManager.GetMessageBoxStandard("Write error", "Could not delete the temporary folder, please delete it yourself.").ShowAsync());
}
Dispatcher.UIThread.Post(() => AbortAll());
return;
}
Expand All @@ -751,7 +765,6 @@ private async void DownloadButton_Clicked(object sender, RoutedEventArgs args)
int indexHere3 = queueIndex;
Dispatcher.UIThread.Post(() =>
{
_ = MessageBoxManager.GetMessageBoxStandard("API error", "An error occurred while trying to contact the MangaDex API.\nPlease double-check the Manga link and try again later.\n This Manga will be skipped.", ButtonEnum.Ok).ShowAsync();
mangaQueueStatuses[indexHere3].Text = "Dropped: API error";
mangaQueueStatuses[indexHere3].Foreground = new SolidColorBrush(Color.FromRgb(130, 0, 0));
});
Expand All @@ -767,6 +780,14 @@ private async void DownloadButton_Clicked(object sender, RoutedEventArgs args)
{
if (skip == false)
{
try
{
Directory.Delete(tempFolderPath, true);
}
catch
{
Dispatcher.UIThread.Post(() => _ = MessageBoxManager.GetMessageBoxStandard("Write error", "Could not delete the temporary folder, please delete it yourself.").ShowAsync());
}
Dispatcher.UIThread.Post(() => AbortAll());
return;
}
Expand Down Expand Up @@ -831,6 +852,14 @@ private async void DownloadButton_Clicked(object sender, RoutedEventArgs args)
{
if (skip == false)
{
try
{
Directory.Delete(tempFolderPath, true);
}
catch
{
Dispatcher.UIThread.Post(() => _ = MessageBoxManager.GetMessageBoxStandard("Write error", "Could not delete the temporary folder, please delete it yourself.").ShowAsync());
}
Dispatcher.UIThread.Post(() => AbortAll());
return;
}
Expand Down Expand Up @@ -893,7 +922,6 @@ private async void DownloadButton_Clicked(object sender, RoutedEventArgs args)
int indexHere3 = queueIndex;
Dispatcher.UIThread.Post(() =>
{
_ = MessageBoxManager.GetMessageBoxStandard("API error", "An error occurred while trying to contact the MangaDex API.\nPlease double-check the Manga link and try again later.\n This Manga will be skipped.", ButtonEnum.Ok).ShowAsync();
mangaQueueStatuses[indexHere3].Text = "Dropped: API error";
mangaQueueStatuses[indexHere3].Foreground = new SolidColorBrush(Color.FromRgb(130, 0, 0));
});
Expand Down Expand Up @@ -1001,7 +1029,7 @@ private async void DownloadButton_Clicked(object sender, RoutedEventArgs args)
if (selectedChapterNumbers.Count > 0)
{
string nr = padDecimal(selectedChapterNumbers.Max(), "D" + selectedChapterNumbers.Count.ToString().Length.ToString());
doc.DocumentElement.SelectSingleNode("//dc:description", nsmgr).InnerText = "Last chapter: " + "Ch." + nr;
doc.DocumentElement.SelectSingleNode("//dc:description", nsmgr).InnerText = currentManga.TempManga.Description.Replace("\r\n", "<br>").Replace("\n", "<br>") + "<br>Last chapter: " + "Ch." + nr;
}

doc.DocumentElement.SelectSingleNode("//dc:title", nsmgr).InnerText = currentManga.TempManga.Title;
Expand Down Expand Up @@ -1384,18 +1412,10 @@ private void AbortAll()

QueueListBox.SelectedIndex = -1;

QueueListBox.SelectionChanged -= AltQueueListBox_SelectionChanged;
QueueListBox.SelectionChanged += QueueListBox_SelectionChanged;
TitleComboBox.IsEnabled = true;
QualityComboBox.IsEnabled = true;

AddFromLinkButton.IsEnabled = true;
AddFromLibraryButton.IsEnabled = true;
RemoveFromQueueButton.IsEnabled = true;

StatusTextBox.Text = "Add mangas to the queue!";
StatusTextBox.Foreground = new SolidColorBrush(Colors.White);
DownloadButton.Content = "Start downloading";
StatusTextBox.Text = "All downloads cancelled.";
StatusTextBox.Foreground = new SolidColorBrush(Color.FromRgb(130, 0, 0));
DownloadButton.Content = "Cancelled";
DownloadButton.IsEnabled = false;

for (int i = queueIndex; i < mangaQueue.Count; i++)
{
Expand Down
36 changes: 18 additions & 18 deletions EditMetadata.axaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,8 @@ public EditMetadata()
Dispatcher.UIThread.Post(() =>
{
CurrentCoverImage.Source = new Bitmap(stream);
UpdateCoverButton.IsEnabled = true;
if (mangaList[passIndex].ID != string.Empty)
UpdateCoverButton.IsEnabled = true;
});
return;
}
Expand Down Expand Up @@ -275,7 +276,6 @@ private void UpdateCoverButton_Clicked(object sender, RoutedEventArgs e)
newCoverStream.Seek(0, SeekOrigin.Begin);
if (apiError == true)
{
Dispatcher.UIThread.Post(async () => await MessageBoxManager.GetMessageBoxStandard("API error", "An error occurred while trying to contact the MangaDex API.\nPlease double-check the Manga link and try again later.", ButtonEnum.Ok).ShowAsync());
apiError = false;
return;
}
Expand All @@ -287,26 +287,24 @@ private void UpdateCoverButton_Clicked(object sender, RoutedEventArgs e)
});
}

private async void UpdateDescriptionButton_Clicked(object sender, RoutedEventArgs e)
private void UpdateDescriptionButton_Clicked(object sender, RoutedEventArgs e)
{
MDLParameters.MangaID = LinkTextBox.Text.Split('/')[4];
MDLGetData.GetDescription();
if (apiError == true)
{
await MessageBoxManager.GetMessageBoxStandard("API error", "An error occurred while trying to contact the MangaDex API.\nPlease double-check the Manga link and try again later.", ButtonEnum.Ok).ShowAsync();
apiError = false;
return;
}
DescriptionTextBox.Text = MDLGetData.GetDescription();
}

private async void UpdateOngoingStatusButton_Clicked(object sender, RoutedEventArgs e)
private void UpdateOngoingStatusButton_Clicked(object sender, RoutedEventArgs e)
{
MDLParameters.MangaID = LinkTextBox.Text.Split('/')[4];
MDLGetData.GetStatus();
if (apiError == true)
{
await MessageBoxManager.GetMessageBoxStandard("API error", "An error occurred while trying to contact the MangaDex API.\nPlease double-check the Manga link and try again later.", ButtonEnum.Ok).ShowAsync();
apiError = false;
return;
}
Expand All @@ -319,26 +317,24 @@ private void OpenLinkButton_Clicked(object sender, RoutedEventArgs e)
OpenLink(LinkTextBox.Text);
}

private async void UpdateContentRatingButton_Clicked(object sender, RoutedEventArgs e)
private void UpdateContentRatingButton_Clicked(object sender, RoutedEventArgs e)
{
MDLParameters.MangaID = LinkTextBox.Text.Split('/')[4];
MDLGetData.GetContentRating();
if (apiError == true)
{
await MessageBoxManager.GetMessageBoxStandard("API error", "An error occurred while trying to contact the MangaDex API.\nPlease double-check the Manga link and try again later.", ButtonEnum.Ok).ShowAsync();
apiError = false;
return;
}
ContentRatingComboBox.SelectedIndex = Array.IndexOf(contentRatings, MDLGetData.GetContentRating().Substring(0, 1).ToUpper() + MDLGetData.GetContentRating().Substring(1));
}

private async void UpdateTagsButton_Clicked(object sender, RoutedEventArgs e)
private void UpdateTagsButton_Clicked(object sender, RoutedEventArgs e)
{
MDLParameters.MangaID = LinkTextBox.Text.Split('/')[4];
List<string> newTags = MDLGetData.GetTags();
if (apiError == true)
{
await MessageBoxManager.GetMessageBoxStandard("API error", "An error occurred while trying to contact the MangaDex API.\nPlease double-check the Manga link and try again later.", ButtonEnum.Ok).ShowAsync();
apiError = false;
return;
}
Expand Down Expand Up @@ -403,16 +399,17 @@ private async void NewTagButton_Clicked(object sender, RoutedEventArgs e)

private void LinkTextBox_TextChanged(object sender, TextChangedEventArgs e)
{
if (ValidateLink(LinkTextBox.Text) == true)
bool isLinkGood = ValidateLink(LinkTextBox.Text);
if (isLinkGood == true)
MDLParameters.MangaID = LinkTextBox.Text.Split('/')[4];
UpdateAllButton.IsEnabled = ValidateLink(LinkTextBox.Text);
UpdateAllButton.IsEnabled = isLinkGood;
if (CurrentCoverImage != null)
UpdateCoverButton.IsEnabled = ValidateLink(LinkTextBox.Text);
UpdateDescriptionButton.IsEnabled = ValidateLink(LinkTextBox.Text);
UpdateOngoingStatusButton.IsEnabled = ValidateLink(LinkTextBox.Text);
UpdateContentRatingButton.IsEnabled = ValidateLink(LinkTextBox.Text);
UpdateTagsButton.IsEnabled = ValidateLink(LinkTextBox.Text);
OpenLinkButton.IsEnabled = ValidateLink(LinkTextBox.Text);
UpdateCoverButton.IsEnabled = isLinkGood;
UpdateDescriptionButton.IsEnabled = isLinkGood;
UpdateOngoingStatusButton.IsEnabled = isLinkGood;
UpdateContentRatingButton.IsEnabled = isLinkGood;
UpdateTagsButton.IsEnabled = isLinkGood;
OpenLinkButton.IsEnabled = isLinkGood;
}

private void UpdateAllButton_Clicked(object sender, RoutedEventArgs e)
Expand Down Expand Up @@ -468,7 +465,10 @@ protected override void OnClosing(WindowClosingEventArgs e)
if (ValidateLink(LinkTextBox.Text) == true)
mangaList[passIndex].ID = LinkTextBox.Text.Split('/')[4];
else
{
mangaList[passIndex].ID = string.Empty;
mangaList[passIndex].CheckInBulk = false;
}
if (ContentRatingComboBox.SelectedIndex != -1)
mangaList[passIndex].ContentRating = contentRatings[ContentRatingComboBox.SelectedIndex];
mangaList[passIndex].Tags.Clear();
Expand Down
3 changes: 3 additions & 0 deletions Globals.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using MsBox.Avalonia.Enums;
using MsBox.Avalonia;
using System.Diagnostics;
using Avalonia.Threading;

namespace Manga_Manager
{
Expand Down Expand Up @@ -53,6 +54,8 @@ static Globals()

internal static void MDLGetData_ApiRequestFailed(object sender, EventArgs e)
{
Dispatcher.UIThread.Post(async () => await MessageBoxManager.GetMessageBoxStandard("API error", "An error occurred while trying to contact the MangaDex API.\nPlease double-check the Manga link and try again later.", ButtonEnum.Ok).ShowAsync());
MDLGetData.ForceReset();
apiError = true;
}

Expand Down
Loading

0 comments on commit 3f833a4

Please sign in to comment.