mirror of
https://github.com/simon-ding/polaris.git
synced 2026-02-06 23:21:00 +08:00
feat: refresh page date after download
This commit is contained in:
@@ -7,7 +7,9 @@ import 'package:ui/providers/server_response.dart';
|
||||
var activitiesDataProvider = AsyncNotifierProvider.autoDispose
|
||||
.family<ActivityData, List<Activity>, ActivityStatus>(ActivityData.new);
|
||||
|
||||
var blacklistDataProvider = AsyncNotifierProvider.autoDispose<BlacklistData,List<Blacklist>>(BlacklistData.new);
|
||||
var blacklistDataProvider =
|
||||
AsyncNotifierProvider.autoDispose<BlacklistData, List<Blacklist>>(
|
||||
BlacklistData.new);
|
||||
|
||||
var mediaHistoryDataProvider = FutureProvider.autoDispose.family(
|
||||
(ref, arg) async {
|
||||
@@ -84,7 +86,6 @@ class ActivityData
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
class Activity {
|
||||
Activity(
|
||||
{required this.id,
|
||||
@@ -123,22 +124,21 @@ class Activity {
|
||||
targetDir: json["target_dir"],
|
||||
status: json["status"],
|
||||
saved: json["saved"],
|
||||
progress: json["progress"]??0,
|
||||
seedRatio: json["seed_ratio"]??0,
|
||||
size: json["size"]??0,
|
||||
uploadProgress: json["upload_progress"]??0);
|
||||
progress: json["progress"] ?? 0,
|
||||
seedRatio: json["seed_ratio"] ?? 0,
|
||||
size: json["size"] ?? 0,
|
||||
uploadProgress: json["upload_progress"] ?? 0);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
class BlacklistData extends AutoDisposeAsyncNotifier<List<Blacklist>> {
|
||||
@override
|
||||
FutureOr<List<Blacklist>> build() async {
|
||||
final dio = APIs.getDio();
|
||||
var resp = await dio.get(APIs.blacklistUrl);
|
||||
final sp = ServerResponse.fromJson(resp.data);
|
||||
if (sp.code!= 0) {
|
||||
throw sp.message;
|
||||
final sp = ServerResponse.fromJson(resp.data);
|
||||
if (sp.code != 0) {
|
||||
throw sp.message;
|
||||
}
|
||||
List<Blacklist> blaclklists = List.empty(growable: true);
|
||||
for (final a in sp.data as List) {
|
||||
@@ -151,7 +151,7 @@ class BlacklistData extends AutoDisposeAsyncNotifier<List<Blacklist>> {
|
||||
final dio = APIs.getDio();
|
||||
var resp = await dio.delete("${APIs.blacklistUrl}/$id");
|
||||
final sp = ServerResponse.fromJson(resp.data);
|
||||
if (sp.code!= 0) {
|
||||
if (sp.code != 0) {
|
||||
throw sp.message;
|
||||
}
|
||||
}
|
||||
@@ -192,4 +192,4 @@ class Blacklist {
|
||||
data['create_time'] = this.createTime;
|
||||
return data;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,9 +24,10 @@ class SeriesDetailData
|
||||
return SeriesDetails.fromJson(rsp.data);
|
||||
}
|
||||
|
||||
Future<void> delete(bool removeFiles ) async {
|
||||
Future<void> delete(bool removeFiles) async {
|
||||
final dio = APIs.getDio();
|
||||
var resp = await dio.delete("${APIs.seriesDetailUrl}$id", queryParameters: {"delete_files": removeFiles});
|
||||
var resp = await dio.delete("${APIs.seriesDetailUrl}$id",
|
||||
queryParameters: {"delete_files": removeFiles});
|
||||
var rsp = ServerResponse.fromJson(resp.data);
|
||||
if (rsp.code != 0) {
|
||||
throw rsp.message;
|
||||
@@ -256,6 +257,7 @@ class MediaTorrentResource extends AutoDisposeFamilyAsyncNotifier<
|
||||
if (rsp.code != 0) {
|
||||
throw rsp.message;
|
||||
}
|
||||
ref.invalidate(mediaDetailsProvider(arg.mediaId));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user