feat: implement persistence for settings and indicators

This commit is contained in:
DiTus
2026-03-20 08:32:52 +01:00
parent 5efd652456
commit 5624e3a8b7
2 changed files with 86 additions and 3 deletions

View File

@ -140,7 +140,10 @@ export class TradingDashboard {
constructor() {
this.chart = null;
this.candleSeries = null;
this.currentInterval = '1d';
// Load settings from local storage or defaults
this.symbol = localStorage.getItem('winterfail_symbol') || 'BTC';
this.currentInterval = localStorage.getItem('winterfail_interval') || '1d';
this.intervals = INTERVALS;
this.allData = new Map();
this.isLoading = false;
@ -164,7 +167,7 @@ constructor() {
let candles = this.allData.get(interval);
if (!candles || candles.length < 125) {
const response = await fetch(`${window.APP_CONFIG.API_BASE_URL}/candles?symbol=BTC&interval=${interval}&limit=1000`);
const response = await fetch(`${window.APP_CONFIG.API_BASE_URL}/candles?symbol=${this.symbol}&interval=${interval}&limit=1000`);
const data = await response.json();
if (data.candles && data.candles.length > 0) {
candles = data.candles.reverse().map(c => ({
@ -1044,6 +1047,7 @@ switchTimeframe(interval) {
const oldInterval = this.currentInterval;
this.currentInterval = interval;
localStorage.setItem('winterfail_interval', interval); // Save setting
this.hasInitialLoad = false;
document.querySelectorAll('.timeframe-btn').forEach(btn => {