mirror of
https://github.com/BetterSEQTA/BetterSEQTA-Plus.git
synced 2026-06-06 11:44:40 +00:00
prepare for release
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user