opt: type & grpc message (#842)

* opt: grpc type

* opt: grpc message

* opt: http type
This commit is contained in:
My-Responsitories
2025-05-10 12:40:27 +08:00
committed by GitHub
parent 7b4f08bb05
commit 024e74115e
21 changed files with 556 additions and 246 deletions

View File

@@ -26,7 +26,7 @@ abstract class CommonWhisperController<R>
? await ImGrpc.unpinSession(sessionId: sessionId)
: await ImGrpc.pinSession(sessionId: sessionId);
if (res['status']) {
if (res.isSuccess) {
List<Session> list = loadingState.value.data!;
list[index].isPinned = isTop ? false : true;
if (!isTop) {
@@ -35,14 +35,14 @@ abstract class CommonWhisperController<R>
loadingState.refresh();
SmartDialog.showToast('${isTop ? '移除' : ''}置顶成功');
} else {
SmartDialog.showToast(res['msg']);
res.toast();
}
}
Future<void> onClearUnread() async {
final res = await ImGrpc.clearUnread(pageType: sessionPageType);
if (res['status']) {
if (loadingState.value is Success) {
if (res.isSuccess) {
if (loadingState.value.isSuccess) {
List<Session>? list = loadingState.value.data;
if (list?.isNotEmpty == true) {
for (var item in list!) {
@@ -55,16 +55,16 @@ abstract class CommonWhisperController<R>
}
SmartDialog.showToast('已标记为已读');
} else {
SmartDialog.showToast(res['msg']);
res.toast();
}
}
Future<void> onDeleteList() async {
var res = await ImGrpc.deleteSessionList(pageType: sessionPageType);
if (res['status']) {
if (res.isSuccess) {
loadingState.value = LoadingState.success(null);
} else {
SmartDialog.showToast(res['msg']);
res.toast();
}
}
}

View File

@@ -176,8 +176,8 @@ class MainController extends GetxController {
return;
}
DynGrpc.dynRed().then((res) {
if (res['status']) {
setCount(res['data']);
if (res != null) {
setCount(res);
}
});
}

View File

@@ -30,8 +30,8 @@ class WhisperBlockController extends CommonListController<
ImGrpc.keywordBlockingList();
Future<void> onAdd(String keyword) async {
var res = await ImGrpc.keywordBlockingAdd(keyword);
if (res['status']) {
final res = await ImGrpc.keywordBlockingAdd(keyword);
if (res.isSuccess) {
Get.back();
loadingState
..value.data!.add(KeywordBlockingItem(keyword: keyword))
@@ -39,20 +39,20 @@ class WhisperBlockController extends CommonListController<
count.value += 1;
SmartDialog.showToast('添加成功');
} else {
SmartDialog.showToast(res['msg']);
res.toast();
}
}
Future<void> onRemove(KeywordBlockingItem item) async {
var res = await ImGrpc.keywordBlockingDelete(item.keyword);
if (res['status']) {
final res = await ImGrpc.keywordBlockingDelete(item.keyword);
if (res.isSuccess) {
loadingState
..value.data!.remove(item)
..refresh();
count.value -= 1;
SmartDialog.showToast('删除成功');
} else {
SmartDialog.showToast(res['msg']);
res.toast();
}
}
}

View File

@@ -3,7 +3,6 @@ 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_data_controller.dart';
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
import 'package:get/get.dart';
import 'package:protobuf/protobuf.dart' show PbMap;
@@ -36,10 +35,10 @@ class WhisperSettingsController
ImGrpc.getImSettings(type: imSettingType);
Future<bool> onSet(PbMap<int, Setting> settings) async {
var res = await ImGrpc.setImSettings(settings: settings);
if (!res['status']) {
SmartDialog.showToast('err: ${res['msg']}');
final res = await ImGrpc.setImSettings(settings: settings);
if (!res.isSuccess) {
res.toast();
}
return res['status'];
return res.isSuccess;
}
}