mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2025-06-05 21:59:27 +02:00
@ -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() {
|
||||||
|
@ -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) {
|
return;
|
||||||
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2439,6 +2443,7 @@ async function saveMovingUI() {
|
|||||||
saveSettingsDebounced();
|
saveSettingsDebounced();
|
||||||
} else {
|
} else {
|
||||||
toastr.warning('failed to save MovingUI state.');
|
toastr.warning('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);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const data = await res.json();
|
const data = await response.json();
|
||||||
name = data.name;
|
name = data.name;
|
||||||
|
|
||||||
this.updateList(name, preset);
|
this.updateList(name, preset);
|
||||||
|
Reference in New Issue
Block a user