perf: 会话顶部提示剩余未读消息

This commit is contained in:
kuaifan
2023-02-07 04:30:18 +08:00
parent daa88a2cc2
commit a0e84479f2
6 changed files with 119 additions and 10 deletions
@@ -457,6 +457,15 @@ class DialogController extends AbstractController
->where('web_socket_dialog_msgs.id', '<', $last->id)
->orderByDesc('web_socket_dialog_msgs.id')
->value('id'));
//
if (empty($position_id)) {
$unreadBuilder = WebSocketDialogMsgRead::whereDialogId($dialog_id)->whereUserid($user->userid)->whereReadAt(null)->where('msg_id', '<', $last->id);
$unread = $unreadBuilder->count();
$data['before'] = [
'unread' => $unread,
'first_id' => $unread > 0 ? intval($unreadBuilder->orderBy('msg_id')->value('msg_id')) : 0,
];
}
}
$data['list'] = $list;
$data['time'] = Base::time();