Skip to content

A local-first personal finance app

Do not show undo notifications on desktop (#4097)

Robert Dyer7c2408daa657
diff --git a/packages/desktop-client/src/hooks/useUndo.ts b/packages/desktop-client/src/hooks/useUndo.ts
index 4101f668c1..0ab580f44f 100644
--- a/packages/desktop-client/src/hooks/useUndo.ts
+++ b/packages/desktop-client/src/hooks/useUndo.ts
@@ -4,6 +4,8 @@ import { useDispatch } from 'react-redux';
import { undo, redo, addNotification } from 'loot-core/client/actions';
import { type Notification } from 'loot-core/client/state-types/notifications';
+import { useResponsive } from '../components/responsive/ResponsiveProvider';
+
type UndoActions = {
undo: () => void;
redo: () => void;
@@ -15,6 +17,7 @@ const timeout = 10000;
export function useUndo(): UndoActions {
const dispatch = useDispatch();
+ const { isNarrowWidth } = useResponsive();
const dispatchUndo = useCallback(() => {
dispatch(undo());
@@ -26,6 +29,10 @@ export function useUndo(): UndoActions {
const showUndoNotification = useCallback(
(notification: Notification) => {
+ if (!isNarrowWidth) {
+ return;
+ }
+
dispatch(
addNotification({
type: 'message',
@@ -38,11 +45,15 @@ export function useUndo(): UndoActions {
}),
);
},
- [dispatch, dispatchUndo],
+ [dispatch, dispatchUndo, isNarrowWidth],
);
const showRedoNotification = useCallback(
- (notificaton: Notification) => {
+ (notification: Notification) => {
+ if (!isNarrowWidth) {
+ return;
+ }
+
dispatch(
addNotification({
type: 'message',
@@ -51,11 +62,11 @@ export function useUndo(): UndoActions {
title: 'Redo',
action: dispatchRedo,
},
- ...notificaton,
+ ...notification,
}),
);
},
- [dispatch, dispatchRedo],
+ [dispatch, dispatchRedo, isNarrowWidth],
);
return {
diff --git a/upcoming-release-notes/4097.md b/upcoming-release-notes/4097.md
new file mode 100644
index 0000000000..db4c002a64
--- /dev/null
+++ b/upcoming-release-notes/4097.md
@@ -0,0 +1,6 @@
+---
+category: Enhancements
+authors: [psybers]
+---
+
+Do not show undo/redo notifications on desktop.