mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2025-02-12 18:10:39 +01:00
Merge pull request #2430 from SillyTavern/toast-save-errors
Improve logs (+add toasts) on save calls
This commit is contained in:
commit
46830a27d0
@ -5775,6 +5775,7 @@ export async function saveChat(chat_name, withMetadata, mesId) {
|
|||||||
contentType: 'application/json',
|
contentType: 'application/json',
|
||||||
success: function (data) { },
|
success: function (data) { },
|
||||||
error: function (jqXHR, exception) {
|
error: function (jqXHR, exception) {
|
||||||
|
toastr.error('Check the server connection and reload the page to prevent data loss.', 'Chat could not be saved');
|
||||||
console.log(exception);
|
console.log(exception);
|
||||||
console.log(jqXHR);
|
console.log(jqXHR);
|
||||||
},
|
},
|
||||||
|
@ -336,6 +336,7 @@ async function convertSoloToGroupChat() {
|
|||||||
|
|
||||||
if (!createChatResponse.ok) {
|
if (!createChatResponse.ok) {
|
||||||
console.error('Group chat creation unsuccessful');
|
console.error('Group chat creation unsuccessful');
|
||||||
|
toastr.error('Group chat creation unsuccessful');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -231,6 +231,7 @@ export class QuickReplySet {
|
|||||||
this.rerender();
|
this.rerender();
|
||||||
} else {
|
} else {
|
||||||
warn(`Failed to save Quick Reply Set: ${this.name}`);
|
warn(`Failed to save Quick Reply Set: ${this.name}`);
|
||||||
|
console.error('QR could not be saved', response);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -492,7 +492,13 @@ async function saveGroupChat(groupId, shouldSaveGroup) {
|
|||||||
body: JSON.stringify({ id: chat_id, chat: [...chat] }),
|
body: JSON.stringify({ id: chat_id, chat: [...chat] }),
|
||||||
});
|
});
|
||||||
|
|
||||||
if (shouldSaveGroup && response.ok) {
|
if (!response.ok) {
|
||||||
|
toastr.error('Check the server connection and reload the page to prevent data loss.', 'Group Chat could not be saved');
|
||||||
|
console.error('Group chat could not be saved', response);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (shouldSaveGroup) {
|
||||||
await editGroup(groupId, false, false);
|
await editGroup(groupId, false, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -546,9 +552,11 @@ export async function renameGroupMember(oldAvatar, newAvatar, newName) {
|
|||||||
body: JSON.stringify({ id: chatId, chat: [...messages] }),
|
body: JSON.stringify({ id: chatId, chat: [...messages] }),
|
||||||
});
|
});
|
||||||
|
|
||||||
if (saveChatResponse.ok) {
|
if (!saveChatResponse.ok) {
|
||||||
console.log(`Renamed character ${newName} in group chat: ${chatId}`);
|
throw new Error('Group member could not be renamed');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
console.log(`Renamed character ${newName} in group chat: ${chatId}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1828,11 +1836,16 @@ export async function saveGroupBookmarkChat(groupId, name, metadata, mesId) {
|
|||||||
|
|
||||||
await editGroup(groupId, true, false);
|
await editGroup(groupId, true, false);
|
||||||
|
|
||||||
await fetch('/api/chats/group/save', {
|
const response = await fetch('/api/chats/group/save', {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: getRequestHeaders(),
|
headers: getRequestHeaders(),
|
||||||
body: JSON.stringify({ id: name, chat: [...trimmed_chat] }),
|
body: JSON.stringify({ id: name, chat: [...trimmed_chat] }),
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if (!response.ok) {
|
||||||
|
toastr.error('Check the server connection and reload the page to prevent data loss.', 'Group chat could not be saved');
|
||||||
|
console.error('Group chat could not be saved', response);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function onSendTextareaInput() {
|
function onSendTextareaInput() {
|
||||||
|
@ -3365,6 +3365,7 @@ async function saveOpenAIPreset(name, settings, triggerUi = true) {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
toastr.error('Failed to save preset');
|
toastr.error('Failed to save preset');
|
||||||
|
throw new Error('Failed to save preset');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2316,26 +2316,30 @@ async function saveTheme(name = undefined, theme = undefined) {
|
|||||||
body: JSON.stringify(theme),
|
body: JSON.stringify(theme),
|
||||||
});
|
});
|
||||||
|
|
||||||
if (response.ok) {
|
if (!response.ok) {
|
||||||
const themeIndex = themes.findIndex(x => x.name == name);
|
toastr.error('Check the server connection and reload the page to prevent data loss.', 'Theme could not be saved');
|
||||||
|
console.error('Theme could not be saved', response);
|
||||||
if (themeIndex == -1) {
|
throw new Error('Theme could not be saved');
|
||||||
themes.push(theme);
|
|
||||||
const option = document.createElement('option');
|
|
||||||
option.selected = true;
|
|
||||||
option.value = name;
|
|
||||||
option.innerText = name;
|
|
||||||
$('#themes').append(option);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
themes[themeIndex] = theme;
|
|
||||||
$(`#themes option[value="${name}"]`).attr('selected', true);
|
|
||||||
}
|
|
||||||
|
|
||||||
power_user.theme = name;
|
|
||||||
saveSettingsDebounced();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const themeIndex = themes.findIndex(x => x.name == name);
|
||||||
|
|
||||||
|
if (themeIndex == -1) {
|
||||||
|
themes.push(theme);
|
||||||
|
const option = document.createElement('option');
|
||||||
|
option.selected = true;
|
||||||
|
option.value = name;
|
||||||
|
option.innerText = name;
|
||||||
|
$('#themes').append(option);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
themes[themeIndex] = theme;
|
||||||
|
$(`#themes option[value="${name}"]`).attr('selected', true);
|
||||||
|
}
|
||||||
|
|
||||||
|
power_user.theme = name;
|
||||||
|
saveSettingsDebounced();
|
||||||
|
|
||||||
return theme;
|
return theme;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2401,12 +2405,14 @@ function getNewTheme(parsed) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function saveMovingUI() {
|
async function saveMovingUI() {
|
||||||
const name = await callGenericPopup('Enter a name for the MovingUI Preset:', POPUP_TYPE.INPUT);
|
const popupResult = await callGenericPopup('Enter a name for the MovingUI Preset:', POPUP_TYPE.INPUT);
|
||||||
|
|
||||||
if (!name) {
|
if (!popupResult) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const name = String(popupResult);
|
||||||
|
|
||||||
const movingUIPreset = {
|
const movingUIPreset = {
|
||||||
name,
|
name,
|
||||||
movingUIState: power_user.movingUIState,
|
movingUIState: power_user.movingUIState,
|
||||||
@ -2438,7 +2444,8 @@ async function saveMovingUI() {
|
|||||||
power_user.movingUIPreset = name;
|
power_user.movingUIPreset = name;
|
||||||
saveSettingsDebounced();
|
saveSettingsDebounced();
|
||||||
} else {
|
} else {
|
||||||
toastr.warning('failed to save MovingUI state.');
|
toastr.error('Failed to save MovingUI state.');
|
||||||
|
console.error('MovingUI could not be saved', response);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -182,17 +182,19 @@ class PresetManager {
|
|||||||
async savePreset(name, settings) {
|
async savePreset(name, settings) {
|
||||||
const preset = settings ?? this.getPresetSettings(name);
|
const preset = settings ?? this.getPresetSettings(name);
|
||||||
|
|
||||||
const res = await fetch('/api/presets/save', {
|
const response = await fetch('/api/presets/save', {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: getRequestHeaders(),
|
headers: getRequestHeaders(),
|
||||||
body: JSON.stringify({ preset, name, apiId: this.apiId }),
|
body: JSON.stringify({ preset, name, apiId: this.apiId }),
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!res.ok) {
|
if (!response.ok) {
|
||||||
toastr.error('Failed to save preset');
|
toastr.error('Check the server connection and reload the page to prevent data loss.', 'Preset could not be saved');
|
||||||
|
console.error('Preset could not be saved', response);
|
||||||
|
throw new Error('Preset could not be saved');
|
||||||
}
|
}
|
||||||
|
|
||||||
const data = await res.json();
|
const data = await response.json();
|
||||||
name = data.name;
|
name = data.name;
|
||||||
|
|
||||||
this.updateList(name, preset);
|
this.updateList(name, preset);
|
||||||
|
@ -3296,7 +3296,7 @@ export async function executeSlashCommandsOnChatInput(text, options = {}) {
|
|||||||
result = new SlashCommandClosureResult();
|
result = new SlashCommandClosureResult();
|
||||||
result.isError = true;
|
result.isError = true;
|
||||||
result.errorMessage = e.message;
|
result.errorMessage = e.message;
|
||||||
if (e.cause !== 'abort') {
|
if (e.cause !== 'abort' && e.message) {
|
||||||
toastr.error(e.message);
|
toastr.error(e.message);
|
||||||
}
|
}
|
||||||
} finally {
|
} finally {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user