mirror of
https://github.com/open-webui/open-webui
synced 2025-03-23 06:17:24 +00:00
refac: sidebar tag add behaviour
This commit is contained in:
parent
4c7651c113
commit
d8a30bd6ae
@ -257,11 +257,15 @@ class ChatTable:
|
||||
query = db.query(Chat).filter_by(user_id=user_id)
|
||||
if not include_archived:
|
||||
query = query.filter_by(archived=False)
|
||||
all_chats = (
|
||||
query.order_by(Chat.updated_at.desc())
|
||||
# .limit(limit).offset(skip)
|
||||
.all()
|
||||
)
|
||||
|
||||
query = query.order_by(Chat.updated_at.desc())
|
||||
|
||||
if skip:
|
||||
query = query.offset(skip)
|
||||
if limit:
|
||||
query = query.limit(limit)
|
||||
|
||||
all_chats = query.all()
|
||||
return [ChatModel.model_validate(chat) for chat in all_chats]
|
||||
|
||||
def get_chat_title_id_list_by_user_id(
|
||||
@ -500,6 +504,8 @@ class ChatTable:
|
||||
# Perform pagination at the SQL level
|
||||
all_chats = query.offset(skip).limit(limit).all()
|
||||
|
||||
print(len(all_chats))
|
||||
|
||||
# Validate and return chats
|
||||
return [ChatModel.model_validate(chat) for chat in all_chats]
|
||||
|
||||
|
@ -37,7 +37,10 @@
|
||||
tags: tags
|
||||
});
|
||||
|
||||
_tags.set(await getAllChatTags(localStorage.token));
|
||||
await _tags.set(await getAllChatTags(localStorage.token));
|
||||
dispatch('add', {
|
||||
name: tagName
|
||||
});
|
||||
};
|
||||
|
||||
const deleteTag = async (tagName) => {
|
||||
|
@ -179,7 +179,10 @@
|
||||
console.log(type, tagName, chatId);
|
||||
if (type === 'delete') {
|
||||
currentChatPage.set(1);
|
||||
await chats.set(await getChatListBySearchText(localStorage.token, search));
|
||||
await chats.set(await getChatListBySearchText(localStorage.token, search, $currentChatPage));
|
||||
} else if (type === 'add') {
|
||||
currentChatPage.set(1);
|
||||
await chats.set(await getChatListBySearchText(localStorage.token, search, $currentChatPage));
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -141,6 +141,13 @@
|
||||
<div class="flex p-1">
|
||||
<Tags
|
||||
{chatId}
|
||||
on:add={(e) => {
|
||||
dispatch('tag', {
|
||||
type: 'add',
|
||||
name: e.detail.name
|
||||
});
|
||||
show = false;
|
||||
}}
|
||||
on:delete={(e) => {
|
||||
dispatch('tag', {
|
||||
type: 'delete',
|
||||
|
Loading…
Reference in New Issue
Block a user