mirror of
https://github.com/gabehf/Fladder.git
synced 2026-03-17 19:26:35 -07:00
feat: Add max concurrent downloads to settings (#347)
Co-authored-by: PartyDonut <PartyDonut@users.noreply.github.com>
This commit is contained in:
parent
947da2390f
commit
8acd880329
7 changed files with 110 additions and 20 deletions
|
|
@ -1,17 +1,55 @@
|
|||
import 'package:background_downloader/background_downloader.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:riverpod_annotation/riverpod_annotation.dart';
|
||||
|
||||
import 'package:fladder/providers/settings/client_settings_provider.dart';
|
||||
|
||||
part 'background_download_provider.g.dart';
|
||||
|
||||
@Riverpod(keepAlive: true)
|
||||
FileDownloader backgroundDownloader(Ref ref) {
|
||||
return FileDownloader()
|
||||
..trackTasks()
|
||||
..configureNotification(
|
||||
running: const TaskNotification('Downloading', 'file: {filename}'),
|
||||
complete: const TaskNotification('Download finished', 'file: {filename}'),
|
||||
paused: const TaskNotification('Download paused', 'file: {filename}'),
|
||||
progressBar: true,
|
||||
class BackgroundDownloader extends _$BackgroundDownloader {
|
||||
@override
|
||||
FileDownloader build() {
|
||||
final maxDownloads = ref.read(clientSettingsProvider.select((value) => value.maxConcurrentDownloads));
|
||||
return FileDownloader()
|
||||
..configure(
|
||||
globalConfig: maxDownloads == 0
|
||||
? ("", "")
|
||||
: (
|
||||
Config.holdingQueue,
|
||||
(
|
||||
//maxConcurrent
|
||||
maxDownloads,
|
||||
//maxConcurrentByHost
|
||||
maxDownloads,
|
||||
//maxConcurrentByGroup
|
||||
maxDownloads,
|
||||
),
|
||||
),
|
||||
)
|
||||
..trackTasks()
|
||||
..configureNotification(
|
||||
running: const TaskNotification('Downloading', 'file: {filename}'),
|
||||
complete: const TaskNotification('Download finished', 'file: {filename}'),
|
||||
paused: const TaskNotification('Download paused', 'file: {filename}'),
|
||||
progressBar: true,
|
||||
);
|
||||
}
|
||||
|
||||
void setMaxConcurrent(int value) {
|
||||
state.configure(
|
||||
globalConfig: value == 0
|
||||
? ("", "")
|
||||
: (
|
||||
Config.holdingQueue,
|
||||
(
|
||||
//maxConcurrent
|
||||
value,
|
||||
//maxConcurrentByHost
|
||||
value,
|
||||
//maxConcurrentByGroup
|
||||
value,
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue