mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2024-12-14 02:16:14 +01:00
#1720 Fetch no-cache images when uploading
This commit is contained in:
parent
0b322c0e3d
commit
2846d0fd58
@ -1376,6 +1376,7 @@ async function handleFileUpload(url, formData) {
|
|||||||
// Refresh sprites list
|
// Refresh sprites list
|
||||||
const name = formData.get('name');
|
const name = formData.get('name');
|
||||||
delete spriteCache[name];
|
delete spriteCache[name];
|
||||||
|
await fetchImagesNoCache();
|
||||||
await validateImages(name);
|
await validateImages(name);
|
||||||
|
|
||||||
return data;
|
return data;
|
||||||
@ -1552,6 +1553,7 @@ async function onClickExpressionDelete(event) {
|
|||||||
|
|
||||||
// Refresh sprites list
|
// Refresh sprites list
|
||||||
delete spriteCache[name];
|
delete spriteCache[name];
|
||||||
|
await fetchImagesNoCache();
|
||||||
await validateImages(name);
|
await validateImages(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1577,6 +1579,30 @@ function setExpressionOverrideHtml(forceClear = false) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function fetchImagesNoCache() {
|
||||||
|
const promises = [];
|
||||||
|
$('#image_list img').each(function () {
|
||||||
|
const src = $(this).attr('src');
|
||||||
|
|
||||||
|
if (!src) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const promise = fetch(src, {
|
||||||
|
method: 'GET',
|
||||||
|
cache: 'no-cache',
|
||||||
|
headers: {
|
||||||
|
'Cache-Control': 'no-cache',
|
||||||
|
'Pragma': 'no-cache',
|
||||||
|
'Expires': '0',
|
||||||
|
},
|
||||||
|
});
|
||||||
|
promises.push(promise);
|
||||||
|
});
|
||||||
|
|
||||||
|
return await Promise.allSettled(promises);
|
||||||
|
}
|
||||||
|
|
||||||
(function () {
|
(function () {
|
||||||
function addExpressionImage() {
|
function addExpressionImage() {
|
||||||
const html = `
|
const html = `
|
||||||
|
Loading…
Reference in New Issue
Block a user