mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2025-06-05 21:59:27 +02:00
Rename character as a group member.
Unify CSRF headers usage in fetch request.
This commit is contained in:
@ -40,6 +40,7 @@ import {
|
|||||||
regenerateGroup,
|
regenerateGroup,
|
||||||
group_generation_id,
|
group_generation_id,
|
||||||
getGroupChat,
|
getGroupChat,
|
||||||
|
renameGroupMember,
|
||||||
} from "./scripts/group-chats.js";
|
} from "./scripts/group-chats.js";
|
||||||
|
|
||||||
import {
|
import {
|
||||||
@ -493,7 +494,7 @@ var colab_ini_step = 1;
|
|||||||
|
|
||||||
let token;
|
let token;
|
||||||
|
|
||||||
function getRequestHeaders() {
|
export function getRequestHeaders() {
|
||||||
return {
|
return {
|
||||||
"Content-Type": "application/json",
|
"Content-Type": "application/json",
|
||||||
"X-CSRF-Token": token,
|
"X-CSRF-Token": token,
|
||||||
@ -2538,6 +2539,8 @@ async function renameCharacter() {
|
|||||||
throw new Error('New character not selected');
|
throw new Error('New character not selected');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Also rename as a group member
|
||||||
|
await renameGroupMember(oldAvatar, newAvatar, newValue);
|
||||||
callPopup('<h3>Character renamed!</h3>Sprites folder (if any) should be renamed manually.', 'text');
|
callPopup('<h3>Character renamed!</h3>Sprites folder (if any) should be renamed manually.', 'text');
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -2,13 +2,13 @@ import {
|
|||||||
characters,
|
characters,
|
||||||
saveChat,
|
saveChat,
|
||||||
sendSystemMessage,
|
sendSystemMessage,
|
||||||
token,
|
|
||||||
system_messages,
|
system_messages,
|
||||||
system_message_types,
|
system_message_types,
|
||||||
this_chid,
|
this_chid,
|
||||||
openCharacterChat,
|
openCharacterChat,
|
||||||
chat_metadata,
|
chat_metadata,
|
||||||
callPopup,
|
callPopup,
|
||||||
|
getRequestHeaders,
|
||||||
} from "../script.js";
|
} from "../script.js";
|
||||||
import { selected_group } from "./group-chats.js";
|
import { selected_group } from "./group-chats.js";
|
||||||
|
|
||||||
@ -25,10 +25,7 @@ const bookmarkNameToken = 'Bookmark #';
|
|||||||
async function getExistingChatNames() {
|
async function getExistingChatNames() {
|
||||||
const response = await fetch("/getallchatsofcharacter", {
|
const response = await fetch("/getallchatsofcharacter", {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: {
|
headers: getRequestHeaders(),
|
||||||
'Content-Type': 'application/json',
|
|
||||||
"X-CSRF-Token": token,
|
|
||||||
},
|
|
||||||
body: JSON.stringify({ avatar_url: characters[this_chid].avatar })
|
body: JSON.stringify({ avatar_url: characters[this_chid].avatar })
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import { callPopup, saveSettings, saveSettingsDebounced, token } from "../script.js";
|
import { callPopup, saveSettings, saveSettingsDebounced } from "../script.js";
|
||||||
import { isSubsetOf } from "./utils.js";
|
import { isSubsetOf } from "./utils.js";
|
||||||
export {
|
export {
|
||||||
getContext,
|
getContext,
|
||||||
@ -37,7 +37,7 @@ let connectedToApi = false;
|
|||||||
|
|
||||||
async function discoverExtensions() {
|
async function discoverExtensions() {
|
||||||
try {
|
try {
|
||||||
const response = await fetch('/discover_extensions', { headers: { 'X-CSRF-Token': token } });
|
const response = await fetch('/discover_extensions');
|
||||||
|
|
||||||
if (response.ok) {
|
if (response.ok) {
|
||||||
const extensions = await response.json();
|
const extensions = await response.json();
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import { saveSettingsDebounced, token } from "../../../script.js";
|
import { saveSettingsDebounced } from "../../../script.js";
|
||||||
import { getContext, getApiUrl, modules, extension_settings } from "../../extensions.js";
|
import { getContext, getApiUrl, modules, extension_settings } from "../../extensions.js";
|
||||||
export { MODULE_NAME };
|
export { MODULE_NAME };
|
||||||
|
|
||||||
@ -250,11 +250,7 @@ async function getSpritesList(name) {
|
|||||||
console.log('getting sprites list');
|
console.log('getting sprites list');
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const result = await fetch(`/get_sprites?name=${encodeURIComponent(name)}`, {
|
const result = await fetch(`/get_sprites?name=${encodeURIComponent(name)}`);
|
||||||
headers: {
|
|
||||||
'X-CSRF-Token': token,
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
let sprites = result.ok ? (await result.json()) : [];
|
let sprites = result.ok ? (await result.json()) : [];
|
||||||
return sprites;
|
return sprites;
|
||||||
|
@ -14,7 +14,6 @@ import {
|
|||||||
substituteParams,
|
substituteParams,
|
||||||
characters,
|
characters,
|
||||||
default_avatar,
|
default_avatar,
|
||||||
token,
|
|
||||||
addOneMessage,
|
addOneMessage,
|
||||||
callPopup,
|
callPopup,
|
||||||
clearChat,
|
clearChat,
|
||||||
@ -42,6 +41,7 @@ import {
|
|||||||
isStreamingEnabled,
|
isStreamingEnabled,
|
||||||
getThumbnailUrl,
|
getThumbnailUrl,
|
||||||
streamingProcessor,
|
streamingProcessor,
|
||||||
|
getRequestHeaders,
|
||||||
} from "../script.js";
|
} from "../script.js";
|
||||||
import { appendTagToList, createTagMapFromList, getTagsList } from './tags.js';
|
import { appendTagToList, createTagMapFromList, getTagsList } from './tags.js';
|
||||||
|
|
||||||
@ -82,10 +82,7 @@ const saveGroupDebounced = debounce(async (group) => await _save(group), 500);
|
|||||||
async function _save(group) {
|
async function _save(group) {
|
||||||
await fetch("/editgroup", {
|
await fetch("/editgroup", {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
headers: {
|
headers: getRequestHeaders(),
|
||||||
"Content-Type": "application/json",
|
|
||||||
"X-CSRF-Token": token,
|
|
||||||
},
|
|
||||||
body: JSON.stringify(group),
|
body: JSON.stringify(group),
|
||||||
});
|
});
|
||||||
await getCharacters();
|
await getCharacters();
|
||||||
@ -120,10 +117,7 @@ export async function getGroupChat(groupId) {
|
|||||||
const chat_id = group.chat_id;
|
const chat_id = group.chat_id;
|
||||||
const response = await fetch("/getgroupchat", {
|
const response = await fetch("/getgroupchat", {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
headers: {
|
headers: getRequestHeaders(),
|
||||||
"Content-Type": "application/json",
|
|
||||||
"X-CSRF-Token": token,
|
|
||||||
},
|
|
||||||
body: JSON.stringify({ id: chat_id }),
|
body: JSON.stringify({ id: chat_id }),
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -139,7 +133,7 @@ export async function getGroupChat(groupId) {
|
|||||||
sendSystemMessage(system_message_types.GROUP);
|
sendSystemMessage(system_message_types.GROUP);
|
||||||
if (group && Array.isArray(group.members)) {
|
if (group && Array.isArray(group.members)) {
|
||||||
for (let member of group.members) {
|
for (let member of group.members) {
|
||||||
const character = characters.find(x => x.avatar === member || x.name === member);
|
const character = characters.find(x => x.avatar === member || x.name === member);
|
||||||
|
|
||||||
if (!character) {
|
if (!character) {
|
||||||
continue;
|
continue;
|
||||||
@ -188,10 +182,7 @@ async function saveGroupChat(groupId, shouldSaveGroup) {
|
|||||||
const chat_id = group.chat_id;
|
const chat_id = group.chat_id;
|
||||||
const response = await fetch("/savegroupchat", {
|
const response = await fetch("/savegroupchat", {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
headers: {
|
headers: getRequestHeaders(),
|
||||||
"Content-Type": "application/json",
|
|
||||||
"X-CSRF-Token": token,
|
|
||||||
},
|
|
||||||
body: JSON.stringify({ id: chat_id, chat: [...chat] }),
|
body: JSON.stringify({ id: chat_id, chat: [...chat] }),
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -200,13 +191,81 @@ async function saveGroupChat(groupId, shouldSaveGroup) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export async function renameGroupMember(oldAvatar, newAvatar, newName) {
|
||||||
|
// Scan every group for our renamed character
|
||||||
|
for (const group of groups) {
|
||||||
|
try {
|
||||||
|
|
||||||
|
// Try finding the member by old avatar link
|
||||||
|
const memberIndex = group.members.findIndex(x => x == oldAvatar);
|
||||||
|
|
||||||
|
// Character was not present in the group...
|
||||||
|
if (memberIndex == -1) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Replace group member avatar id and save the changes
|
||||||
|
group.members[memberIndex] = newAvatar;
|
||||||
|
await editGroup(group.id, true);
|
||||||
|
console.log(`Renamed character ${newName} in group: ${group.name}`)
|
||||||
|
|
||||||
|
// Load all chats from this group
|
||||||
|
for (const chatId of group.chats) {
|
||||||
|
const getChatResponse = await fetch("/getgroupchat", {
|
||||||
|
method: "POST",
|
||||||
|
headers: getRequestHeaders(),
|
||||||
|
body: JSON.stringify({ id: chatId }),
|
||||||
|
});
|
||||||
|
|
||||||
|
if (getChatResponse.ok) {
|
||||||
|
// Only save the chat if there were any changes to the chat content
|
||||||
|
let hadChanges = false;
|
||||||
|
const messages = await getChatResponse.json();
|
||||||
|
// Chat shouldn't be empty
|
||||||
|
if (Array.isArray(messages) && messages.length) {
|
||||||
|
// Iterate over every chat message
|
||||||
|
for (const message of messages) {
|
||||||
|
// Only look at character messages
|
||||||
|
if (message.is_user || message.is_system) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Message belonged to the old-named character:
|
||||||
|
// Update name, avatar thumbnail URL and original avatar link
|
||||||
|
if (message.force_avatar && message.force_avatar.indexOf(encodeURIComponent(oldAvatar)) !== -1) {
|
||||||
|
message.name = newName;
|
||||||
|
message.force_avatar = message.force_avatar.replace(encodeURIComponent(oldAvatar), encodeURIComponent(newAvatar));
|
||||||
|
message.original_avatar = newAvatar;
|
||||||
|
hadChanges = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (hadChanges) {
|
||||||
|
const saveChatResponse = await fetch("/savegroupchat", {
|
||||||
|
method: "POST",
|
||||||
|
headers: getRequestHeaders(),
|
||||||
|
body: JSON.stringify({ id: chatId, chat: [...messages] }),
|
||||||
|
});
|
||||||
|
|
||||||
|
if (saveChatResponse.ok) {
|
||||||
|
console.log(`Renamed character ${newName} in group chat: ${chatId}`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (error) {
|
||||||
|
console.log(`An error during renaming the character ${newName} in group: ${group.name}`);
|
||||||
|
console.error(error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
async function getGroups() {
|
async function getGroups() {
|
||||||
const response = await fetch("/getgroups", {
|
const response = await fetch("/getgroups", {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
headers: {
|
headers: getRequestHeaders()
|
||||||
"Content-Type": "application/json",
|
|
||||||
"X-CSRF-Token": token,
|
|
||||||
},
|
|
||||||
});
|
});
|
||||||
|
|
||||||
if (response.ok) {
|
if (response.ok) {
|
||||||
@ -219,9 +278,9 @@ async function getGroups() {
|
|||||||
group.chat_id = group.id;
|
group.chat_id = group.id;
|
||||||
group.chats = [group.id];
|
group.chats = [group.id];
|
||||||
group.members = group.members
|
group.members = group.members
|
||||||
.map(x => characters.find(y => y.name == x)?.avatar)
|
.map(x => characters.find(y => y.name == x)?.avatar)
|
||||||
.filter(x => x)
|
.filter(x => x)
|
||||||
.filter(onlyUnique)
|
.filter(onlyUnique)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -491,7 +550,7 @@ function activateSwipe(members) {
|
|||||||
let activatedNames = [];
|
let activatedNames = [];
|
||||||
|
|
||||||
// pre-update group chat swipe
|
// pre-update group chat swipe
|
||||||
if (!chat[chat.length -1].original_avatar) {
|
if (!chat[chat.length - 1].original_avatar) {
|
||||||
const matches = characters.filter(x => x.name == chat[chat.length - 1].name);
|
const matches = characters.filter(x => x.name == chat[chat.length - 1].name);
|
||||||
|
|
||||||
for (const match of matches) {
|
for (const match of matches) {
|
||||||
@ -502,7 +561,7 @@ function activateSwipe(members) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
activatedNames.push(chat[chat.length -1].original_avatar);
|
activatedNames.push(chat[chat.length - 1].original_avatar);
|
||||||
}
|
}
|
||||||
|
|
||||||
const memberIds = activatedNames
|
const memberIds = activatedNames
|
||||||
@ -609,10 +668,7 @@ function extractAllWords(value) {
|
|||||||
async function deleteGroup(id) {
|
async function deleteGroup(id) {
|
||||||
const response = await fetch("/deletegroup", {
|
const response = await fetch("/deletegroup", {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
headers: {
|
headers: getRequestHeaders(),
|
||||||
"Content-Type": "application/json",
|
|
||||||
"X-CSRF-Token": token,
|
|
||||||
},
|
|
||||||
body: JSON.stringify({ id: id }),
|
body: JSON.stringify({ id: id }),
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -943,10 +999,7 @@ $(document).ready(() => {
|
|||||||
|
|
||||||
const createGroupResponse = await fetch("/creategroup", {
|
const createGroupResponse = await fetch("/creategroup", {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
headers: {
|
headers: getRequestHeaders(),
|
||||||
"Content-Type": "application/json",
|
|
||||||
"X-CSRF-Token": token,
|
|
||||||
},
|
|
||||||
body: JSON.stringify({
|
body: JSON.stringify({
|
||||||
name: name,
|
name: name,
|
||||||
members: members,
|
members: members,
|
||||||
|
@ -10,13 +10,13 @@ import {
|
|||||||
checkOnlineStatus,
|
checkOnlineStatus,
|
||||||
setOnlineStatus,
|
setOnlineStatus,
|
||||||
getExtensionPrompt,
|
getExtensionPrompt,
|
||||||
token,
|
|
||||||
name1,
|
name1,
|
||||||
name2,
|
name2,
|
||||||
extension_prompt_types,
|
extension_prompt_types,
|
||||||
characters,
|
characters,
|
||||||
this_chid,
|
this_chid,
|
||||||
callPopup,
|
callPopup,
|
||||||
|
getRequestHeaders,
|
||||||
} from "../script.js";
|
} from "../script.js";
|
||||||
import { groups, selected_group } from "./group-chats.js";
|
import { groups, selected_group } from "./group-chats.js";
|
||||||
|
|
||||||
@ -509,10 +509,7 @@ async function sendOpenAIRequest(openai_msgs_tosend, signal) {
|
|||||||
const response = await fetch(generate_url, {
|
const response = await fetch(generate_url, {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
body: JSON.stringify(generate_data),
|
body: JSON.stringify(generate_data),
|
||||||
headers: {
|
headers: getRequestHeaders(),
|
||||||
'Content-Type': 'application/json',
|
|
||||||
"X-CSRF-Token": token,
|
|
||||||
},
|
|
||||||
signal: signal,
|
signal: signal,
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -567,10 +564,7 @@ async function calculateLogitBias() {
|
|||||||
try {
|
try {
|
||||||
const reply = await fetch(`/openai_bias?model=${oai_settings.openai_model}`, {
|
const reply = await fetch(`/openai_bias?model=${oai_settings.openai_model}`, {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: {
|
headers: getRequestHeaders(),
|
||||||
'Content-Type': 'application/json',
|
|
||||||
'X-CSRF-Token': token,
|
|
||||||
},
|
|
||||||
body,
|
body,
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -802,10 +796,7 @@ async function saveOpenAIPreset(name, settings) {
|
|||||||
|
|
||||||
const savePresetSettings = await fetch(`/savepreset_openai?name=${name}`, {
|
const savePresetSettings = await fetch(`/savepreset_openai?name=${name}`, {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: {
|
headers: getRequestHeaders(),
|
||||||
'Content-Type': 'application/json',
|
|
||||||
'X-CSRF-Token': token,
|
|
||||||
},
|
|
||||||
body: JSON.stringify(presetBody),
|
body: JSON.stringify(presetBody),
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -837,7 +828,7 @@ async function showApiKeyUsage() {
|
|||||||
try {
|
try {
|
||||||
const response = await fetch('/openai_usage', {
|
const response = await fetch('/openai_usage', {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: { 'Content-Type': 'application/json', 'X-CSRF-Token': token },
|
headers: getRequestHeaders(),
|
||||||
body: body,
|
body: body,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -1,11 +1,11 @@
|
|||||||
import {
|
import {
|
||||||
token as csrf_token,
|
|
||||||
saveSettingsDebounced,
|
saveSettingsDebounced,
|
||||||
setOnlineStatus,
|
setOnlineStatus,
|
||||||
checkOnlineStatus,
|
checkOnlineStatus,
|
||||||
substituteParams,
|
substituteParams,
|
||||||
max_context,
|
max_context,
|
||||||
getTokenCount,
|
getTokenCount,
|
||||||
|
getRequestHeaders,
|
||||||
} from "../script.js";
|
} from "../script.js";
|
||||||
|
|
||||||
export {
|
export {
|
||||||
@ -149,10 +149,7 @@ async function purgeConversation(count = -1) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
const response = await fetch('/purge_poe', {
|
const response = await fetch('/purge_poe', {
|
||||||
headers: {
|
headers: getRequestHeaders(),
|
||||||
'X-CSRF-Token': csrf_token,
|
|
||||||
'Content-Type': 'application/json',
|
|
||||||
},
|
|
||||||
body: body,
|
body: body,
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
});
|
});
|
||||||
@ -173,10 +170,7 @@ async function sendMessage(prompt, withStreaming, signal) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
const response = await fetch('/generate_poe', {
|
const response = await fetch('/generate_poe', {
|
||||||
headers: {
|
headers: getRequestHeaders(),
|
||||||
'X-CSRF-Token': csrf_token,
|
|
||||||
'Content-Type': 'application/json',
|
|
||||||
},
|
|
||||||
body: body,
|
body: body,
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
signal: signal,
|
signal: signal,
|
||||||
@ -241,10 +235,7 @@ function setButtonState(value) {
|
|||||||
async function checkStatusPoe() {
|
async function checkStatusPoe() {
|
||||||
const body = JSON.stringify({ token: poe_settings.token });
|
const body = JSON.stringify({ token: poe_settings.token });
|
||||||
const response = await fetch('/status_poe', {
|
const response = await fetch('/status_poe', {
|
||||||
headers: {
|
headers: getRequestHeaders(),
|
||||||
'X-CSRF-Token': csrf_token,
|
|
||||||
'Content-Type': 'application/json',
|
|
||||||
},
|
|
||||||
body: body,
|
body: body,
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
});
|
});
|
||||||
|
@ -3,10 +3,10 @@ import {
|
|||||||
scrollChatToBottom,
|
scrollChatToBottom,
|
||||||
characters,
|
characters,
|
||||||
callPopup,
|
callPopup,
|
||||||
token,
|
|
||||||
getStatus,
|
getStatus,
|
||||||
reloadMarkdownProcessor,
|
reloadMarkdownProcessor,
|
||||||
reloadCurrentChat,
|
reloadCurrentChat,
|
||||||
|
getRequestHeaders,
|
||||||
} from "../script.js";
|
} from "../script.js";
|
||||||
|
|
||||||
export {
|
export {
|
||||||
@ -449,10 +449,8 @@ async function saveTheme() {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const response = await fetch('/savetheme', {
|
const response = await fetch('/savetheme', {
|
||||||
method: 'POST', headers: {
|
method: 'POST',
|
||||||
'X-CSRF-Token': token,
|
headers: getRequestHeaders(),
|
||||||
'Content-Type': 'application/json',
|
|
||||||
},
|
|
||||||
body: JSON.stringify(theme)
|
body: JSON.stringify(theme)
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import {
|
import {
|
||||||
|
getRequestHeaders,
|
||||||
saveSettingsDebounced,
|
saveSettingsDebounced,
|
||||||
token,
|
|
||||||
} from "../script.js";
|
} from "../script.js";
|
||||||
|
|
||||||
export {
|
export {
|
||||||
@ -160,8 +160,7 @@ function setSettingByName(i, value, trigger) {
|
|||||||
async function generateTextGenWithStreaming(generate_data, signal) {
|
async function generateTextGenWithStreaming(generate_data, signal) {
|
||||||
const response = await fetch('/generate_textgenerationwebui', {
|
const response = await fetch('/generate_textgenerationwebui', {
|
||||||
headers: {
|
headers: {
|
||||||
'Content-Type': 'application/json',
|
...getRequestHeaders(),
|
||||||
'X-CSRF-Token': token,
|
|
||||||
'X-Response-Streaming': true,
|
'X-Response-Streaming': true,
|
||||||
'X-Streaming-URL': textgenerationwebui_settings.streaming_url,
|
'X-Streaming-URL': textgenerationwebui_settings.streaming_url,
|
||||||
},
|
},
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import { saveSettings, callPopup, token, substituteParams, getTokenCount } from "../script.js";
|
import { saveSettings, callPopup, substituteParams, getTokenCount, getRequestHeaders } from "../script.js";
|
||||||
import { download, debounce } from "./utils.js";
|
import { download, debounce } from "./utils.js";
|
||||||
|
|
||||||
export {
|
export {
|
||||||
@ -92,10 +92,7 @@ async function loadWorldInfoData() {
|
|||||||
|
|
||||||
const response = await fetch("/getworldinfo", {
|
const response = await fetch("/getworldinfo", {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
headers: {
|
headers: getRequestHeaders(),
|
||||||
"Content-Type": "application/json",
|
|
||||||
"X-CSRF-Token": token,
|
|
||||||
},
|
|
||||||
body: JSON.stringify({ name: world_info }),
|
body: JSON.stringify({ name: world_info }),
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -107,10 +104,7 @@ async function loadWorldInfoData() {
|
|||||||
async function updateWorldInfoList(importedWorldName) {
|
async function updateWorldInfoList(importedWorldName) {
|
||||||
var result = await fetch("/getsettings", {
|
var result = await fetch("/getsettings", {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
headers: {
|
headers: getRequestHeaders(),
|
||||||
"Content-Type": "application/json",
|
|
||||||
"X-CSRF-Token": token,
|
|
||||||
},
|
|
||||||
body: JSON.stringify({}),
|
body: JSON.stringify({}),
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -343,10 +337,7 @@ function createWorldInfoEntry() {
|
|||||||
async function _save() {
|
async function _save() {
|
||||||
const response = await fetch("/editworldinfo", {
|
const response = await fetch("/editworldinfo", {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
headers: {
|
headers: getRequestHeaders(),
|
||||||
"Content-Type": "application/json",
|
|
||||||
"X-CSRF-Token": token,
|
|
||||||
},
|
|
||||||
body: JSON.stringify({ name: world_info, data: world_info_data }),
|
body: JSON.stringify({ name: world_info, data: world_info_data }),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -384,10 +375,7 @@ async function deleteWorldInfo(worldInfoName, selectWorldName) {
|
|||||||
|
|
||||||
const response = await fetch("/deleteworldinfo", {
|
const response = await fetch("/deleteworldinfo", {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
headers: {
|
headers: getRequestHeaders(),
|
||||||
"Content-Type": "application/json",
|
|
||||||
"X-CSRF-Token": token,
|
|
||||||
},
|
|
||||||
body: JSON.stringify({ name: worldInfoName }),
|
body: JSON.stringify({ name: worldInfoName }),
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user