digitransit-ui/app/store/RoutingSettingsStore.js
Vesa Meskanen e747ee367b fix: refactor badly outdated transport mode handling
UI contained lots of complex code for adding citybike and scooter to transport modes array.
In the end, those were just filtered away before making a request. Most of the old mess
is now cleaned away. There is still some strange code related to availableForSelection config switch;
it should probably be erased as well.
2024-06-27 15:06:42 +03:00

33 lines
856 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();
}
static handlers = {
saveRoutingSettings: 'saveRoutingSettings',
getRoutingSettings: 'getRoutingSettings',
};
}
export default RoutingSettingsStore;