feat: 未读消息计数

This commit is contained in:
guozhigq
2024-06-15 20:34:28 +08:00
parent f62eae55d2
commit 86023e46a6
4 changed files with 194 additions and 135 deletions

View File

@ -1,3 +1,4 @@
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:pilipala/http/msg.dart';
import 'package:pilipala/models/msg/account.dart';
@ -7,6 +8,38 @@ class WhisperController extends GetxController {
RxList<SessionList> sessionList = <SessionList>[].obs;
RxList<AccountListModel> accountList = <AccountListModel>[].obs;
bool isLoading = false;
RxList noticesList = [
{
'icon': Icons.message_outlined,
'title': '回复我的',
'path': '',
'count': 0,
},
{
'icon': Icons.alternate_email,
'title': '@ 我的',
'path': '',
'count': 0,
},
{
'icon': Icons.thumb_up_outlined,
'title': '收到的赞',
'path': '',
'count': 0,
},
{
'icon': Icons.notifications_none_outlined,
'title': '系统通知',
'path': '',
'count': 0,
}
].obs;
@override
void onInit() {
unread();
super.onInit();
}
Future querySessionList(String? type) async {
if (isLoading) return;
@ -77,4 +110,16 @@ class WhisperController extends GetxController {
sessionList.removeWhere((p0) => p0.talkerId == talkerId);
sessionList.refresh();
}
// 消息未读数
void unread() async {
var res = await MsgHttp.unread();
if (res['status']) {
noticesList[0]['count'] = res['data']['reply'];
noticesList[1]['count'] = res['data']['at'];
noticesList[2]['count'] = res['data']['like'];
noticesList[3]['count'] = res['data']['sys_msg'];
noticesList.refresh();
}
}
}