Skip to content

Commit f3b4a7a

Browse files
author
prima
committed
fix: Added block to prevent opening manager while loading daata
1 parent 6652e57 commit f3b4a7a

File tree

4 files changed

+43
-3
lines changed

4 files changed

+43
-3
lines changed

embd_res/js/characterManager.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -594,6 +594,13 @@ let getScenariosAndLegacyServerSaves = async () => {
594594

595595
let maxLengthForSection = 500, halfMaxLengthForSection = Math.floor(maxLengthForSection / 2);
596596
let showCharacterList = async () => {
597+
// Still processing characters
598+
if (!!window?.debounce_pending_updateCharacterListFromAll || !!window?.pending_encrypt)
599+
{
600+
handleError("Please wait - data is still being loaded")
601+
return
602+
}
603+
597604
let containers = []
598605

599606
let createIcon = (name, image) => {

embd_res/js/encryptUtils.js

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
11
window.encrypt = (key, data) => {
2+
waitingToast.setText("Encrypting")
3+
waitingToast.show()
4+
window["pending_encrypt"] = true
5+
26
var iv = forge.random.getBytesSync(16)
37
var salt = forge.random.getBytesSync(128)
48
var saltedKey = forge.pkcs5.pbkdf2(key, salt, 10, 16)
@@ -13,10 +17,18 @@ window.encrypt = (key, data) => {
1317
iv: btoa(iv),
1418
text: cipher.output.toHex(),
1519
}
16-
return btoa(JSON.stringify(encryptedObj))
20+
let returnValue = btoa(JSON.stringify(encryptedObj))
21+
22+
window["pending_encrypt"] = false
23+
waitingToast.hide()
24+
return returnValue
1725
}
1826

1927
window.decrypt = (key, data) => {
28+
waitingToast.setText("Decrypting")
29+
waitingToast.show()
30+
window["pending_encrypt"] = true
31+
2032
data = JSON.parse(atob(data))
2133
var encryptedBytes = forge.util.hexToBytes(data.text)
2234
var saltedKey = forge.pkcs5.pbkdf2(key, atob(data.salt), 10, 16)
@@ -34,5 +46,8 @@ window.decrypt = (key, data) => {
3446
} while (index < length)
3547
var result = decipher.finish()
3648
decrypted += decipher.output.getBytes()
49+
50+
window["pending_encrypt"] = false
51+
waitingToast.hide()
3752
return decrypted
3853
}

embd_res/js/waitingToast.js

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
class WaitingToast {
33
#waitingDiv
44
#waitingText
5+
lock = false
56
constructor() {
67
this.waitingDiv = document.createElement("div")
78
this.waitingDiv.classList.add("waitingToast", "hidden")
@@ -18,10 +19,25 @@ class WaitingToast {
1819
}
1920

2021
show() {
21-
this.waitingDiv.classList.remove("hidden")
22+
if (!this.lock)
23+
{
24+
this.waitingDiv.classList.remove("hidden")
25+
}
2226
}
2327

2428
hide() {
29+
if (!this.lock) {
30+
this.waitingDiv.classList.add("hidden")
31+
}
32+
}
33+
34+
showLock() {
35+
this.lock = true
36+
this.waitingDiv.classList.remove("hidden")
37+
}
38+
39+
hideUnlock() {
40+
this.lock = false
2541
this.waitingDiv.classList.add("hidden")
2642
}
2743

embd_res/klite.embd

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5521,10 +5521,12 @@ Current version indicated by LITEVER below.
55215521
}
55225522

55235523
function debounce(func, delay) {
5524-
let timeout;
5524+
let timeout, functionName = func?.prototype?.constructor?.name, debounceVar = `debounce_pending_${functionName || "generic"}`;;
55255525
return function (...args) {
5526+
window[debounceVar] = true
55265527
clearTimeout(timeout);
55275528
timeout = setTimeout(() => {
5529+
window[debounceVar] = false
55285530
func.apply(this, args);
55295531
}, delay);
55305532
};

0 commit comments

Comments
 (0)