2022-04-13 19:19:32 +00:00
|
|
|
import { defineStore } from 'pinia';
|
|
|
|
|
|
|
|
import { setTimezone } from '@/shared/formatters';
|
2022-04-19 18:07:59 +00:00
|
|
|
import { getCurrentTheme, getTheme } from '@/shared/themes';
|
2022-04-13 19:19:32 +00:00
|
|
|
|
|
|
|
const STORE_UI_SETTINGS = 'ftUISettings';
|
|
|
|
|
|
|
|
export enum OpenTradeVizOptions {
|
|
|
|
showPill = 'showPill',
|
|
|
|
asTitle = 'asTitle',
|
|
|
|
noOpenTrades = 'noOpenTrades',
|
|
|
|
}
|
|
|
|
|
|
|
|
export interface SettingsType {
|
|
|
|
openTradesInTitle?: string;
|
|
|
|
timezone?: string;
|
|
|
|
backgroundSync?: boolean;
|
|
|
|
}
|
|
|
|
|
|
|
|
export const useSettingsStore = defineStore('uiSettings', {
|
|
|
|
// other options...
|
|
|
|
state: () => {
|
|
|
|
return {
|
|
|
|
openTradesInTitle: OpenTradeVizOptions.showPill as string,
|
|
|
|
timezone: 'UTC',
|
|
|
|
backgroundSync: true,
|
2022-04-19 18:07:59 +00:00
|
|
|
// TODO: needs proper migration ...
|
|
|
|
currentTheme: getCurrentTheme(),
|
2022-04-13 19:19:32 +00:00
|
|
|
};
|
|
|
|
},
|
2022-04-19 18:07:59 +00:00
|
|
|
getters: {
|
|
|
|
isDarkTheme(state) {
|
|
|
|
const theme = getTheme(state.currentTheme);
|
|
|
|
if (theme) {
|
|
|
|
return theme.dark;
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
},
|
|
|
|
chartTheme(): string {
|
|
|
|
return this.isDarkTheme ? 'dark' : 'light';
|
|
|
|
},
|
|
|
|
},
|
2022-04-13 19:19:32 +00:00
|
|
|
actions: {
|
|
|
|
setOpenTradesInTitle(locked: string) {
|
|
|
|
this.openTradesInTitle = locked;
|
|
|
|
},
|
|
|
|
setTimeZone(timezone: string) {
|
|
|
|
setTimezone(timezone);
|
|
|
|
this.timezone = timezone;
|
|
|
|
},
|
|
|
|
setBackgroundSync(value: boolean) {
|
|
|
|
this.backgroundSync = value;
|
|
|
|
},
|
|
|
|
},
|
|
|
|
persist: {
|
|
|
|
key: STORE_UI_SETTINGS,
|
|
|
|
},
|
|
|
|
});
|