Fix service based variables. (#565)

This commit is contained in:
Jas Singh
2024-12-20 21:17:06 -08:00
committed by GitHub
parent 49288718cb
commit 0101f242e6
2 changed files with 10 additions and 6 deletions

View File

@@ -4,15 +4,17 @@ import Menu from 'src/components/shared/Menu';
import MenuItem from 'src/components/shared/MenuItem';
import { hyprlandService } from 'src/lib/constants/services';
import { isRecording } from '../helpers';
const monitorList = Variable(hyprlandService?.monitors || []);
hyprlandService.connect('monitor-added', () => monitorList.set(hyprlandService.monitors));
hyprlandService.connect('monitor-removed', () => monitorList.set(hyprlandService.monitors));
import AstalHyprland from 'gi://AstalHyprland?version=0.1';
const MonitorListDropdown = (): JSX.Element => {
const monitorList: Variable<AstalHyprland.Monitor[]> = Variable([]);
const monitorBinding = Variable.derive([bind(hyprlandService, 'monitors')], () =>
monitorList.set(hyprlandService.monitors),
);
return (
<Menu className={'dropdown recording'} halign={Gtk.Align.FILL} hexpand>
<Menu className={'dropdown recording'} halign={Gtk.Align.FILL} onDestroy={() => monitorBinding.drop()} hexpand>
{bind(monitorList).as((monitors) => {
return monitors.map((monitor) => (
<MenuItem