💥 fix(control-center/tile): correct usage of subscribe method

This commit is contained in:
retrozinndev
2025-03-01 17:11:51 -03:00
parent f197052f7f
commit 4a0dd57989
+4 -1
View File
@@ -18,8 +18,10 @@ export function Tile(props: TileProps): Widget.EventBox {
const toggled = new Variable<boolean>(props.toggleState instanceof Binding ?
(props.toggleState.get() || false) : (props.toggleState || false));
let subscription: () => void;
if(props?.toggleState instanceof Binding)
props.toggleState.subscribe(val => toggled.set(val || false))();
subscription = props.toggleState.subscribe(val => toggled.set(val || false));
return new Widget.EventBox({
className: toggled().as((state: boolean) =>
@@ -36,6 +38,7 @@ export function Tile(props: TileProps): Widget.EventBox {
toggled.set(true);
props.onToggledOn && props.onToggledOn();
},
onDestroy: () => subscription(),
child: new Widget.Box({
className: (props.className instanceof Binding) ?
props.className.as((clsName: (string|undefined)) =>