opt: unread & zan grpc & readlist open with browser (#852)

* opt: unread

* opt: zan grpc

* feat: readlist open with browser
This commit is contained in:
My-Responsitories
2025-05-11 18:58:00 +08:00
committed by GitHub
parent 8d34e6f340
commit 72734d4b4e
13 changed files with 127 additions and 208 deletions

View File

@@ -2,12 +2,11 @@ import 'package:PiliPlus/grpc/bilibili/app/im/v1.pb.dart'
show Offset, Session, SessionMainReply, SessionPageType, ThreeDotItem;
import 'package:PiliPlus/grpc/im.dart';
import 'package:PiliPlus/http/loading_state.dart';
import 'package:PiliPlus/http/msg.dart';
import 'package:PiliPlus/models/msg/msgfeed_unread.dart';
import 'package:PiliPlus/pages/common/common_whisper_controller.dart';
import 'package:PiliPlus/utils/storage.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
import 'package:get/get.dart';
import 'package:protobuf/protobuf.dart' show PbMap;
@@ -15,7 +14,8 @@ class WhisperController extends CommonWhisperController<SessionMainReply> {
@override
SessionPageType sessionPageType = SessionPageType.SESSION_PAGE_TYPE_HOME;
late final List msgFeedTopItems;
late final List<({bool enabled, IconData icon, String name, String route})>
msgFeedTopItems;
late final RxList<int> unreadCounts;
PbMap<int, Offset>? offset;
@@ -29,44 +29,46 @@ class WhisperController extends CommonWhisperController<SessionMainReply> {
final disableLikeMsg =
GStorage.setting.get(SettingBoxKey.disableLikeMsg, defaultValue: false);
msgFeedTopItems = [
{
"name": "回复我的",
"icon": Icons.message_outlined,
"route": "/replyMe",
"enabled": true,
},
{
"name": "@我",
"icon": Icons.alternate_email_outlined,
"route": "/atMe",
"enabled": true,
},
{
"name": "收到的赞",
"icon": Icons.favorite_border_outlined,
"route": "/likeMe",
"enabled": !disableLikeMsg,
},
{
"name": "系统通知",
"icon": Icons.notifications_none_outlined,
"route": "/sysMsg",
"enabled": true,
},
const (
name: "回复我的",
icon: Icons.message_outlined,
route: "/replyMe",
enabled: true,
),
const (
name: "@我",
icon: Icons.alternate_email_outlined,
route: "/atMe",
enabled: true,
),
(
name: "收到的赞",
icon: Icons.favorite_border_outlined,
route: "/likeMe",
enabled: !disableLikeMsg,
),
const (
name: "系统通知",
icon: Icons.notifications_none_outlined,
route: "/sysMsg",
enabled: true,
),
];
unreadCounts =
List.generate(msgFeedTopItems.length, (index) => 0).toList().obs;
unreadCounts = List.filled(msgFeedTopItems.length, 0).obs;
queryMsgFeedUnread();
queryData();
}
Future<void> queryMsgFeedUnread() async {
var res = await MsgHttp.msgFeedUnread();
if (res['status']) {
final data = MsgFeedUnread.fromJson(res['data']);
unreadCounts.value = [data.reply, data.at, data.like, data.sysMsg];
var res = await ImGrpc.getTotalUnread(unreadType: 2);
if (res.isSuccess) {
final data = MsgFeedUnread.fromJson(res.data.msgFeedUnread.unread);
final unreadCounts = [data.reply, data.at, data.like, data.sysMsg];
if (!listEquals(this.unreadCounts, unreadCounts)) {
this.unreadCounts.value = unreadCounts;
}
} else {
SmartDialog.showToast(res['msg']);
res.toast();
}
}