mirror of
https://github.com/shlinkio/shlink-web-client.git
synced 2026-04-25 16:06:19 +00:00
Created settings page and reducers to handle real-time updates config
This commit is contained in:
14
src/settings/services/SettingsService.js
Normal file
14
src/settings/services/SettingsService.js
Normal file
@@ -0,0 +1,14 @@
|
||||
const SETTINGS_STORAGE_KEY = 'settings';
|
||||
|
||||
export default class SettingsService {
|
||||
constructor(storage) {
|
||||
this.storage = storage;
|
||||
}
|
||||
|
||||
loadSettings = () => this.storage.get(SETTINGS_STORAGE_KEY) || {};
|
||||
|
||||
updateSettings = (settingsToUpdate) => this.storage.set(SETTINGS_STORAGE_KEY, {
|
||||
...this.loadSettings(),
|
||||
...settingsToUpdate,
|
||||
})
|
||||
}
|
||||
21
src/settings/services/provideServices.js
Normal file
21
src/settings/services/provideServices.js
Normal file
@@ -0,0 +1,21 @@
|
||||
import RealTimeUpdates from '../RealTimeUpdates';
|
||||
import Settings from '../Settings';
|
||||
import { loadRealTimeUpdates, setRealTimeUpdates } from '../reducers/realTimeUpdates';
|
||||
import SettingsService from './SettingsService';
|
||||
|
||||
const provideServices = (bottle, connect) => {
|
||||
// Components
|
||||
bottle.serviceFactory('Settings', Settings, 'RealTimeUpdates');
|
||||
|
||||
bottle.serviceFactory('RealTimeUpdates', () => RealTimeUpdates);
|
||||
bottle.decorator('RealTimeUpdates', connect([ 'realTimeUpdates' ], [ 'setRealTimeUpdates' ]));
|
||||
|
||||
// Services
|
||||
bottle.service('SettingsService', SettingsService, 'Storage');
|
||||
|
||||
// Actions
|
||||
bottle.serviceFactory('setRealTimeUpdates', setRealTimeUpdates, 'SettingsService', 'loadRealTimeUpdates');
|
||||
bottle.serviceFactory('loadRealTimeUpdates', loadRealTimeUpdates, 'SettingsService');
|
||||
};
|
||||
|
||||
export default provideServices;
|
||||
Reference in New Issue
Block a user