perf: 优化未读消息提示

This commit is contained in:
kuaifan
2023-02-07 09:07:00 +08:00
parent 2ebb963342
commit 0f0da2ad27
5 changed files with 16 additions and 36 deletions

View File

@@ -457,15 +457,6 @@ 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();
@@ -1050,6 +1041,7 @@ class DialogController extends AbstractController
switch ($type) {
case 'read':
$data['unread'] = 0;
$data['first_umid'] = 0;
WebSocketDialogMsgRead::whereUserid($user->userid)
->whereReadAt(null)
->whereDialogId($dialogId)