From d43a9b7b743bc27b2a8740e97f55a1f352ac00c0 Mon Sep 17 00:00:00 2001
From: wujingjing <gersonwu@qq.com>
Date: 星期五, 03 一月 2025 10:53:21 +0800
Subject: [PATCH] updateInputValue bug

---
 src/stores/chatRoom.ts |   63 +++++++++++++++++--------------
 1 files changed, 35 insertions(+), 28 deletions(-)

diff --git a/src/stores/chatRoom.ts b/src/stores/chatRoom.ts
index 67af8b5..21b2af3 100644
--- a/src/stores/chatRoom.ts
+++ b/src/stores/chatRoom.ts
@@ -197,37 +197,44 @@
 	},
 };
 
+let getHistoryChatRoomsPromise: Promise<any>;
 //鍘嗗彶瀵硅瘽
-const getHistoryChatRooms = () => {
-	return new Promise((resolve, reject) => {
-		GetHistoryGroups()
-			.then((res) => {
-				const resData = (res?.groups || []) as any[];
-				chatRoomList.value = resData
-					.toSorted((a, b) => b.create_time.localeCompare(a.create_time))
-					.map((item) => ({
-						id: item.group_id,
-						title: item.group_title,
-						createTime: item.create_time,
-						isInitial: Number(item.chat_count) === 0,
-					}));
-
-				if (!chatRoomList.value || chatRoomList.value.length === 0) {
-					newChatRoomClick();
-				} else {
-					const toClickRoom = activeChatRoom.value ?? chatRoomList.value[0];
-					activeRoomId.value = toClickRoom.id;
-					gotoAnswerPage(toClickRoom);
-				}
+const getHistoryChatRooms = async () => {
+	getHistoryChatRoomsPromise = new Promise(async (resolve, reject) => {
+		if (isSharePage.value) return resolve(null);
+		const res = await GetHistoryGroups();
+		const resData = (res?.groups || []) as any[];
+		// 鎸夋渶鏅氭椂闂村埌鏈�鏃╂椂闂�
+		chatRoomList.value = resData
+			?.toSorted((a, b) => {
+				return b.create_time.localeCompare(a.create_time);
 			})
-			.then(() => {
-				resolve(true);
-			})
-			.catch((error) => {
-				reject(error);
+			.map((item) => {
+				return {
+					id: item.group_id,
+					title: item.group_title,
+					createTime: item.create_time,
+					isInitial: Number(item.chat_count) === 0,
+				};
 			});
-	}).catch((error) => {
-		reject(error);
+
+		resolve(chatRoomList.value);
 	});
 };
 
+const roomClick = (room: ChatRoomItem) => {
+	activeRoomId.value = room.id;
+
+	gotoAnswerPage(room);
+};
+
+export const selectFirstRoom = () => {
+	getHistoryChatRoomsPromise.then(() => {
+		if (!chatRoomList.value || chatRoomList.value.length === 0) {
+			newChatRoomClick();
+		} else {
+			const toClickRoom = activeChatRoom.value ?? chatRoomList.value[0];
+			roomClick(toClickRoom);
+		}
+	});
+};

--
Gitblit v1.9.3