mirror of
https://github.com/simon-ding/polaris.git
synced 2026-06-08 02:57:38 +08:00
feat: option to download all episodes
This commit is contained in:
@@ -84,14 +84,15 @@ class SearchPageData
|
||||
}
|
||||
|
||||
Future<void> submit2Watchlist(int tmdbId, int storageId, String resolution,
|
||||
String mediaType, String folder) async {
|
||||
String mediaType, String folder, bool downloadHistoryEpisodes) async {
|
||||
final dio = await APIs.getDio();
|
||||
if (mediaType == "tv") {
|
||||
var resp = await dio.post(APIs.watchlistTvUrl, data: {
|
||||
"tmdb_id": tmdbId,
|
||||
"storage_id": storageId,
|
||||
"resolution": resolution,
|
||||
"folder": folder
|
||||
"folder": folder,
|
||||
"download_history_episodes":downloadHistoryEpisodes
|
||||
});
|
||||
var sp = ServerResponse.fromJson(resp.data);
|
||||
if (sp.code != 0) {
|
||||
|
||||
@@ -146,6 +146,8 @@ class _SearchPageState extends ConsumerState<SearchPage> {
|
||||
int storageSelected = 0;
|
||||
var storage = ref.watch(storageSettingProvider);
|
||||
var name = ref.watch(suggestNameDataProvider(item.id!));
|
||||
bool downloadHistoryEpisodes = false;
|
||||
bool buttonTapped = false;
|
||||
|
||||
var pathController = TextEditingController();
|
||||
return AlertDialog(
|
||||
@@ -230,6 +232,19 @@ class _SearchPageState extends ConsumerState<SearchPage> {
|
||||
),
|
||||
)
|
||||
: Text(""),
|
||||
item.mediaType == "tv"
|
||||
? SizedBox(
|
||||
width: 250,
|
||||
child: CheckboxListTile(
|
||||
title: const Text("是否下载往期剧集"),
|
||||
value: downloadHistoryEpisodes,
|
||||
onChanged: (v) {
|
||||
setState(() {
|
||||
downloadHistoryEpisodes = v!;
|
||||
});
|
||||
}),
|
||||
)
|
||||
: const SizedBox(),
|
||||
],
|
||||
);
|
||||
});
|
||||
@@ -254,18 +269,33 @@ class _SearchPageState extends ConsumerState<SearchPage> {
|
||||
textStyle: Theme.of(context).textTheme.labelLarge,
|
||||
),
|
||||
child: const Text('确定'),
|
||||
onPressed: () {
|
||||
ref
|
||||
onPressed: () async {
|
||||
if (buttonTapped) {
|
||||
return;
|
||||
}
|
||||
setState(() {
|
||||
buttonTapped = true;
|
||||
});
|
||||
|
||||
await ref
|
||||
.read(searchPageDataProvider(widget.query ?? "")
|
||||
.notifier)
|
||||
.submit2Watchlist(item.id!, storageSelected,
|
||||
resSelected, item.mediaType!, pathController.text)
|
||||
.submit2Watchlist(
|
||||
item.id!,
|
||||
storageSelected,
|
||||
resSelected,
|
||||
item.mediaType!,
|
||||
pathController.text,
|
||||
downloadHistoryEpisodes)
|
||||
.then((v) {
|
||||
Utils.showSnakeBar("添加成功");
|
||||
Navigator.of(context).pop();
|
||||
}).onError((error, trace) {
|
||||
Utils.showSnakeBar("添加失败:$error");
|
||||
});
|
||||
setState(() {
|
||||
buttonTapped = false;
|
||||
});
|
||||
},
|
||||
),
|
||||
],
|
||||
|
||||
Reference in New Issue
Block a user