Skip to content

Commit cdb63f8

Browse files
committed
Fix scanlines toggle
1 parent 570462c commit cdb63f8

File tree

1 file changed

+6
-10
lines changed

1 file changed

+6
-10
lines changed

src/components/Television.astro

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -41,25 +41,20 @@ const { activeProgram, channelId, channelName } = Astro.props;
4141
selector: string,
4242
attribute: string,
4343
defaultValue: string = "0",
44-
detailProperty?: string,
44+
detailProperty: string,
4545
): void {
46-
// Use the specified detail property or fall back to the attribute name without 'data-' prefix
47-
const localStorageKey = detailProperty || attribute.replace("data-", "");
48-
49-
const savedValue = localStorage.getItem(localStorageKey) || defaultValue;
46+
const savedValue = localStorage.getItem(detailProperty) || defaultValue;
5047
setAttributeOnElement(selector, attribute, savedValue);
5148
}
5249

5350
function createEventListener(
5451
eventName: string,
5552
selector: string,
5653
attribute: string,
57-
detailProperty?: string,
54+
detailProperty: string,
5855
): void {
5956
document.addEventListener(eventName, ((e: CustomEvent) => {
60-
// Use the specified detail property or fall back to the attribute name without 'data-' prefix
61-
const propertyName = detailProperty || attribute.replace("data-", "");
62-
const value = e.detail[propertyName];
57+
const value = e.detail[detailProperty];
6358
setAttributeOnElement(selector, attribute, value);
6459
}) as EventListener);
6560
}
@@ -70,7 +65,7 @@ const { activeProgram, channelId, channelName } = Astro.props;
7065
selector: ".scanlines",
7166
attribute: "data-active",
7267
defaultValue: "true",
73-
detailProperty: "enabled",
68+
detailProperty: "scanlines",
7469
},
7570
{
7671
event: "brightnessChange",
@@ -111,6 +106,7 @@ const { activeProgram, channelId, channelName } = Astro.props;
111106
setting.selector,
112107
setting.attribute,
113108
setting.defaultValue,
109+
setting.detailProperty,
114110
);
115111
});
116112

0 commit comments

Comments
 (0)