Timothy J. Baek 7 tháng trước cách đây
mục cha
commit
78d6647885
1 tập tin đã thay đổi với 16 bổ sung4 xóa
  1. 16 4
      src/lib/components/layout/Sidebar/ChatItem.svelte

+ 16 - 4
src/lib/components/layout/Sidebar/ChatItem.svelte

@@ -14,7 +14,15 @@
 		getChatListByTagName,
 		updateChatById
 	} from '$lib/apis/chats';
-	import { chatId, chats, mobile, pinnedChats, showSidebar, currentChatPage } from '$lib/stores';
+	import {
+		chatId,
+		chatTitle as _chatTitle,
+		chats,
+		mobile,
+		pinnedChats,
+		showSidebar,
+		currentChatPage
+	} from '$lib/stores';
 
 	import ChatMenu from './ChatMenu.svelte';
 	import ShareChatModal from '$lib/components/chat/ShareChatModal.svelte';
@@ -33,14 +41,18 @@
 
 	let chatTitle = chat.title;
 
-	const editChatTitle = async (id, _title) => {
-		if (_title === '') {
+	const editChatTitle = async (id, title) => {
+		if (title === '') {
 			toast.error($i18n.t('Title cannot be an empty string.'));
 		} else {
 			await updateChatById(localStorage.token, id, {
-				title: _title
+				title: title
 			});
 
+			if (id === $chatId) {
+				_chatTitle.set(title);
+			}
+
 			currentChatPage.set(1);
 			await chats.set(await getChatList(localStorage.token, $currentChatPage));
 			await pinnedChats.set(await getChatListByTagName(localStorage.token, 'pinned'));