prepare for release

This commit is contained in:
SethBurkart123
2023-10-11 12:20:41 +11:00
parent 7a672b1b1b
commit 5abb0b08f6
16 changed files with 324 additions and 114 deletions
+59 -2
View File
@@ -1,11 +1,15 @@
/* global chrome */
import {
CreateBackground,
CreateCustomShortcutDiv,
RemoveCustomShortcutDiv,
RemoveBackground,
RemoveShortcutDiv,
addShortcuts,
disableNotificationCollector,
enableNotificationCollector,
} from "../../SEQTA.js";
import { updateBgDurations } from "../ui/Animation.js";
import { updateAllColors } from "../ui/Colors.js";
export default class StorageListener {
@@ -18,6 +22,13 @@ export default class StorageListener {
this.handleSelectedColorChange(changes.selectedColor.newValue);
}
if (changes.shortcuts) {
this.handleShortcutsChange(
changes.shortcuts.oldValue,
changes.shortcuts.newValue
);
}
if (changes?.customshortcuts?.newValue) {
this.handleCustomShortcutsChange(
changes.customshortcuts.oldValue,
@@ -28,6 +39,19 @@ export default class StorageListener {
if (changes.notificationcollector) {
this.handleNotificationCollectorChange(changes.notificationcollector);
}
if (changes.bksliderinput) {
updateBgDurations(changes.bksliderinput.newValue);
}
if (changes.animatedbk !== undefined) {
if (changes.animatedbk.newValue) {
CreateBackground();
} else {
RemoveBackground();
document.getElementById("container").style.background = "var(--background-secondary)";
}
}
}
handleSelectedColorChange(newColor) {
@@ -61,8 +85,41 @@ export default class StorageListener {
);
if (removedElement) {
RemoveCustomShortcutDiv(removedElement);
RemoveShortcutDiv(removedElement);
}
}
}
handleShortcutsChange(oldValue, newValue) {
// Find Added Shortcuts
const addedShortcuts = newValue.filter(newItem => {
const isAdded = oldValue.some(oldItem => {
const match = oldItem.name === newItem.name;
const wasDisabled = !oldItem.enabled;
const isEnabled = newItem.enabled;
return match && wasDisabled && isEnabled;
});
return isAdded;
});
// Find Removed Shortcuts
const removedShortcuts = newValue.filter(newItem => {
const isRemoved = oldValue.some(oldItem => {
const match = oldItem.name === newItem.name;
const wasEnabled = oldItem.enabled; // Was enabled in the old array
const isDisabled = !newItem.enabled; // Is disabled in the new array
return match && wasEnabled && isDisabled;
});
return isRemoved;
});
// Add new shortcuts to the UI
addShortcuts(addedShortcuts);
// Remove deleted shortcuts from the UI
RemoveShortcutDiv(removedShortcuts);
}
}