From 4a0dd5798932524adc2f76df6089d96525e2b300 Mon Sep 17 00:00:00 2001 From: retrozinndev Date: Sat, 1 Mar 2025 17:11:51 -0300 Subject: [PATCH] :boom: fix(control-center/tile): correct usage of subscribe method --- ags/widget/control-center/tiles/Tile.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/ags/widget/control-center/tiles/Tile.ts b/ags/widget/control-center/tiles/Tile.ts index f60ca82..145e725 100644 --- a/ags/widget/control-center/tiles/Tile.ts +++ b/ags/widget/control-center/tiles/Tile.ts @@ -18,8 +18,10 @@ export function Tile(props: TileProps): Widget.EventBox { const toggled = new Variable(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)) =>