Fixes #97 missing jobs.
Implemented Equals(obj) functions for Chapter, DownloadChapter and DownloadNewChapters to check if jobs already exist.
This commit is contained in:
parent
0c135aa89e
commit
b5be4e0dd8
@ -41,6 +41,13 @@ public readonly struct Chapter : IComparable
|
||||
return $"Chapter {parentManga.sortName} {parentManga.internalId} {chapterNumber} {name}";
|
||||
}
|
||||
|
||||
public override bool Equals(object? obj)
|
||||
{
|
||||
if (obj is not Chapter)
|
||||
return false;
|
||||
return CompareTo(obj) == 0;
|
||||
}
|
||||
|
||||
public int CompareTo(object? obj)
|
||||
{
|
||||
if (obj is Chapter otherChapter)
|
||||
|
@ -43,4 +43,12 @@ public class DownloadChapter : Job
|
||||
downloadTask.Start();
|
||||
return Array.Empty<Job>();
|
||||
}
|
||||
|
||||
public override bool Equals(object? obj)
|
||||
{
|
||||
if (obj is not DownloadChapter otherJob)
|
||||
return false;
|
||||
return otherJob.mangaConnector == this.mangaConnector &&
|
||||
otherJob.chapter.Equals(this.chapter);
|
||||
}
|
||||
}
|
@ -48,4 +48,12 @@ public class DownloadNewChapters : Job
|
||||
progressToken.Complete();
|
||||
return jobs;
|
||||
}
|
||||
|
||||
public override bool Equals(object? obj)
|
||||
{
|
||||
if (obj is not DownloadNewChapters otherJob)
|
||||
return false;
|
||||
return otherJob.mangaConnector == this.mangaConnector &&
|
||||
otherJob.manga.Equals(this.manga);
|
||||
}
|
||||
}
|
@ -43,15 +43,7 @@ public class JobBoss : GlobalBase
|
||||
/// </summary>
|
||||
public bool ContainsJobLike(Job job)
|
||||
{
|
||||
if (job is DownloadChapter dcJob)
|
||||
{
|
||||
return this.GetJobsLike(dcJob.mangaConnector, chapter: dcJob.chapter).Any();
|
||||
}else if (job is DownloadNewChapters ncJob)
|
||||
{
|
||||
return this.GetJobsLike(ncJob.mangaConnector, ncJob.manga).Any();
|
||||
}
|
||||
|
||||
return false;
|
||||
return this.jobs.Any(existingJob => existingJob.Equals(job));
|
||||
}
|
||||
|
||||
public void RemoveJob(Job job)
|
||||
|
@ -48,4 +48,13 @@ public class UpdateMetadata : Job
|
||||
this.progressToken.Cancel();
|
||||
return Array.Empty<Job>();
|
||||
}
|
||||
|
||||
public override bool Equals(object? obj)
|
||||
{
|
||||
|
||||
if (obj is not UpdateMetadata otherJob)
|
||||
return false;
|
||||
return otherJob.mangaConnector == this.mangaConnector &&
|
||||
otherJob.manga.Equals(this.manga);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user