Skip to content

Commit

Permalink
Update payloads
Browse files Browse the repository at this point in the history
  • Loading branch information
joel-jeremy committed Jan 13, 2025
1 parent a9e7bc3 commit 2384069
Show file tree
Hide file tree
Showing 29 changed files with 336 additions and 226 deletions.
18 changes: 10 additions & 8 deletions packages/desktop-client/src/components/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -125,14 +125,16 @@ function AppInner() {
if (userData?.tokenExpired) {
dispatch(
addNotification({
type: 'error',
id: 'login-expired',
title: t('Login expired'),
sticky: true,
message: t('Login expired, please login again.'),
button: {
title: t('Go to login'),
action: () => dispatch(signOut()),
notification: {
type: 'error',
id: 'login-expired',
title: t('Login expired'),
sticky: true,
message: t('Login expired, please login again.'),
button: {
title: t('Go to login'),
action: () => dispatch(signOut()),
},
},
}),
);
Expand Down
54 changes: 30 additions & 24 deletions packages/desktop-client/src/components/FinancesApp.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -111,15 +111,19 @@ export function FinancesApp() {
await global.Actual.waitForUpdateReadyForDownload();
dispatch(
addNotification({
type: 'message',
title: t('A new version of Actual is available!'),
message: t('Click the button below to reload and apply the update.'),
sticky: true,
id: 'update-reload-notification',
button: {
title: t('Update now'),
action: async () => {
await global.Actual.applyAppUpdate();
notification: {
type: 'message',
title: t('A new version of Actual is available!'),
message: t(
'Click the button below to reload and apply the update.',
),
sticky: true,
id: 'update-reload-notification',
button: {
title: t('Update now'),
action: async () => {
await global.Actual.applyAppUpdate();
},
},
},
}),
Expand All @@ -137,22 +141,24 @@ export function FinancesApp() {
if (isOutdated && lastUsedVersion !== latestVersion) {
dispatch(
addNotification({
type: 'message',
title: t('A new version of Actual is available!'),
message: t(
'Version {{latestVersion}} of Actual was recently released.',
{ latestVersion },
),
sticky: true,
id: 'update-notification',
button: {
title: t('Open changelog'),
action: () => {
window.open('https://actualbudget.org/docs/releases');
notification: {
type: 'message',
title: t('A new version of Actual is available!'),
message: t(
'Version {{latestVersion}} of Actual was recently released.',
{ latestVersion },
),
sticky: true,
id: 'update-notification',
button: {
title: t('Open changelog'),
action: () => {
window.open('https://actualbudget.org/docs/releases');
},
},
onClose: () => {
setLastUsedVersion(latestVersion);
},
},
onClose: () => {
setLastUsedVersion(latestVersion);
},
}),
);
Expand Down
2 changes: 1 addition & 1 deletion packages/desktop-client/src/components/Notifications.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ export function Notifications({ style }: { style?: CSSProperties }) {
if (note.onClose) {
note.onClose();
}
dispatch(removeNotification(note.id));
dispatch(removeNotification({ id: note.id }));
}}
/>
))}
Expand Down
10 changes: 6 additions & 4 deletions packages/desktop-client/src/components/ServerContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -109,9 +109,11 @@ export function ServerProvider({ children }: { children: ReactNode }) {
if ('error' in data) {
dispatch(
addNotification({
type: 'error',
title: t('Failed to refresh login methods'),
message: data.error ?? t('Unknown'),
notification: {
type: 'error',
title: t('Failed to refresh login methods'),
message: data.error ?? t('Unknown'),
},
}),
);
setAvailableLoginMethods([]);
Expand All @@ -121,7 +123,7 @@ export function ServerProvider({ children }: { children: ReactNode }) {
setAvailableLoginMethods([]);
}
}
}, [serverURL]);
}, [dispatch, serverURL]);

useEffect(() => {
if (serverURL) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,11 +87,13 @@ function UserAccessContent({
if ('error' in data) {
dispatch(
addNotification({
type: 'error',
id: 'error',
title: t('Error getting available users'),
sticky: true,
message: data.error,
notification: {
type: 'error',
id: 'error',
title: t('Error getting available users'),
sticky: true,
message: data.error,
},
}),
);
return [];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,14 @@ export const UserAccessRow = memo(
if (someDeletionsFailed) {
dispatch(
addNotification({
type: 'error',
title: t('Access Revocation Incomplete'),
message: t(
'Some access permissions were not revoked successfully.',
),
sticky: true,
notification: {
type: 'error',
title: t('Access Revocation Incomplete'),
message: t(
'Some access permissions were not revoked successfully.',
),
sticky: true,
},
}),
);
}
Expand All @@ -69,26 +71,30 @@ export const UserAccessRow = memo(
if (error === 'token-expired') {
dispatch(
addNotification({
type: 'error',
id: 'login-expired',
title: t('Login expired'),
sticky: true,
message: getUserAccessErrors(error),
button: {
title: t('Go to login'),
action: () => {
dispatch(signOut());
notification: {
type: 'error',
id: 'login-expired',
title: t('Login expired'),
sticky: true,
message: getUserAccessErrors(error),
button: {
title: t('Go to login'),
action: () => {
dispatch(signOut());
},
},
},
}),
);
} else {
dispatch(
addNotification({
type: 'error',
title: t('Something happened while editing access'),
sticky: true,
message: getUserAccessErrors(error),
notification: {
type: 'error',
title: t('Something happened while editing access'),
sticky: true,
message: getUserAccessErrors(error),
},
}),
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,24 +148,28 @@ function UserDirectoryContent({
if (error === 'token-expired') {
dispatch(
addNotification({
type: 'error',
id: 'login-expired',
title: t('Login expired'),
sticky: true,
message: getUserDirectoryErrors(error),
button: {
title: t('Go to login'),
action: () => dispatch(signOut()),
notification: {
type: 'error',
id: 'login-expired',
title: t('Login expired'),
sticky: true,
message: getUserDirectoryErrors(error),
button: {
title: t('Go to login'),
action: () => dispatch(signOut()),
},
},
}),
);
} else {
dispatch(
addNotification({
type: 'error',
title: t('Something happened while deleting users'),
sticky: true,
message: getUserDirectoryErrors(error),
notification: {
type: 'error',
title: t('Something happened while deleting users'),
sticky: true,
message: getUserDirectoryErrors(error),
},
}),
);
}
Expand Down
12 changes: 7 additions & 5 deletions packages/desktop-client/src/components/budget/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -176,11 +176,13 @@ function BudgetInner(props: BudgetInnerProps) {
const categoryNameAlreadyExistsNotification = name => {
dispatch(
addNotification({
type: 'error',
message: t(
'Category ‘{{name}}‘ already exists in group (May be Hidden)',
{ name },
),
notification: {
type: 'error',
message: t(
'Category ‘{{name}}‘ already exists in group (May be Hidden)',
{ name },
),
},
}),
);
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,13 @@ export function OpenIdForm({
if ('error' in config) {
dispatch(
addNotification({
type: 'error',
id: 'error',
title: t('Error getting OpenID config'),
sticky: true,
message: config.error,
notification: {
type: 'error',
id: 'error',
title: t('Error getting OpenID config'),
sticky: true,
message: config.error,
},
}),
);
} else if ('openId' in config) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,9 @@ function SelectedTransactionsFloatingActionBar({ transactions, style }) {

const dispatch = useDispatch();
useEffect(() => {
dispatch(setNotificationInset({ bottom: NOTIFICATION_BOTTOM_INSET }));
dispatch(
setNotificationInset({ inset: { bottom: NOTIFICATION_BOTTOM_INSET } }),
);
return () => {
dispatch(setNotificationInset(null));
};
Expand Down
20 changes: 11 additions & 9 deletions packages/desktop-client/src/components/modals/EditAccess.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -70,15 +70,17 @@ export function EditUserAccess({
if (error === 'token-expired') {
dispatch(
addNotification({
type: 'error',
id: 'login-expired',
title: t('Login expired'),
sticky: true,
message: getUserAccessErrors(error),
button: {
title: t('Go to login'),
action: () => {
dispatch(signOut());
notification: {
type: 'error',
id: 'login-expired',
title: t('Login expired'),
sticky: true,
message: getUserAccessErrors(error),
button: {
title: t('Go to login'),
action: () => {
dispatch(signOut());
},
},
},
}),
Expand Down
20 changes: 11 additions & 9 deletions packages/desktop-client/src/components/modals/EditUser.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -86,15 +86,17 @@ function useSaveUser() {
if (error === 'token-expired') {
dispatch(
addNotification({
type: 'error',
id: 'login-expired',
title: t('Login expired'),
sticky: true,
message: getUserDirectoryErrors(error),
button: {
title: t('Go to login'),
action: () => {
dispatch(signOut());
notification: {
type: 'error',
id: 'login-expired',
title: t('Login expired'),
sticky: true,
message: getUserDirectoryErrors(error),
button: {
title: t('Go to login'),
action: () => {
dispatch(signOut());
},
},
},
}),
Expand Down
28 changes: 16 additions & 12 deletions packages/desktop-client/src/components/modals/TransferOwnership.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,14 @@ export function TransferOwnership({
} else if ('error' in data) {
dispatch(
addNotification({
type: 'error',
title: t('Error getting users'),
message: t(
'Failed to complete ownership transfer. Please try again.',
),
sticky: true,
notification: {
type: 'error',
title: t('Error getting users'),
message: t(
'Failed to complete ownership transfer. Please try again.',
),
sticky: true,
},
}),
);
} else {
Expand Down Expand Up @@ -194,12 +196,14 @@ export function TransferOwnership({
} catch (error) {
dispatch(
addNotification({
type: 'error',
title: t('Failed to transfer ownership'),
message: t(
'Failed to complete ownership transfer. Please try again.',
),
sticky: true,
notification: {
type: 'error',
title: t('Failed to transfer ownership'),
message: t(
'Failed to complete ownership transfer. Please try again.',
),
sticky: true,
},
}),
);
setIsTransferring(false);
Expand Down
Loading

0 comments on commit 2384069

Please sign in to comment.