less nesting

This commit is contained in:
end-4
2024-01-29 12:06:44 +07:00
parent 1a06184ec8
commit dc5aa31732
@@ -236,56 +236,51 @@ const arr = (s, n) => {
return array; return array;
}; };
const OverviewRow = ({ startWorkspace, workspaces, windowName = 'overview' }) => { const OverviewRow = ({ startWorkspace, workspaces, windowName = 'overview' }) => Widget.Box({
return Widget.Box({ children: arr(startWorkspace, workspaces).map(Workspace),
children: arr(startWorkspace, workspaces).map(Workspace), attribute: {
attribute: { update: box => {
update: box => { if (!App.getWindow(windowName).visible) return;
if (!App.getWindow(windowName).visible) return; execAsync('hyprctl -j clients').then(clients => {
execAsync('hyprctl -j clients').then(clients => { const json = JSON.parse(clients);
const json = JSON.parse(clients); const children = box.get_children();
const children = box.get_children(); for (let i = 0; i < children.length; i++) {
for (let i = 0; i < children.length; i++) { const ch = children[i];
const ch = children[i]; ch.update(json)
ch.update(json) }
}
}).catch(print); }).catch(print);
} }
}, },
setup: (box) => box setup: (box) => box
.hook(overviewTick, (box) => box.attribute.update(box)) .hook(overviewTick, (box) => box.attribute.update(box))
// .hook(Hyprland, (box, name, data) => { // idk, does this make it lag occasionally? // .hook(Hyprland, (box, name, data) => { // idk, does this make it lag occasionally?
// console.log(name) // console.log(name)
// if (["changefloatingmode", "movewindow"].includes(name)) // if (["changefloatingmode", "movewindow"].includes(name))
// box.attribute.update(box); // box.attribute.update(box);
// }, 'event') // }, 'event')
.hook(Hyprland, (box) => box.attribute.update(box), 'client-removed') .hook(Hyprland, (box) => box.attribute.update(box), 'client-removed')
.hook(Hyprland, (box) => box.attribute.update(box), 'client-added') .hook(Hyprland, (box) => box.attribute.update(box), 'client-added')
.hook(Hyprland.active.workspace, (box) => box.attribute.update(box)) .hook(Hyprland.active.workspace, (box) => box.attribute.update(box))
.hook(App, (box, name, visible) => { // Update on open .hook(App, (box, name, visible) => { // Update on open
if (name == 'overview' && visible) box.attribute.update(box); if (name == 'overview' && visible) box.attribute.update(box);
})
,
});
export default () => Widget.Revealer({
revealChild: true,
transition: 'slide_down',
transitionDuration: 200,
child: Widget.Box({
vertical: true,
className: 'overview-tasks',
children: Array.from({ length: NUM_OF_WORKSPACE_ROWS }, (_, index) =>
OverviewRow({
startWorkspace: 1 + index * NUM_OF_WORKSPACE_COLS,
workspaces: NUM_OF_WORKSPACE_COLS
}) })
, )
}); }),
} });
export default () => {
const overviewRevealer = Widget.Revealer({
revealChild: true,
transition: 'slide_down',
transitionDuration: 200,
child: Widget.Box({
vertical: true,
className: 'overview-tasks',
children: Array.from({ length: NUM_OF_WORKSPACE_ROWS }, (_, index) =>
OverviewRow({
startWorkspace: 1 + index * NUM_OF_WORKSPACE_COLS,
workspaces: NUM_OF_WORKSPACE_COLS
})
)
}),
});
return overviewRevealer;
};