mirror of
https://github.com/open-webui/open-webui.git
synced 2026-12-06 03:28:12 -05:00
fix: importing chats from Settings does nothing when the file is not valid JSON or the import fails (#35269)
Settings > Data Controls > Import Chats did nothing at all for a file that is not valid JSON, and also when the server refused the import. A file that is not valid JSON now shows "Invalid file format.", the same message the sidebar import uses, and a failed import shows its error. Fixes #35268
This commit is contained in:
1 parent
dc91478606
commit
b6175ef1a7
1 file changed
+10
-2
@@ -38,7 +38,13 @@
|
||||
|
||||
let reader = new FileReader();
|
||||
reader.onload = (event) => {
|
||||
let chats = JSON.parse(event.target.result);
|
||||
let chats;
|
||||
try {
|
||||
chats = JSON.parse(event.target.result);
|
||||
} catch {
|
||||
toast.error($i18n.t('Invalid file format.'));
|
||||
return;
|
||||
}
|
||||
console.log(chats);
|
||||
if (getImportOrigin(chats) == 'openai') {
|
||||
try {
|
||||
@@ -82,7 +88,9 @@
|
||||
};
|
||||
}
|
||||
})
|
||||
);
|
||||
).catch((error) => {
|
||||
toast.error(`${error}`);
|
||||
});
|
||||
if (res) {
|
||||
toast.success(`Successfully imported ${res.length} chats.`);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user