mirror of
https://github.com/tiddly-gittly/TidGi-Desktop.git
synced 2026-01-16 22:31:25 -08:00
refactor: notification listeners
This commit is contained in:
parent
81b19a362a
commit
bb7cc2af04
3 changed files with 6 additions and 12 deletions
|
|
@ -132,8 +132,8 @@ const DialogPauseNotifications = (props: DialogPauseNotificationsProps) => {
|
|||
},
|
||||
];
|
||||
|
||||
const pauseNotif = (tilDate: any) => {
|
||||
requestSetPreference('pauseNotifications', `pause:${tilDate.toString()}`);
|
||||
const pauseNotification = (tilDate: Date): void => {
|
||||
void window.service.preference.set('pauseNotifications', `pause:${tilDate.toString()}`);
|
||||
void window.service.notification.show({
|
||||
title: 'Notifications paused',
|
||||
body: `Notifications paused until ${formatDate(tilDate)}.`,
|
||||
|
|
@ -182,7 +182,7 @@ const DialogPauseNotifications = (props: DialogPauseNotificationsProps) => {
|
|||
</ListItem>
|
||||
}>
|
||||
{quickShortcuts.map((shortcut) => (
|
||||
<MenuItem dense key={shortcut.name} onClick={() => pauseNotif(shortcut.calcDate())}>
|
||||
<MenuItem dense key={shortcut.name} onClick={() => pauseNotification(shortcut.calcDate())}>
|
||||
{shortcut.name}
|
||||
</MenuItem>
|
||||
))}
|
||||
|
|
@ -209,7 +209,7 @@ const DialogPauseNotifications = (props: DialogPauseNotificationsProps) => {
|
|||
return (
|
||||
<List dense className={classes.list} disablePadding subheader={<ListSubheader component="div">Pause notifications</ListSubheader>}>
|
||||
{quickShortcuts.map((shortcut) => (
|
||||
<ListItem button key={shortcut.name} onClick={() => pauseNotif(shortcut.calcDate())}>
|
||||
<ListItem button key={shortcut.name} onClick={() => pauseNotification(shortcut.calcDate())}>
|
||||
<ListItemText primary={shortcut.name} />
|
||||
</ListItem>
|
||||
))}
|
||||
|
|
@ -236,7 +236,7 @@ const DialogPauseNotifications = (props: DialogPauseNotificationsProps) => {
|
|||
<DateTimePicker
|
||||
value={new Date()}
|
||||
renderInput={(dateTimeProps) => <TextField className={classes.hidden} {...dateTimeProps} />}
|
||||
onChange={pauseNotif}
|
||||
onChange={pauseNotification}
|
||||
label="Custom"
|
||||
open={showDateTimePicker}
|
||||
onOpen={() => onUpdateShowDateTimePicker(true)}
|
||||
|
|
|
|||
|
|
@ -12,10 +12,6 @@ export const getShouldUseDarkColors = async (): Promise<void> => {
|
|||
await ipcRenderer.invoke('get-should-use-dark-colors');
|
||||
};
|
||||
|
||||
// Notifications
|
||||
export const requestUpdatePauseNotificationsInfo = async () => await ipcRenderer.invoke('request-update-pause-notifications-info');
|
||||
export const getPauseNotificationsInfo = () => ipcRenderer.invokeSync('get-pause-notifications-info');
|
||||
|
||||
// Preferences
|
||||
export const requestSetPreference = async (name: string, value: JsonValue) => await ipcRenderer.invoke('request-set-preference', name, value);
|
||||
export const requestResetPreferences = async () => await ipcRenderer.invoke('request-reset-preferences');
|
||||
|
|
|
|||
|
|
@ -2,8 +2,6 @@ import { combineReducers } from 'redux';
|
|||
|
||||
import { UPDATE_PAUSE_NOTIFICATIONS_INFO, UPDATE_SHOW_DATE_TIME_PICKER } from '../../constants/actions';
|
||||
|
||||
import { getPauseNotificationsInfo } from '../../senders';
|
||||
|
||||
const showDateTimePicker = (state = false, action: any) => {
|
||||
switch (action.type) {
|
||||
case UPDATE_SHOW_DATE_TIME_PICKER: {
|
||||
|
|
@ -15,7 +13,7 @@ const showDateTimePicker = (state = false, action: any) => {
|
|||
}
|
||||
};
|
||||
|
||||
const pauseNotificationsInfo = (state = getPauseNotificationsInfo(), action: any) => {
|
||||
const pauseNotificationsInfo = (state = await window.service.notification.getPauseNotificationsInfo(), action: any) => {
|
||||
switch (action.type) {
|
||||
case UPDATE_PAUSE_NOTIFICATIONS_INFO: {
|
||||
return action.pauseNotificationsInfo;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue