Skip to content
This repository has been archived by the owner on Jan 17, 2025. It is now read-only.

Commit

Permalink
opt: blackMidsList
Browse files Browse the repository at this point in the history
Signed-off-by: bggRGjQaUbCoE <[email protected]>
  • Loading branch information
bggRGjQaUbCoE committed Dec 2, 2024
1 parent cbdd8e7 commit 84ee106
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 24 deletions.
8 changes: 2 additions & 6 deletions lib/common/widgets/video_popup_menu.dart
Original file line number Diff line number Diff line change
Expand Up @@ -240,13 +240,9 @@ class VideoCustomActions {
act: 5,
reSrc: 11,
);
List<int> blackMidsList = GStorage.localCache
.get(LocalCacheKey.blackMidsList, defaultValue: [-1])
.map<int>((i) => i as int)
.toList();
List<int> blackMidsList = GStorage.blackMidsList;
blackMidsList.insert(0, videoItem.owner.mid);
GStorage.localCache
.put(LocalCacheKey.blackMidsList, blackMidsList);
GStorage.setBlackMidsList(blackMidsList);
Get.back();
SmartDialog.showToast(res['msg'] ?? '成功');
},
Expand Down
3 changes: 1 addition & 2 deletions lib/http/search.dart
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,7 @@ class SearchHttp {
try {
switch (searchType) {
case SearchType.video:
List<int> blackMidsList = localCache
.get(LocalCacheKey.blackMidsList, defaultValue: <int>[]);
List<int> blackMidsList = GStorage.blackMidsList;
if (res.data['data']['result'] != null) {
for (var i in res.data['data']['result']) {
// 屏蔽推广和拉黑用户
Expand Down
17 changes: 5 additions & 12 deletions lib/http/video.dart
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,7 @@ class VideoHttp {
);
if (res.data['code'] == 0) {
List<RecVideoItemModel> list = [];
List<int> blackMidsList =
localCache.get(LocalCacheKey.blackMidsList, defaultValue: <int>[]);
List<int> blackMidsList = GStorage.blackMidsList;
for (var i in res.data['data']['item']) {
//过滤掉live与ad,以及拉黑用户
if (i['goto'] == 'av' &&
Expand Down Expand Up @@ -140,8 +139,7 @@ class VideoHttp {
);
if (res.data['code'] == 0) {
List<RecVideoItemAppModel> list = [];
List<int> blackMidsList =
localCache.get(LocalCacheKey.blackMidsList, defaultValue: <int>[]);
List<int> blackMidsList = GStorage.blackMidsList;
for (var i in res.data['data']['items']) {
// 屏蔽推广和拉黑用户
if (i['card_goto'] != 'ad_av' &&
Expand Down Expand Up @@ -171,10 +169,7 @@ class VideoHttp {
);
if (res.data['code'] == 0) {
List<HotVideoItemModel> list = [];
List<int> blackMidsList = localCache
.get(LocalCacheKey.blackMidsList, defaultValue: [-1])
.map<int>((e) => e as int)
.toList();
List<int> blackMidsList = GStorage.blackMidsList;
for (var i in res.data['data']['list']) {
if (!blackMidsList.contains(i['owner']['mid'])) {
list.add(HotVideoItemModel.fromJson(i));
Expand All @@ -190,8 +185,7 @@ class VideoHttp {
dynamic res = await GrpcRepo.popular(idx);
if (res['status']) {
List<card.Card> list = [];
List<int> blackMidsList =
localCache.get(LocalCacheKey.blackMidsList, defaultValue: <int>[]);
List<int> blackMidsList = GStorage.blackMidsList;
for (card.Card item in res['data']) {
if (!blackMidsList.contains(item.smallCoverV5.up.id.toInt())) {
list.add(item);
Expand Down Expand Up @@ -977,8 +971,7 @@ class VideoHttp {
var res = await Request().get(rankApi);
if (res.data['code'] == 0) {
List<HotVideoItemModel> list = [];
List<int> blackMidsList =
localCache.get(LocalCacheKey.blackMidsList, defaultValue: <int>[]);
List<int> blackMidsList = GStorage.blackMidsList;
for (var i in res.data['data']['list']) {
if (!blackMidsList.contains(i['owner']['mid'])) {
list.add(HotVideoItemModel.fromJson(i));
Expand Down
10 changes: 6 additions & 4 deletions lib/pages/blacklist/index.dart
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ class _BlackListPageState extends State<BlackListPage> {
List list = _blackListController.loadingState.value is Success
? (_blackListController.loadingState.value as Success).response
: <int>[];
GStorage.localCache.put(LocalCacheKey.blackMidsList,
list.isNotEmpty ? list.map<int>((e) => e.mid!).toList() : list);
GStorage.setBlackMidsList(
list.isNotEmpty ? list.map<int>((e) => e.mid!).toList() : <int>[]);
super.dispose();
}

Expand Down Expand Up @@ -121,7 +121,8 @@ class BlackListController extends CommonController {
if (response.response.list.length >= total.value) {
isEnd = true;
}
loadingState.value = LoadingState.success(response.response.list);
loadingState.value = LoadingState.success(
response.response.list.isNotEmpty ? response.response.list : <int>[]);
return true;
}

Expand All @@ -131,7 +132,8 @@ class BlackListController extends CommonController {
List list = (loadingState.value as Success).response;
list.removeWhere((e) => e.mid == mid);
total.value = total.value - 1;
loadingState.value = LoadingState.success(list);
loadingState.value =
LoadingState.success(list.isNotEmpty ? list : <int>[]);
SmartDialog.showToast(result['msg']);
}
}
Expand Down
8 changes: 8 additions & 0 deletions lib/utils/storage.dart
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,14 @@ class GStorage {
static List<double> get dynamicDetailRatio =>
setting.get(SettingBoxKey.dynamicDetailRatio, defaultValue: [60.0, 40.0]);

static List<int> get blackMidsList => List<int>.from(GStorage.localCache
.get(LocalCacheKey.blackMidsList, defaultValue: <int>[]));

static void setBlackMidsList(blackMidsList) {
if (blackMidsList is! List<int>) return;
GStorage.localCache.put(LocalCacheKey.blackMidsList, blackMidsList);
}

static MemberTabType get memberTab => MemberTabType
.values[setting.get(SettingBoxKey.memberTab, defaultValue: 0)];

Expand Down

0 comments on commit 84ee106

Please sign in to comment.