mirror of
https://github.com/C9Glax/tranga.git
synced 2025-02-23 15:50:13 +01:00
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}";
|
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)
|
public int CompareTo(object? obj)
|
||||||
{
|
{
|
||||||
if (obj is Chapter otherChapter)
|
if (obj is Chapter otherChapter)
|
||||||
|
@ -43,4 +43,12 @@ public class DownloadChapter : Job
|
|||||||
downloadTask.Start();
|
downloadTask.Start();
|
||||||
return Array.Empty<Job>();
|
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();
|
progressToken.Complete();
|
||||||
return jobs;
|
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>
|
/// </summary>
|
||||||
public bool ContainsJobLike(Job job)
|
public bool ContainsJobLike(Job job)
|
||||||
{
|
{
|
||||||
if (job is DownloadChapter dcJob)
|
return this.jobs.Any(existingJob => existingJob.Equals(job));
|
||||||
{
|
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void RemoveJob(Job job)
|
public void RemoveJob(Job job)
|
||||||
|
@ -48,4 +48,13 @@ public class UpdateMetadata : Job
|
|||||||
this.progressToken.Cancel();
|
this.progressToken.Cancel();
|
||||||
return Array.Empty<Job>();
|
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…
x
Reference in New Issue
Block a user