From 1400bd80dd138b0c3d33bda2926cd1ac4f590baf Mon Sep 17 00:00:00 2001 From: YunaiV Date: Mon, 4 May 2026 23:06:12 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20fix(im)=EF=BC=9AloadFriendReques?= =?UTF-8?q?t=20=E6=8C=89=20id=20=E5=A4=A7=E5=B0=8F=E5=86=B3=E5=AE=9A?= =?UTF-8?q?=E6=8F=92=E5=85=A5=E4=BD=8D=E7=BD=AE=EF=BC=8C=E8=80=81=20id=20?= =?UTF-8?q?=E4=B8=8D=E5=85=A5=E9=81=BF=E5=85=8D=E7=A0=B4=E5=9D=8F=E5=80=92?= =?UTF-8?q?=E5=BA=8F=20+=20loadMore=20=E9=87=8D=E5=A4=8D=20push?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/im/home/store/friendStore.ts | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/views/im/home/store/friendStore.ts b/src/views/im/home/store/friendStore.ts index f44676c18..2b1393089 100644 --- a/src/views/im/home/store/friendStore.ts +++ b/src/views/im/home/store/friendStore.ts @@ -272,8 +272,19 @@ export const useFriendStore = defineStore('imFriendStore', { const existing = this.findFriendRequest(requestId) if (existing) { Object.assign(existing, next) + return + } + // 比本地最旧 id 还老:不入列表,让 loadMore 自然带回,避免破坏 id 倒序 / 后续 loadMore 重复 push + const oldest = this.friendRequests[this.friendRequests.length - 1] + if (oldest && requestId < oldest.id) { + return + } + // 按 id 倒序找首个比自己小的位置插入;找不到则追加末尾 + const insertIndex = this.friendRequests.findIndex((request) => request.id < requestId) + if (insertIndex < 0) { + this.friendRequests.push(next) } else { - this.friendRequests.unshift(next) + this.friendRequests.splice(insertIndex, 0, next) } },