Improve workspace module performance. (#430)

* Move out rule fetching to on startup

* Discard null tray values
This commit is contained in:
Jas Singh
2024-11-03 20:23:55 -08:00
committed by GitHub
parent 9287e1d6a4
commit c8e657f3f9
2 changed files with 5 additions and 5 deletions

View File

@@ -12,7 +12,7 @@ const SysTray = (): BarBoxChild => {
const items = Utils.merge( const items = Utils.merge(
[systemtray.bind('items'), ignore.bind('value'), customIcons.bind('value')], [systemtray.bind('items'), ignore.bind('value'), customIcons.bind('value')],
(items, ignored, custIcons) => { (items, ignored, custIcons) => {
const filteredTray = items.filter(({ id }) => !ignored.includes(id)); const filteredTray = items.filter(({ id }) => !ignored.includes(id) && id !== null);
isVis.value = filteredTray.length > 0; isVis.value = filteredTray.length > 0;

View File

@@ -9,6 +9,7 @@ import { WorkspaceIconMap } from 'lib/types/workspace';
const { workspaces, monitorSpecific, workspaceMask, spacing, ignored, showAllActive } = options.bar.workspaces; const { workspaces, monitorSpecific, workspaceMask, spacing, ignored, showAllActive } = options.bar.workspaces;
export const occupiedWses = (monitor: number): BoxWidget => { export const occupiedWses = (monitor: number): BoxWidget => {
const workspaceRules = getWorkspaceRules();
return Widget.Box({ return Widget.Box({
children: Utils.merge( children: Utils.merge(
[ [
@@ -61,9 +62,7 @@ export const occupiedWses = (monitor: number): BoxWidget => {
) => { ) => {
const activeId = hyprland.active.workspace.id; const activeId = hyprland.active.workspace.id;
let allWkspcs = range(totalWkspcs || 8); let allWkspcs = range(totalWkspcs || 8);
const activeWorkspaces = wkSpaces.map((w) => w.id); const activeWorkspaces = wkSpaces.map((w) => w.id);
const workspaceRules = getWorkspaceRules();
// Sometimes hyprland doesn't have all the monitors in the list // Sometimes hyprland doesn't have all the monitors in the list
// so we complement it with monitors from the workspace list // so we complement it with monitors from the workspace list
@@ -77,7 +76,7 @@ export const occupiedWses = (monitor: number): BoxWidget => {
const workspacesWithRules = Object.keys(workspaceRules).reduce((acc: number[], k: string) => { const workspacesWithRules = Object.keys(workspaceRules).reduce((acc: number[], k: string) => {
return [...acc, ...workspaceRules[k]]; return [...acc, ...workspaceRules[k]];
}, [] as number[]); }, []);
const activesForMonitor = activeWorkspaces.filter((w) => { const activesForMonitor = activeWorkspaces.filter((w) => {
if ( if (
@@ -99,7 +98,7 @@ export const occupiedWses = (monitor: number): BoxWidget => {
allWkspcs = [...new Set([...allWkspcs, ...activeWorkspaces])]; allWkspcs = [...new Set([...allWkspcs, ...activeWorkspaces])];
} }
return allWkspcs const returnWs = allWkspcs
.sort((a, b) => { .sort((a, b) => {
return a - b; return a - b;
}) })
@@ -159,6 +158,7 @@ export const occupiedWses = (monitor: number): BoxWidget => {
}), }),
}); });
}); });
return returnWs;
}, },
), ),
}); });