mirror of
https://github.com/HSLdevcom/digitransit-ui
synced 2025-09-20 20:32:47 +02:00
34 lines
872 B
JavaScript
34 lines
872 B
JavaScript
import Store from 'fluxible/addons/BaseStore';
|
|
import {
|
|
getSearchSettingsStorage,
|
|
setSearchSettingsStorage,
|
|
} from './localStorage';
|
|
|
|
class RoutingSettingsStore extends Store {
|
|
static storeName = 'RoutingSettingsStore';
|
|
|
|
// eslint-disable-next-line class-methods-use-this
|
|
getRoutingSettings() {
|
|
let settings = getSearchSettingsStorage();
|
|
|
|
if (!settings) {
|
|
settings = {};
|
|
setSearchSettingsStorage(settings);
|
|
}
|
|
return settings;
|
|
}
|
|
|
|
saveRoutingSettings(changedSettings) {
|
|
const oldSettings = this.getRoutingSettings();
|
|
const newSettings = { ...oldSettings, ...changedSettings };
|
|
setSearchSettingsStorage(newSettings);
|
|
this.emitChange(changedSettings);
|
|
}
|
|
|
|
static handlers = {
|
|
saveRoutingSettings: 'saveRoutingSettings',
|
|
getRoutingSettings: 'getRoutingSettings',
|
|
};
|
|
}
|
|
|
|
export default RoutingSettingsStore;
|