Compare commits
No commits in common. "a74163b29a446dfc6b95e211e90f3b7478bae25b" and "779624a7221e37ca2e70ccb04c29dd4a7bdb9fd6" have entirely different histories.
a74163b29a
...
779624a722
47
manage.js
47
manage.js
@ -233,37 +233,6 @@ clearbtn.onclick = async () => {
|
|||||||
await loadToggleState();
|
await loadToggleState();
|
||||||
})().catch(displayError);
|
})().catch(displayError);
|
||||||
|
|
||||||
async function refreshImages() {
|
|
||||||
console.debug("refreshImages");
|
|
||||||
var images = await db.getAllImages();
|
|
||||||
for (let image of images) {
|
|
||||||
if (!document.querySelector(`[data-internal-id="${image.internalId}"]`)) createEmojiSquare(image);
|
|
||||||
}
|
|
||||||
var ids = images.map(i => i.internalId);
|
|
||||||
for (let emojisquare of document.querySelectorAll(".emojisquare")) {
|
|
||||||
if (!ids.includes(emojisquare.dataset.internalId)) emojisquare.delete();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
async function loadToggleState() {
|
|
||||||
console.debug("loadToggleState");
|
|
||||||
try {
|
|
||||||
var elements = document.querySelectorAll(".emojisquare");
|
|
||||||
if (elements.length === 0) return;
|
|
||||||
var currentFiles = await callContentScript("getFiles", mode);
|
|
||||||
var active = currentFiles?.map(e => e.id);
|
|
||||||
elements.forEach(e => {
|
|
||||||
e.dataset.state = active.includes(e.dataset["currentId_"+mode]) ? "enabled" : "disabled";
|
|
||||||
});
|
|
||||||
errorDiv.innerText = "";
|
|
||||||
} catch (error) {
|
|
||||||
displayError(error);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
onfocus = () => refreshImages().then(loadToggleState);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function createEmojiSquare({internalId, data, animationStyle, currentId_emoji, currentId_sticker}) {
|
function createEmojiSquare({internalId, data, animationStyle, currentId_emoji, currentId_sticker}) {
|
||||||
var div = document.createElement("div");
|
var div = document.createElement("div");
|
||||||
@ -357,6 +326,22 @@ function createEmojiSquare({internalId, data, animationStyle, currentId_emoji, c
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
async function loadToggleState() {
|
||||||
|
console.debug("loadToggleState");
|
||||||
|
try {
|
||||||
|
var elements = document.querySelectorAll(".emojisquare");
|
||||||
|
if (elements.length === 0) return;
|
||||||
|
var currentFiles = await callContentScript("getFiles", mode);
|
||||||
|
var active = currentFiles?.map(e => e.id);
|
||||||
|
elements.forEach(e => {
|
||||||
|
e.dataset.state = active.includes(e.dataset["currentId_"+mode]) ? "enabled" : "disabled";
|
||||||
|
});
|
||||||
|
errorDiv.innerText = "";
|
||||||
|
} catch (error) {
|
||||||
|
displayError(error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
onfocus = loadToggleState;
|
||||||
|
|
||||||
|
|
||||||
function displayError(error) {
|
function displayError(error) {
|
||||||
|
Loading…
Reference in New Issue
Block a user