mirror of
https://github.com/open-webui/open-webui
synced 2024-11-25 13:29:53 +00:00
fix: shared chat not updating
This commit is contained in:
parent
bca9c71ed6
commit
dc8c85c33d
@ -203,15 +203,22 @@ class ChatTable:
|
|||||||
def update_shared_chat_by_chat_id(self, chat_id: str) -> Optional[ChatModel]:
|
def update_shared_chat_by_chat_id(self, chat_id: str) -> Optional[ChatModel]:
|
||||||
try:
|
try:
|
||||||
with get_db() as db:
|
with get_db() as db:
|
||||||
print("update_shared_chat_by_id")
|
|
||||||
chat = db.get(Chat, chat_id)
|
chat = db.get(Chat, chat_id)
|
||||||
print(chat)
|
shared_chat = (
|
||||||
chat.title = chat.title
|
db.query(Chat).filter_by(user_id=f"shared-{chat_id}").first()
|
||||||
chat.chat = chat.chat
|
)
|
||||||
db.commit()
|
|
||||||
db.refresh(chat)
|
|
||||||
|
|
||||||
return self.get_chat_by_id(chat.share_id)
|
if shared_chat is None:
|
||||||
|
return self.insert_shared_chat_by_chat_id(chat_id)
|
||||||
|
|
||||||
|
shared_chat.title = chat.title
|
||||||
|
shared_chat.chat = chat.chat
|
||||||
|
|
||||||
|
shared_chat.updated_at = int(time.time())
|
||||||
|
db.commit()
|
||||||
|
db.refresh(shared_chat)
|
||||||
|
|
||||||
|
return ChatModel.model_validate(shared_chat)
|
||||||
except Exception:
|
except Exception:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
@ -80,7 +80,7 @@
|
|||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<Modal bind:show size="sm">
|
<Modal bind:show size="md">
|
||||||
<div>
|
<div>
|
||||||
<div class=" flex justify-between dark:text-gray-300 px-5 pt-4 pb-0.5">
|
<div class=" flex justify-between dark:text-gray-300 px-5 pt-4 pb-0.5">
|
||||||
<div class=" text-lg font-medium self-center">{$i18n.t('Share Chat')}</div>
|
<div class=" text-lg font-medium self-center">{$i18n.t('Share Chat')}</div>
|
||||||
|
@ -20,7 +20,7 @@
|
|||||||
} else if (size === 'sm') {
|
} else if (size === 'sm') {
|
||||||
return 'w-[30rem]';
|
return 'w-[30rem]';
|
||||||
} else if (size === 'md') {
|
} else if (size === 'md') {
|
||||||
return 'w-[48rem]';
|
return 'w-[42rem]';
|
||||||
} else {
|
} else {
|
||||||
return 'w-[56rem]';
|
return 'w-[56rem]';
|
||||||
}
|
}
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
import dayjs from 'dayjs';
|
import dayjs from 'dayjs';
|
||||||
|
|
||||||
import { settings, chatId, WEBUI_NAME, models } from '$lib/stores';
|
import { settings, chatId, WEBUI_NAME, models } from '$lib/stores';
|
||||||
import { convertMessagesToHistory } from '$lib/utils';
|
import { convertMessagesToHistory, createMessagesList } from '$lib/utils';
|
||||||
|
|
||||||
import { getChatByShareId } from '$lib/apis/chats';
|
import { getChatByShareId } from '$lib/apis/chats';
|
||||||
|
|
||||||
@ -40,19 +40,7 @@
|
|||||||
currentId: null
|
currentId: null
|
||||||
};
|
};
|
||||||
|
|
||||||
$: if (history.currentId !== null) {
|
$: messages = createMessagesList(history, history.currentId);
|
||||||
let _messages = [];
|
|
||||||
|
|
||||||
let currentMessage = history.messages[history.currentId];
|
|
||||||
while (currentMessage !== null) {
|
|
||||||
_messages.unshift({ ...currentMessage });
|
|
||||||
currentMessage =
|
|
||||||
currentMessage.parentId !== null ? history.messages[currentMessage.parentId] : null;
|
|
||||||
}
|
|
||||||
messages = _messages;
|
|
||||||
} else {
|
|
||||||
messages = [];
|
|
||||||
}
|
|
||||||
|
|
||||||
$: if ($page.params.id) {
|
$: if ($page.params.id) {
|
||||||
(async () => {
|
(async () => {
|
||||||
@ -138,7 +126,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<hr class=" dark:border-gray-800 mt-6 mb-2" />
|
<hr class="border-gray-50 dark:border-gray-850 mt-6 mb-2" />
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class=" flex flex-col w-full flex-auto overflow-auto h-0" id="messages-container">
|
<div class=" flex flex-col w-full flex-auto overflow-auto h-0" id="messages-container">
|
||||||
|
Loading…
Reference in New Issue
Block a user