Skip to content

Commit

Permalink
added notification variable
Browse files Browse the repository at this point in the history
- Added a variable to showing the download notification, so when you're reading manga and going to the next chapter it doesnt everytime show the notification.

The notification variable is set to true so no other code needs to ask if it wants to show the notification and keeps working like it used to
  • Loading branch information
merlinmarijn committed Feb 7, 2024
1 parent 509e9de commit 050f8fb
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
3 changes: 2 additions & 1 deletion src/components/reader/ReaderPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,8 @@ const ReaderPage: React.FC<Props> = (props: Props) => {
DownloadUnreadChapters(
seriesArr,
customDownloadsDir || String(getDefaultDownloadDir()),
OnStartUpDownloadUnreadCount
OnStartUpDownloadUnreadCount,
false
);
}
return true;
Expand Down
5 changes: 3 additions & 2 deletions src/features/library/chapterDownloadUtils.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,8 @@ export async function downloadAll(
export async function DownloadUnreadChapters(
seriesList: Series[],
downloadsDir: string,
count = 1
count = 1,
notification: boolean = true

Check failure on line 106 in src/features/library/chapterDownloadUtils.tsx

View workflow job for this annotation

GitHub Actions / build (18, macos-latest)

Type boolean trivially inferred from a boolean literal, remove type annotation
) {
seriesList
.filter((series) => library.validURL(series.sourceId))
Expand Down Expand Up @@ -133,7 +134,7 @@ export async function DownloadUnreadChapters(
} as DownloadTask)
)
);
downloaderClient.start();
downloaderClient.start(notification);
await new Promise((resolve) => setTimeout(resolve, 1000));
});
}
Expand Down
6 changes: 4 additions & 2 deletions src/services/downloader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ class DownloaderClient {
this.setDownloadErrors([...this.downloadErrors, downloadError]);
};

start = async () => {
start = async (notification: boolean = true) => {

Check failure on line 102 in src/services/downloader.ts

View workflow job for this annotation

GitHub Actions / build (18, macos-latest)

Type boolean trivially inferred from a boolean literal, remove type annotation
if (this.running) return;

if (this.queue.length === 0) {
Expand All @@ -109,7 +109,9 @@ class DownloaderClient {

const startingQueueSize = this.queue.length;
const notificationId = uuidv4();
showNotification({ id: notificationId, message: 'Starting download...', loading: true });
if (notification) {
showNotification({ id: notificationId, message: 'Starting download...', loading: true });
}

this.setRunning(true);
let tasksCompleted = 0;
Expand Down

0 comments on commit 050f8fb

Please sign in to comment.