mirror of
https://github.com/open-webui/open-webui.git
synced 2025-12-13 04:45:19 +00:00
fix: pinned chats in ref chat
This commit is contained in:
parent
9971919ca1
commit
5fe56a862b
4 changed files with 16 additions and 4 deletions
|
|
@ -502,6 +502,7 @@ class ChatTable:
|
||||||
user_id: str,
|
user_id: str,
|
||||||
include_archived: bool = False,
|
include_archived: bool = False,
|
||||||
include_folders: bool = False,
|
include_folders: bool = False,
|
||||||
|
include_pinned: bool = False,
|
||||||
skip: Optional[int] = None,
|
skip: Optional[int] = None,
|
||||||
limit: Optional[int] = None,
|
limit: Optional[int] = None,
|
||||||
) -> list[ChatTitleIdResponse]:
|
) -> list[ChatTitleIdResponse]:
|
||||||
|
|
@ -511,6 +512,7 @@ class ChatTable:
|
||||||
if not include_folders:
|
if not include_folders:
|
||||||
query = query.filter_by(folder_id=None)
|
query = query.filter_by(folder_id=None)
|
||||||
|
|
||||||
|
if not include_pinned:
|
||||||
query = query.filter(or_(Chat.pinned == False, Chat.pinned == None))
|
query = query.filter(or_(Chat.pinned == False, Chat.pinned == None))
|
||||||
|
|
||||||
if not include_archived:
|
if not include_archived:
|
||||||
|
|
|
||||||
|
|
@ -39,6 +39,7 @@ router = APIRouter()
|
||||||
def get_session_user_chat_list(
|
def get_session_user_chat_list(
|
||||||
user=Depends(get_verified_user),
|
user=Depends(get_verified_user),
|
||||||
page: Optional[int] = None,
|
page: Optional[int] = None,
|
||||||
|
include_pinned: Optional[bool] = False,
|
||||||
include_folders: Optional[bool] = False,
|
include_folders: Optional[bool] = False,
|
||||||
):
|
):
|
||||||
try:
|
try:
|
||||||
|
|
@ -47,11 +48,15 @@ def get_session_user_chat_list(
|
||||||
skip = (page - 1) * limit
|
skip = (page - 1) * limit
|
||||||
|
|
||||||
return Chats.get_chat_title_id_list_by_user_id(
|
return Chats.get_chat_title_id_list_by_user_id(
|
||||||
user.id, include_folders=include_folders, skip=skip, limit=limit
|
user.id,
|
||||||
|
include_folders=include_folders,
|
||||||
|
include_pinned=include_pinned,
|
||||||
|
skip=skip,
|
||||||
|
limit=limit,
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
return Chats.get_chat_title_id_list_by_user_id(
|
return Chats.get_chat_title_id_list_by_user_id(
|
||||||
user.id, include_folders=include_folders
|
user.id, include_folders=include_folders, include_pinned=include_pinned
|
||||||
)
|
)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
log.exception(e)
|
log.exception(e)
|
||||||
|
|
|
||||||
|
|
@ -112,6 +112,7 @@ export const importChat = async (
|
||||||
export const getChatList = async (
|
export const getChatList = async (
|
||||||
token: string = '',
|
token: string = '',
|
||||||
page: number | null = null,
|
page: number | null = null,
|
||||||
|
include_pinned: boolean = false,
|
||||||
include_folders: boolean = false
|
include_folders: boolean = false
|
||||||
) => {
|
) => {
|
||||||
let error = null;
|
let error = null;
|
||||||
|
|
@ -125,6 +126,10 @@ export const getChatList = async (
|
||||||
searchParams.append('include_folders', 'true');
|
searchParams.append('include_folders', 'true');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (include_pinned) {
|
||||||
|
searchParams.append('include_pinned', 'true');
|
||||||
|
}
|
||||||
|
|
||||||
const res = await fetch(`${WEBUI_API_BASE_URL}/chats/?${searchParams.toString()}`, {
|
const res = await fetch(`${WEBUI_API_BASE_URL}/chats/?${searchParams.toString()}`, {
|
||||||
method: 'GET',
|
method: 'GET',
|
||||||
headers: {
|
headers: {
|
||||||
|
|
|
||||||
|
|
@ -31,7 +31,7 @@
|
||||||
|
|
||||||
const getItemsPage = async () => {
|
const getItemsPage = async () => {
|
||||||
itemsLoading = true;
|
itemsLoading = true;
|
||||||
let res = await getChatList(localStorage.token, page, true).catch(() => {
|
let res = await getChatList(localStorage.token, page, true, true).catch(() => {
|
||||||
return [];
|
return [];
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue