2022-04-13 19:19:32 +00:00
|
|
|
import { defineStore } from 'pinia';
|
|
|
|
|
2022-04-19 18:07:59 +00:00
|
|
|
import { getCurrentTheme, getTheme } from '@/shared/themes';
|
2022-04-19 18:20:46 +00:00
|
|
|
import axios from 'axios';
|
|
|
|
import { UiVersion } from '@/types';
|
2022-12-06 05:59:24 +00:00
|
|
|
import { FtWsMessageTypes } from '@/types/wsMessageTypes';
|
2022-04-13 19:19:32 +00:00
|
|
|
|
|
|
|
const STORE_UI_SETTINGS = 'ftUISettings';
|
|
|
|
|
|
|
|
export enum OpenTradeVizOptions {
|
|
|
|
showPill = 'showPill',
|
|
|
|
asTitle = 'asTitle',
|
|
|
|
noOpenTrades = 'noOpenTrades',
|
|
|
|
}
|
|
|
|
|
2022-12-06 05:59:24 +00:00
|
|
|
const notificationDefaults = {
|
|
|
|
[FtWsMessageTypes.entryFill]: true,
|
|
|
|
[FtWsMessageTypes.exitFill]: true,
|
|
|
|
[FtWsMessageTypes.entryCancel]: true,
|
|
|
|
[FtWsMessageTypes.exitCancel]: true,
|
|
|
|
};
|
|
|
|
|
2022-04-13 19:19:32 +00:00
|
|
|
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
|
|
|
currentTheme: getCurrentTheme(),
|
2022-04-19 18:20:46 +00:00
|
|
|
uiVersion: 'dev',
|
2022-07-11 14:33:47 +00:00
|
|
|
useHeikinAshiCandles: false,
|
2022-12-06 05:59:24 +00:00
|
|
|
notifications: notificationDefaults,
|
2022-12-06 06:10:40 +00:00
|
|
|
profitDistributionBins: 20,
|
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: {
|
2022-04-19 18:20:46 +00:00
|
|
|
async loadUIVersion() {
|
|
|
|
if (import.meta.env.PROD) {
|
|
|
|
try {
|
|
|
|
const result = await axios.get<UiVersion>('/ui_version');
|
|
|
|
const { version } = result.data;
|
|
|
|
this.uiVersion = version;
|
|
|
|
} catch (error) {
|
|
|
|
//
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
2022-04-13 19:19:32 +00:00
|
|
|
},
|
|
|
|
persist: {
|
|
|
|
key: STORE_UI_SETTINGS,
|
|
|
|
},
|
|
|
|
});
|