mirror of
https://github.com/open-webui/open-webui
synced 2025-06-23 02:16:52 +00:00
fix: dates not preserved after importing chat
This commit is contained in:
parent
b5f4c85bb1
commit
04775fa34e
@ -72,6 +72,8 @@ class ChatImportForm(ChatForm):
|
|||||||
meta: Optional[dict] = {}
|
meta: Optional[dict] = {}
|
||||||
pinned: Optional[bool] = False
|
pinned: Optional[bool] = False
|
||||||
folder_id: Optional[str] = None
|
folder_id: Optional[str] = None
|
||||||
|
created_at: Optional[int] = None
|
||||||
|
updated_at: Optional[int] = None
|
||||||
|
|
||||||
|
|
||||||
class ChatTitleMessagesForm(BaseModel):
|
class ChatTitleMessagesForm(BaseModel):
|
||||||
@ -147,8 +149,16 @@ class ChatTable:
|
|||||||
"meta": form_data.meta,
|
"meta": form_data.meta,
|
||||||
"pinned": form_data.pinned,
|
"pinned": form_data.pinned,
|
||||||
"folder_id": form_data.folder_id,
|
"folder_id": form_data.folder_id,
|
||||||
"created_at": int(time.time()),
|
"created_at": (
|
||||||
"updated_at": int(time.time()),
|
form_data.created_at
|
||||||
|
if hasattr(form_data, "created_at") and form_data.created_at
|
||||||
|
else int(time.time())
|
||||||
|
),
|
||||||
|
"updated_at": (
|
||||||
|
form_data.updated_at
|
||||||
|
if hasattr(form_data, "updated_at") and form_data.updated_at
|
||||||
|
else int(time.time())
|
||||||
|
),
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -37,7 +37,9 @@ export const importChat = async (
|
|||||||
chat: object,
|
chat: object,
|
||||||
meta: object | null,
|
meta: object | null,
|
||||||
pinned?: boolean,
|
pinned?: boolean,
|
||||||
folderId?: string | null
|
folderId?: string | null,
|
||||||
|
createdAt?: number,
|
||||||
|
updatedAt?: number
|
||||||
) => {
|
) => {
|
||||||
let error = null;
|
let error = null;
|
||||||
|
|
||||||
@ -52,7 +54,9 @@ export const importChat = async (
|
|||||||
chat: chat,
|
chat: chat,
|
||||||
meta: meta ?? {},
|
meta: meta ?? {},
|
||||||
pinned: pinned,
|
pinned: pinned,
|
||||||
folder_id: folderId
|
folder_id: folderId,
|
||||||
|
created_at: createdAt,
|
||||||
|
updated_at: updatedAt
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
.then(async (res) => {
|
.then(async (res) => {
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
import {
|
import {
|
||||||
archiveAllChats,
|
archiveAllChats,
|
||||||
createNewChat,
|
importChat,
|
||||||
deleteAllChats,
|
deleteAllChats,
|
||||||
getAllChats,
|
getAllChats,
|
||||||
getAllUserChats,
|
getAllUserChats,
|
||||||
@ -58,9 +58,9 @@
|
|||||||
console.log(chat);
|
console.log(chat);
|
||||||
|
|
||||||
if (chat.chat) {
|
if (chat.chat) {
|
||||||
await createNewChat(localStorage.token, chat.chat);
|
await importChat(localStorage.token, chat.chat, chat.meta ?? {}, false, null, chat.created_at, chat.updated_at);
|
||||||
} else {
|
} else {
|
||||||
await createNewChat(localStorage.token, chat);
|
await importChat(localStorage.token, chat, chat.meta ?? {}, false, null, chat.created_at, chat.updated_at);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -202,7 +202,7 @@
|
|||||||
for (const item of items) {
|
for (const item of items) {
|
||||||
console.log(item);
|
console.log(item);
|
||||||
if (item.chat) {
|
if (item.chat) {
|
||||||
await importChat(localStorage.token, item.chat, item?.meta ?? {}, pinned, folderId);
|
await importChat(localStorage.token, item.chat, item?.meta ?? {}, pinned, folderId, item.created_at, item.updated_at);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user