/
findly_project
/
FindlyWeb
Обзор
Документация
Войти
/
findly_project
/
FindlyWeb
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
main
src/modules/storage.js
53 строки
1 KB
kolo
some fix
24 июн 2025, 16:20
24 июн 2025, 16:20
88a803e
Код
Авторство
О чём код?
export class StorageManager { constructor(app) { this.app = app; } saveStateToLocalStorage() { const state = { maxSize: this.app.maxSize, filters: this.app.filters, }; localStorage.setItem('findlyAppState', JSON.stringify(state)); } loadStateFromLocalStorage() { const savedStateJSON = localStorage.getItem('findlyAppState'); if (savedStateJSON) { const savedState = JSON.parse(savedStateJSON); this.app.maxSize = savedState.maxSize ?? this.app.constructor.DEFAULT_MAX_SIZE; const defaultFilters = { onlyNew: false, nameFilter: false, priceFilter: false, tolerance: 0.25, excludeWords: [], excludedMarketplaces: [] }; this.app.filters = { ...defaultFilters, ...(savedState.filters || {}) }; } } addExcludeWord() { const input = this.app.elements['exclude-word-input']; const word = input.value.trim(); const validation = this.app.validation.validateExcludeWord(word); if (!validation.isValid) { this.app.ui.showToast(validation.message, 1500); return; } this.app.filters.excludeWords.push(word); this.app.ui.renderExcludeWords(); this.saveStateToLocalStorage(); input.value = ''; } removeExcludeWord(word) { this.app.filters.excludeWords = this.app.filters.excludeWords.filter(w => w !== word); this.app.ui.renderExcludeWords(); this.saveStateToLocalStorage(); } }