mirror of
https://github.com/HChaZZY/PiliPlus.git
synced 2025-12-22 10:06:23 +08:00
feat: im settings
Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me>
This commit is contained in:
58
lib/pages/whisper_block/controller.dart
Normal file
58
lib/pages/whisper_block/controller.dart
Normal file
@@ -0,0 +1,58 @@
|
||||
import 'package:PiliPlus/grpc/bilibili/app/im/v1.pb.dart';
|
||||
import 'package:PiliPlus/grpc/im.dart';
|
||||
import 'package:PiliPlus/http/loading_state.dart';
|
||||
import 'package:PiliPlus/pages/common/common_list_controller.dart';
|
||||
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
|
||||
import 'package:get/get.dart';
|
||||
|
||||
class WhisperBlockController extends CommonListController<
|
||||
KeywordBlockingListReply, KeywordBlockingItem> {
|
||||
@override
|
||||
void onInit() {
|
||||
super.onInit();
|
||||
queryData();
|
||||
}
|
||||
|
||||
RxInt count = 0.obs;
|
||||
int? listLimit;
|
||||
int? charLimit;
|
||||
|
||||
@override
|
||||
List<KeywordBlockingItem>? getDataList(KeywordBlockingListReply response) {
|
||||
count.value = response.items.length;
|
||||
listLimit = response.listLimit;
|
||||
charLimit = response.charLimit;
|
||||
return response.items;
|
||||
}
|
||||
|
||||
@override
|
||||
Future<LoadingState<KeywordBlockingListReply>> customGetData() =>
|
||||
ImGrpc.keywordBlockingList();
|
||||
|
||||
Future<void> onAdd(String keyword) async {
|
||||
var res = await ImGrpc.keywordBlockingAdd(keyword);
|
||||
if (res['status']) {
|
||||
Get.back();
|
||||
loadingState
|
||||
..value.data!.add(KeywordBlockingItem(keyword: keyword))
|
||||
..refresh();
|
||||
count.value += 1;
|
||||
SmartDialog.showToast('添加成功');
|
||||
} else {
|
||||
SmartDialog.showToast(res['msg']);
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> onRemove(KeywordBlockingItem item) async {
|
||||
var res = await ImGrpc.keywordBlockingDelete(item.keyword);
|
||||
if (res['status']) {
|
||||
loadingState
|
||||
..value.data!.remove(item)
|
||||
..refresh();
|
||||
count.value -= 1;
|
||||
SmartDialog.showToast('删除成功');
|
||||
} else {
|
||||
SmartDialog.showToast(res['msg']);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user