2021-01-13 13:58:10 -08:00
|
|
|
import { ThemePreference } from "../reducers/settingsReducer";
|
2021-04-10 06:36:20 -07:00
|
|
|
import { DailyStatsKey } from "../views/DashboardView";
|
2020-11-24 06:54:00 -08:00
|
|
|
// List of settings related action types.
|
2021-01-13 13:58:10 -08:00
|
|
|
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";
|
2021-04-09 16:28:01 -07:00
|
|
|
export const TASK_ROWS_PER_PAGE_CHANGE = "TASK_ROWS_PER_PAGE_CHANGE";
|
2021-04-10 06:36:20 -07:00
|
|
|
export const DAILY_STATS_KEY_CHANGE = "DAILY_STATS_KEY_CHANGE";
|
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 {
|
2021-01-13 13:58:10 -08:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2021-04-09 16:28:01 -07:00
|
|
|
interface TaskRowsPerPageChange {
|
|
|
|
type: typeof TASK_ROWS_PER_PAGE_CHANGE;
|
|
|
|
value: number;
|
|
|
|
}
|
|
|
|
|
2021-04-10 06:36:20 -07:00
|
|
|
interface DailyStatsKeyChange {
|
|
|
|
type: typeof DAILY_STATS_KEY_CHANGE;
|
|
|
|
value: DailyStatsKey;
|
|
|
|
}
|
|
|
|
|
2020-11-24 06:54:00 -08:00
|
|
|
// Union of all settings related action types.
|
2021-01-13 13:58:10 -08:00
|
|
|
export type SettingsActionTypes =
|
|
|
|
| PollIntervalChangeAction
|
2021-01-22 22:26:04 -08:00
|
|
|
| ThemePreferenceChangeAction
|
2021-04-09 16:28:01 -07:00
|
|
|
| ToggleDrawerAction
|
2021-04-10 06:36:20 -07:00
|
|
|
| TaskRowsPerPageChange
|
|
|
|
| DailyStatsKeyChange;
|
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
|
|
|
|
2021-01-13 13:58:10 -08:00
|
|
|
export function selectTheme(value: ThemePreference) {
|
2021-01-12 15:55:56 -08:00
|
|
|
return {
|
2021-01-13 13:58:10 -08:00
|
|
|
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 };
|
|
|
|
}
|
2021-04-09 16:28:01 -07:00
|
|
|
|
|
|
|
export function taskRowsPerPageChange(value: number) {
|
|
|
|
return {
|
|
|
|
type: TASK_ROWS_PER_PAGE_CHANGE,
|
|
|
|
value,
|
|
|
|
};
|
|
|
|
}
|
2021-04-10 06:36:20 -07:00
|
|
|
|
|
|
|
export function dailyStatsKeyChange(value: DailyStatsKey) {
|
|
|
|
return {
|
|
|
|
type: DAILY_STATS_KEY_CHANGE,
|
|
|
|
value,
|
|
|
|
}
|
|
|
|
}
|