feat: 消息未读标记
This commit is contained in:
@ -489,4 +489,8 @@ class Api {
|
|||||||
|
|
||||||
/// 我的订阅详情
|
/// 我的订阅详情
|
||||||
static const userSubFolderDetail = '/x/space/fav/season/list';
|
static const userSubFolderDetail = '/x/space/fav/season/list';
|
||||||
|
|
||||||
|
/// 已读标记
|
||||||
|
static const String ackSessionMsg =
|
||||||
|
'${HttpString.tUrl}/session_svr/v1/session_svr/update_ack';
|
||||||
}
|
}
|
||||||
|
|||||||
@ -86,4 +86,36 @@ class MsgHttp {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 消息标记已读
|
||||||
|
static Future ackSessionMsg({
|
||||||
|
int? talkerId,
|
||||||
|
int? ackSeqno,
|
||||||
|
}) async {
|
||||||
|
String csrf = await Request.getCsrf();
|
||||||
|
Map params = await WbiSign().makSign({
|
||||||
|
'talker_id': talkerId,
|
||||||
|
'session_type': 1,
|
||||||
|
'ack_seqno': ackSeqno,
|
||||||
|
'build': 0,
|
||||||
|
'mobi_app': 'web',
|
||||||
|
'csrf_token': csrf,
|
||||||
|
'csrf': csrf
|
||||||
|
});
|
||||||
|
var res = await Request().get(Api.ackSessionMsg, data: params);
|
||||||
|
if (res.data['code'] == 0) {
|
||||||
|
return {
|
||||||
|
'status': true,
|
||||||
|
'data': res.data['data'],
|
||||||
|
};
|
||||||
|
} else {
|
||||||
|
return {
|
||||||
|
'status': false,
|
||||||
|
'date': [],
|
||||||
|
'msg': "message: ${res.data['message']},"
|
||||||
|
" msg: ${res.data['msg']},"
|
||||||
|
" code: ${res.data['code']}",
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -110,7 +110,7 @@ class _WhisperPageState extends State<WhisperPage> {
|
|||||||
if (snapshot.connectionState == ConnectionState.done) {
|
if (snapshot.connectionState == ConnectionState.done) {
|
||||||
Map data = snapshot.data as Map;
|
Map data = snapshot.data as Map;
|
||||||
if (data['status']) {
|
if (data['status']) {
|
||||||
List sessionList = _whisperController.sessionList;
|
RxList sessionList = _whisperController.sessionList;
|
||||||
return Obx(
|
return Obx(
|
||||||
() => sessionList.isEmpty
|
() => sessionList.isEmpty
|
||||||
? const SizedBox()
|
? const SizedBox()
|
||||||
@ -121,7 +121,10 @@ class _WhisperPageState extends State<WhisperPage> {
|
|||||||
const NeverScrollableScrollPhysics(),
|
const NeverScrollableScrollPhysics(),
|
||||||
itemBuilder: (_, int i) {
|
itemBuilder: (_, int i) {
|
||||||
return ListTile(
|
return ListTile(
|
||||||
onTap: () => Get.toNamed(
|
onTap: () {
|
||||||
|
sessionList[i].unreadCount = 0;
|
||||||
|
sessionList.refresh();
|
||||||
|
Get.toNamed(
|
||||||
'/whisperDetail',
|
'/whisperDetail',
|
||||||
parameters: {
|
parameters: {
|
||||||
'talkerId': sessionList[i]
|
'talkerId': sessionList[i]
|
||||||
@ -138,16 +141,15 @@ class _WhisperPageState extends State<WhisperPage> {
|
|||||||
.mid
|
.mid
|
||||||
.toString(),
|
.toString(),
|
||||||
},
|
},
|
||||||
),
|
);
|
||||||
|
},
|
||||||
leading: Badge(
|
leading: Badge(
|
||||||
isLabelVisible: false,
|
isLabelVisible:
|
||||||
backgroundColor: Theme.of(context)
|
sessionList[i].unreadCount > 0,
|
||||||
.colorScheme
|
|
||||||
.primary,
|
|
||||||
label: Text(sessionList[i]
|
label: Text(sessionList[i]
|
||||||
.unreadCount
|
.unreadCount
|
||||||
.toString()),
|
.toString()),
|
||||||
alignment: Alignment.bottomRight,
|
alignment: Alignment.topRight,
|
||||||
child: NetworkImgLayer(
|
child: NetworkImgLayer(
|
||||||
width: 45,
|
width: 45,
|
||||||
height: 45,
|
height: 45,
|
||||||
|
|||||||
@ -25,10 +25,31 @@ class WhisperDetailController extends GetxController {
|
|||||||
var res = await MsgHttp.sessionMsg(talkerId: talkerId);
|
var res = await MsgHttp.sessionMsg(talkerId: talkerId);
|
||||||
if (res['status']) {
|
if (res['status']) {
|
||||||
messageList.value = res['data'].messages;
|
messageList.value = res['data'].messages;
|
||||||
if (messageList.isNotEmpty && res['data'].eInfos != null) {
|
if (messageList.isNotEmpty) {
|
||||||
|
ackSessionMsg();
|
||||||
|
if (res['data'].eInfos != null) {
|
||||||
eInfos = res['data'].eInfos;
|
eInfos = res['data'].eInfos;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
SmartDialog.showToast(res['msg']);
|
||||||
|
}
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 消息标记已读
|
||||||
|
Future ackSessionMsg() async {
|
||||||
|
if (messageList.isEmpty) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
var res = await MsgHttp.ackSessionMsg(
|
||||||
|
talkerId: talkerId,
|
||||||
|
ackSeqno: messageList.last.msgSeqno,
|
||||||
|
);
|
||||||
|
if (res['status']) {
|
||||||
|
SmartDialog.showToast("已读成功");
|
||||||
|
} else {
|
||||||
|
SmartDialog.showToast(res['msg']);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user