Skip to content

Commit

Permalink
perf: 优化消息阅读逻辑
Browse files Browse the repository at this point in the history
  • Loading branch information
kuaifan committed Dec 15, 2023
1 parent fa7b049 commit d12fb47
Show file tree
Hide file tree
Showing 8 changed files with 217 additions and 201 deletions.
14 changes: 8 additions & 6 deletions app/Models/WebSocketDialog.php
Original file line number Diff line number Diff line change
Expand Up @@ -214,12 +214,14 @@ public function generateUnread($userid, $positionData = false)
if ($positionData) {
$array = [];
// @我的消息
if ($this->mention > 0
&& $mention_id = intval($builder->clone()->whereMention(1)->orderByDesc('msg_id')->value('msg_id'))) {
$array[] = [
'msg_id' => $mention_id,
'label' => Doo::translate('@我的消息'),
];
if ($this->mention > 0) {
$list = $builder->clone()->whereMention(1)->orderByDesc('msg_id')->take(20)->get();
foreach ($list as $item) {
$array[] = [
'msg_id' => $item->msg_id,
'label' => Doo::translate('@我的消息'),
];
}
}
// 最早一条未读消息
if ($this->unread > 0
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@
"vue-resize-observer": "^2.0.16",
"vue-router": "^3.6.5",
"vue-template-compiler": "~2.6.14",
"vue-virtual-scroll-list-hi": "^2.3.5-3",
"vue-virtual-scroll-list-hi": "^2.3.5-5",
"vuedraggable": "^2.24.3",
"vuex": "^3.6.2"
},
Expand Down
Loading

0 comments on commit d12fb47

Please sign in to comment.