Skip to content

Commit deec992

Browse files
committed
Use useCategoryStore().get_category_color
1 parent 292da10 commit deec992

File tree

2 files changed

+4
-12
lines changed

2 files changed

+4
-12
lines changed

src/util/color.ts

-10
Original file line numberDiff line numberDiff line change
@@ -97,16 +97,6 @@ export function getCategoryColorFromString(str: string): string {
9797
}
9898
}
9999

100-
export function getCategoryColor(category_name: string[]): string {
101-
// TODO: Don't load classes on every call
102-
const allCats = loadClasses();
103-
const c = allCats.find(cat => _.isEqual(cat.name, category_name));
104-
if (c !== undefined) {
105-
return getColorFromCategory(c, allCats);
106-
}
107-
return fallbackColor(category_name.join(' > '));
108-
}
109-
110100
function fallbackColor(str: string): string {
111101
// Get fallback color
112102
// TODO: Fetch setting from somewhere better, where defaults are respected

src/visualizations/summary.ts

+4-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@ import * as d3 from 'd3';
44
import Color from 'color';
55
import _ from 'lodash';
66

7-
import { getCategoryColor, getCategoryColorFromString } from '~/util/color';
7+
import { useCategoryStore } from '~/stores/categories';
8+
import { getCategoryColorFromString } from '~/util/color';
89
import { seconds_to_duration } from '~/util/time';
910
import { IEvent } from '~/util/interfaces';
1011

@@ -73,7 +74,8 @@ function update(container: HTMLElement, apps: Entry[]) {
7374

7475
let appcolor: string;
7576
if (Array.isArray(app.colorKey)) {
76-
appcolor = getCategoryColor(app.colorKey);
77+
const categoryStore = useCategoryStore();
78+
appcolor = categoryStore.get_category_color(app.colorKey);
7779
} else {
7880
appcolor = app.color || getCategoryColorFromString(app.colorKey || app.name);
7981
}

0 commit comments

Comments
 (0)