Skip to content

Commit

Permalink
fix: use settings store to retrieve useColorFallback setting (#533)
Browse files Browse the repository at this point in the history
* fix: respect landingpage settings (use settings/server store, not localStore)

* fix: use settings store to retrieve useColorFallback setting

* fix: fixed imports
  • Loading branch information
ErikBjare committed Jan 8, 2024
1 parent 845b12f commit 23df3fb
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
5 changes: 4 additions & 1 deletion src/route.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import Vue from 'vue';
import VueRouter from 'vue-router';

import { useSettingsStore } from '~/stores/settings';

const Home = () => import('./views/Home.vue');

// Activity views for desktop
Expand Down Expand Up @@ -30,7 +32,8 @@ const router = new VueRouter({
{
path: '/',
redirect: _to => {
return localStorage.landingpage || '/home';
const settings = useSettingsStore();
return settings.landingpage || '/home';
},
},
{ path: '/home', component: Home },
Expand Down
7 changes: 3 additions & 4 deletions src/util/color.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { Category, matchString, loadClasses } from './classes';
import Color from 'color';
import * as d3 from 'd3';
import { IEvent, IBucket } from './interfaces';
import { useSettingsStore } from '~/stores/settings';

// See here for examples:
// https://bl.ocks.org/pstuffa/3393ff2711a53975040077b7453781a9
Expand Down Expand Up @@ -99,10 +100,8 @@ export function getCategoryColorFromString(str: string): string {

function fallbackColor(str: string): string {
// Get fallback color
// TODO: Fetch setting from somewhere better, where defaults are respected
const useColorFallback =
localStorage !== undefined ? localStorage.useColorFallback === 'true' : true;
if (useColorFallback) {
const settings = useSettingsStore();
if (settings.useColorFallback) {
return getColorFromString(str);
} else {
return COLOR_UNCAT;
Expand Down

2 comments on commit 23df3fb

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here are screenshots of this commit:

Screenshots using aw-server v0.12.3b11 (click to expand)

Screenshots using aw-server-rust master (click to expand)

Screenshots using aw-server-rust v0.12.3b11 (click to expand)

@ErikBjare
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This broke stuff, can't import useSettingsStore in the route.js (I think).

Please sign in to comment.