asynqmon/ui/src/actions/settingsActions.ts

44 lines
1.0 KiB
TypeScript
Raw Normal View History

import { ThemePreference } from "../reducers/settingsReducer";
2020-11-24 06:54:00 -08:00
// List of settings related action types.
export const POLL_INTERVAL_CHANGE = "POLL_INTERVAL_CHANGE";
export const THEME_PREFERENCE_CHANGE = "THEME_PREFERENCE_CHANGE";
2021-01-22 22:26:04 -08:00
export const TOGGLE_DRAWER = "TOGGLE_DRAWER";
2020-11-24 06:54:00 -08:00
interface PollIntervalChangeAction {
type: typeof POLL_INTERVAL_CHANGE;
value: number; // new poll interval value in seconds
}
2021-01-22 22:26:04 -08:00
interface ThemePreferenceChangeAction {
type: typeof THEME_PREFERENCE_CHANGE;
value: ThemePreference;
2021-01-12 15:55:56 -08:00
}
2021-01-22 22:26:04 -08:00
interface ToggleDrawerAction {
type: typeof TOGGLE_DRAWER;
}
2020-11-24 06:54:00 -08:00
// Union of all settings related action types.
export type SettingsActionTypes =
| PollIntervalChangeAction
2021-01-22 22:26:04 -08:00
| ThemePreferenceChangeAction
| ToggleDrawerAction;
2020-11-24 06:54:00 -08:00
export function pollIntervalChange(value: number) {
return {
type: POLL_INTERVAL_CHANGE,
value,
};
}
2021-01-12 15:55:56 -08:00
export function selectTheme(value: ThemePreference) {
2021-01-12 15:55:56 -08:00
return {
type: THEME_PREFERENCE_CHANGE,
value,
};
2021-01-12 15:55:56 -08:00
}
2021-01-22 22:26:04 -08:00
export function toggleDrawer() {
return { type: TOGGLE_DRAWER };
}