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