Skip to content

A local-first personal finance app

[AI] Lint: fix typescript/unbound-method problems (#7163)

Matiss Janis Aboltinsbf1d220ced5c
diff --git a/.oxlintrc.json b/.oxlintrc.json
index 9bc9841aa4..c51a563682 100644
--- a/.oxlintrc.json
+++ b/.oxlintrc.json
@@ -103,6 +103,10 @@
"typescript/no-duplicate-type-constituents": "off",
"typescript/await-thenable": "error",
"typescript/no-floating-promises": "warn", // TODO: covert to error
+ "typescript/require-array-sort-compare": "warn", // TODO: covert to error
+ "typescript/unbound-method": "error",
+ "typescript/no-for-in-array": "warn", // TODO: covert to error
+ "typescript/restrict-template-expressions": "warn", // TODO: covert to error
// Import rules
"import/consistent-type-specifier-style": "error",
diff --git a/packages/crdt/src/crdt/timestamp.test.ts b/packages/crdt/src/crdt/timestamp.test.ts
index 2ceffeac53..fe20ccf83b 100644
--- a/packages/crdt/src/crdt/timestamp.test.ts
+++ b/packages/crdt/src/crdt/timestamp.test.ts
@@ -121,12 +121,12 @@ describe('Timestamp', function () {
it('should fail with counter overflow', function () {
now = 40;
for (let i = 0; i < 65536; i++) Timestamp.send();
- expect(Timestamp.send).toThrow(Timestamp.OverflowError);
+ expect(() => Timestamp.send()).toThrow(Timestamp.OverflowError);
});
it('should fail with clock drift', function () {
now = -(5 * 60 * 1000 + 1);
- expect(Timestamp.send).toThrow(Timestamp.ClockDriftError);
+ expect(() => Timestamp.send()).toThrow(Timestamp.ClockDriftError);
});
});
diff --git a/packages/desktop-client/src/components/banksync/EditSyncAccount.tsx b/packages/desktop-client/src/components/banksync/EditSyncAccount.tsx
index 5a2ea59c1e..30a49cb770 100644
--- a/packages/desktop-client/src/components/banksync/EditSyncAccount.tsx
+++ b/packages/desktop-client/src/components/banksync/EditSyncAccount.tsx
@@ -195,13 +195,13 @@ export function EditSyncAccount({ account }: EditSyncAccountProps) {
name="synced-account-edit"
containerProps={{ style: { width: 800 } }}
>
- {({ state: { close } }) => (
+ {({ state }) => (
<>
<ModalHeader
title={t('{{accountName}} bank sync settings', {
accountName: potentiallyTruncatedAccountName,
})}
- rightContent={<ModalCloseButton onPress={close} />}
+ rightContent={<ModalCloseButton onPress={() => state.close()} />}
/>
<Text style={{ fontSize: 15 }}>
@@ -246,20 +246,20 @@ export function EditSyncAccount({ account }: EditSyncAccountProps) {
<Button
style={{ color: theme.errorText }}
onPress={() => {
- void onUnlink(close);
+ void onUnlink(() => state.close());
}}
>
<Trans>Unlink account</Trans>
</Button>
<SpaceBetween gap={10}>
- <Button onPress={close}>
+ <Button onPress={() => state.close()}>
<Trans>Cancel</Trans>
</Button>
<Button
variant="primary"
onPress={() => {
- void onSave(close);
+ void onSave(() => state.close());
}}
>
<Trans>Save</Trans>
diff --git a/packages/desktop-client/src/components/modals/AccountAutocompleteModal.tsx b/packages/desktop-client/src/components/modals/AccountAutocompleteModal.tsx
index e45f6ff120..8700434fdb 100644
--- a/packages/desktop-client/src/components/modals/AccountAutocompleteModal.tsx
+++ b/packages/desktop-client/src/components/modals/AccountAutocompleteModal.tsx
@@ -46,7 +46,7 @@ export function AccountAutocompleteModal({
},
}}
>
- {({ state: { close } }) => (
+ {({ state }) => (
<>
{isNarrowWidth && (
<ModalHeader
@@ -58,7 +58,7 @@ export function AccountAutocompleteModal({
}
rightContent={
<ModalCloseButton
- onPress={close}
+ onPress={() => state.close()}
style={{ color: theme.menuAutoCompleteText }}
/>
}
@@ -80,7 +80,7 @@ export function AccountAutocompleteModal({
focused
embedded
closeOnBlur={false}
- onClose={close}
+ onClose={() => state.close()}
{...defaultAutocompleteProps}
onSelect={onSelect}
includeClosedAccounts={includeClosedAccounts}
diff --git a/packages/desktop-client/src/components/modals/AccountMenuModal.tsx b/packages/desktop-client/src/components/modals/AccountMenuModal.tsx
index cb8073e992..4540160085 100644
--- a/packages/desktop-client/src/components/modals/AccountMenuModal.tsx
+++ b/packages/desktop-client/src/components/modals/AccountMenuModal.tsx
@@ -114,7 +114,7 @@ export function AccountMenuModal({
},
}}
>
- {({ state: { close } }) => (
+ {({ state }) => (
<>
<ModalHeader
leftContent={
@@ -140,7 +140,7 @@ export function AccountMenuModal({
)}
</Fragment>
}
- rightContent={<ModalCloseButton onPress={close} />}
+ rightContent={<ModalCloseButton onPress={() => state.close()} />}
/>
<View
style={{
diff --git a/packages/desktop-client/src/components/modals/BudgetAutomationsModal.tsx b/packages/desktop-client/src/components/modals/BudgetAutomationsModal.tsx
index a52431b9af..fed14a7a7b 100644
--- a/packages/desktop-client/src/components/modals/BudgetAutomationsModal.tsx
+++ b/packages/desktop-client/src/components/modals/BudgetAutomationsModal.tsx
@@ -373,7 +373,7 @@ export function BudgetAutomationsModal({ categoryId }: { categoryId: string }) {
style: { width: 850, height: 650, paddingBottom: 20 },
}}
>
- {({ state: { close } }) => (
+ {({ state }) => (
<SpaceBetween
direction="vertical"
wrap={false}
@@ -384,7 +384,7 @@ export function BudgetAutomationsModal({ categoryId }: { categoryId: string }) {
title={t('Budget automations: {{category}}', {
category: currentCategory?.name,
})}
- rightContent={<ModalCloseButton onPress={close} />}
+ rightContent={<ModalCloseButton onPress={() => state.close()} />}
/>
{loading ? (
<View
@@ -453,10 +453,13 @@ export function BudgetAutomationsModal({ categoryId }: { categoryId: string }) {
</Link>
)}
{/* <View style={{ flex: 1 }} /> */}
- <Button onPress={close}>
+ <Button onPress={() => state.close()}>
<Trans>Cancel</Trans>
</Button>
- <Button variant="primary" onPress={() => onSave(close)}>
+ <Button
+ variant="primary"
+ onPress={() => onSave(() => state.close())}
+ >
<Trans>Save</Trans>
</Button>
</SpaceBetween>
diff --git a/packages/desktop-client/src/components/modals/BudgetPageMenuModal.tsx b/packages/desktop-client/src/components/modals/BudgetPageMenuModal.tsx
index df15a7888d..a9685bf823 100644
--- a/packages/desktop-client/src/components/modals/BudgetPageMenuModal.tsx
+++ b/packages/desktop-client/src/components/modals/BudgetPageMenuModal.tsx
@@ -33,11 +33,11 @@ export function BudgetPageMenuModal({
return (
<Modal name="budget-page-menu">
- {({ state: { close } }) => (
+ {({ state }) => (
<>
<ModalHeader
showLogo
- rightContent={<ModalCloseButton onPress={close} />}
+ rightContent={<ModalCloseButton onPress={() => state.close()} />}
/>
<BudgetPageMenu
getItemStyle={() => defaultMenuItemStyle}
diff --git a/packages/desktop-client/src/components/modals/CategoryAutocompleteModal.tsx b/packages/desktop-client/src/components/modals/CategoryAutocompleteModal.tsx
index aa773d50a7..43327fc33d 100644
--- a/packages/desktop-client/src/components/modals/CategoryAutocompleteModal.tsx
+++ b/packages/desktop-client/src/components/modals/CategoryAutocompleteModal.tsx
@@ -54,7 +54,7 @@ export function CategoryAutocompleteModal({
},
}}
>
- {({ state: { close } }) => (
+ {({ state }) => (
<>
{isNarrowWidth && (
<ModalHeader
@@ -66,7 +66,7 @@ export function CategoryAutocompleteModal({
}
rightContent={
<ModalCloseButton
- onPress={close}
+ onPress={() => state.close()}
style={{ color: theme.menuAutoCompleteText }}
/>
}
@@ -94,7 +94,7 @@ export function CategoryAutocompleteModal({
closeOnSelect={closeOnSelect}
clearOnSelect={clearOnSelect}
showSplitOption={false}
- onClose={close}
+ onClose={() => state.close()}
{...defaultAutocompleteProps}
onSelect={onSelect}
categoryGroups={categoryGroups}
diff --git a/packages/desktop-client/src/components/modals/CategoryGroupAutocompleteModal.tsx b/packages/desktop-client/src/components/modals/CategoryGroupAutocompleteModal.tsx
index ad1d44b070..f6bc72bd78 100644
--- a/packages/desktop-client/src/components/modals/CategoryGroupAutocompleteModal.tsx
+++ b/packages/desktop-client/src/components/modals/CategoryGroupAutocompleteModal.tsx
@@ -54,7 +54,7 @@ export function CategoryGroupAutocompleteModal({
},
}}
>
- {({ state: { close } }) => (
+ {({ state }) => (
<>
{isNarrowWidth && (
<ModalHeader
@@ -66,7 +66,7 @@ export function CategoryGroupAutocompleteModal({
}
rightContent={
<ModalCloseButton
- onPress={close}
+ onPress={() => state.close()}
style={{ color: theme.menuAutoCompleteText }}
/>
}
@@ -93,7 +93,7 @@ export function CategoryGroupAutocompleteModal({
closeOnBlur={false}
closeOnSelect={closeOnSelect}
clearOnSelect={clearOnSelect}
- onClose={close}
+ onClose={() => state.close()}
{...defaultAutocompleteProps}
onSelect={onSelect}
categoryGroups={categoryGroups}
diff --git a/packages/desktop-client/src/components/modals/CategoryGroupMenuModal.tsx b/packages/desktop-client/src/components/modals/CategoryGroupMenuModal.tsx
index 6c6d99480a..718e956fa6 100644
--- a/packages/desktop-client/src/components/modals/CategoryGroupMenuModal.tsx
+++ b/packages/desktop-client/src/components/modals/CategoryGroupMenuModal.tsx
@@ -133,7 +133,7 @@ export function CategoryGroupMenuModal({
},
}}
>
- {({ state: { close } }) => (
+ {({ state }) => (
<>
<ModalHeader
leftContent={
@@ -150,7 +150,7 @@ export function CategoryGroupMenuModal({
onTitleUpdate={onRename}
/>
}
- rightContent={<ModalCloseButton onPress={close} />}
+ rightContent={<ModalCloseButton onPress={() => state.close()} />}
/>
<View
style={{
@@ -237,7 +237,7 @@ export function CategoryGroupMenuModal({
getItemStyle={() => defaultMenuItemStyle}
onApplyBudgetTemplatesInGroup={() => {
_onApplyBudgetTemplatesInGroup();
- close();
+ state.close();
showUndoNotification({
message: t('budget templates have been applied.'),
});
diff --git a/packages/desktop-client/src/components/modals/CategoryMenuModal.tsx b/packages/desktop-client/src/components/modals/CategoryMenuModal.tsx
index eb3f06b24c..d255f3efb3 100644
--- a/packages/desktop-client/src/components/modals/CategoryMenuModal.tsx
+++ b/packages/desktop-client/src/components/modals/CategoryMenuModal.tsx
@@ -86,7 +86,7 @@ export function CategoryMenuModal({
style: { height: '45vh' },
}}
>
- {({ state: { close } }) => (
+ {({ state }) => (
<>
<ModalHeader
leftContent={
@@ -104,7 +104,7 @@ export function CategoryMenuModal({
onTitleUpdate={onRename}
/>
}
- rightContent={<ModalCloseButton onPress={close} />}
+ rightContent={<ModalCloseButton onPress={() => state.close()} />}
/>
<View
style={{
diff --git a/packages/desktop-client/src/components/modals/CloseAccountModal.tsx b/packages/desktop-client/src/components/modals/CloseAccountModal.tsx
index a462db5e32..3bfeebb92f 100644
--- a/packages/desktop-client/src/components/modals/CloseAccountModal.tsx
+++ b/packages/desktop-client/src/components/modals/CloseAccountModal.tsx
@@ -130,11 +130,11 @@ export function CloseAccountModal({
isLoading={loading}
containerProps={{ style: { width: '30vw' } }}
>
- {({ state: { close } }) => (
+ {({ state }) => (
<>
<ModalHeader
title={t('Close Account')}
- rightContent={<ModalCloseButton onPress={close} />}
+ rightContent={<ModalCloseButton onPress={() => state.close()} />}
/>
<View>
<Paragraph>
@@ -164,7 +164,7 @@ export function CloseAccountModal({
<Form
onSubmit={e => {
if (onSubmit(e)) {
- close();
+ state.close();
}
}}
>
@@ -286,7 +286,7 @@ export function CloseAccountModal({
id: account.id,
forced: true,
});
- close();
+ state.close();
}}
style={{ color: theme.errorText }}
>
@@ -311,7 +311,7 @@ export function CloseAccountModal({
marginRight: 10,
height: isNarrowWidth ? styles.mobileMinHeight : undefined,
}}
- onPress={close}
+ onPress={() => state.close()}
>
<Trans>Cancel</Trans>
</Button>
diff --git a/packages/desktop-client/src/components/modals/ConfirmCategoryDeleteModal.tsx b/packages/desktop-client/src/components/modals/ConfirmCategoryDeleteModal.tsx
index b67d261c7a..edeb2d2ab6 100644
--- a/packages/desktop-client/src/components/modals/ConfirmCategoryDeleteModal.tsx
+++ b/packages/desktop-client/src/components/modals/ConfirmCategoryDeleteModal.tsx
@@ -71,11 +71,11 @@ export function ConfirmCategoryDeleteModal({
name="confirm-category-delete"
containerProps={{ style: { width: '30vw' } }}
>
- {({ state: { close } }) => (
+ {({ state }) => (
<>
<ModalHeader
title={t('Confirm Delete')} // Use translation for title
- rightContent={<ModalCloseButton onPress={close} />}
+ rightContent={<ModalCloseButton onPress={() => state.close()} />}
/>
<View style={{ lineHeight: 1.5 }}>
{group ? (
@@ -177,7 +177,7 @@ export function ConfirmCategoryDeleteModal({
setError('required-transfer');
} else {
onDelete(transferCategory);
- close();
+ state.close();
}
}}
>
diff --git a/packages/desktop-client/src/components/modals/ConfirmDeleteModal.tsx b/packages/desktop-client/src/components/modals/ConfirmDeleteModal.tsx
index e3adb860b4..41b0355d00 100644
--- a/packages/desktop-client/src/components/modals/ConfirmDeleteModal.tsx
+++ b/packages/desktop-client/src/components/modals/ConfirmDeleteModal.tsx
@@ -34,11 +34,11 @@ export function ConfirmDeleteModal({
return (
<Modal name="confirm-delete">
- {({ state: { close } }) => (
+ {({ state }) => (
<>
<ModalHeader
title={t('Confirm Delete')}
- rightContent={<ModalCloseButton onPress={close} />}
+ rightContent={<ModalCloseButton onPress={() => state.close()} />}
/>
<View style={{ lineHeight: 1.5 }}>
<Paragraph>{message}</Paragraph>
@@ -53,7 +53,7 @@ export function ConfirmDeleteModal({
marginRight: 10,
...narrowButtonStyle,
}}
- onPress={close}
+ onPress={() => state.close()}
>
<Trans>Cancel</Trans>
</Button>
@@ -63,7 +63,7 @@ export function ConfirmDeleteModal({
style={narrowButtonStyle}
onPress={() => {
onConfirm();
- close();
+ state.close();
}}
>
<Trans>Delete</Trans>
diff --git a/packages/desktop-client/src/components/modals/ConfirmTransactionEditModal.tsx b/packages/desktop-client/src/components/modals/ConfirmTransactionEditModal.tsx
index c7bef8663b..a78b1141d1 100644
--- a/packages/desktop-client/src/components/modals/ConfirmTransactionEditModal.tsx
+++ b/packages/desktop-client/src/components/modals/ConfirmTransactionEditModal.tsx
@@ -40,11 +40,11 @@ export function ConfirmTransactionEditModal({
name="confirm-transaction-edit"
containerProps={{ style: { width: '30vw' } }}
>
- {({ state: { close } }) => (
+ {({ state }) => (
<>
<ModalHeader
title={t('Reconciled Transaction')}
- rightContent={<ModalCloseButton onPress={close} />}
+ rightContent={<ModalCloseButton onPress={() => state.close()} />}
/>
<View style={{ lineHeight: 1.5 }}>
{confirmReason === 'batchDeleteWithReconciled' ? (
@@ -109,7 +109,7 @@ export function ConfirmTransactionEditModal({
...narrowButtonStyle,
}}
onPress={() => {
- close();
+ state.close();
onCancel();
}}
>
@@ -124,7 +124,7 @@ export function ConfirmTransactionEditModal({
...narrowButtonStyle,
}}
onPress={() => {
- close();
+ state.close();
onConfirm();
}}
>
diff --git a/packages/desktop-client/src/components/modals/ConfirmUnlinkAccountModal.tsx b/packages/desktop-client/src/components/modals/ConfirmUnlinkAccountModal.tsx
index 0263437dd4..bb90da1d53 100644
--- a/packages/desktop-client/src/components/modals/ConfirmUnlinkAccountModal.tsx
+++ b/packages/desktop-client/src/components/modals/ConfirmUnlinkAccountModal.tsx
@@ -30,11 +30,11 @@ export function ConfirmUnlinkAccountModal({
name="confirm-unlink-account"
containerProps={{ style: { width: '30vw' } }}
>
- {({ state: { close } }) => (
+ {({ state }) => (
<>
<ModalHeader
title={t('Confirm Unlink')} // Use translation for title
- rightContent={<ModalCloseButton onPress={close} />}
+ rightContent={<ModalCloseButton onPress={() => state.close()} />}
/>
<View style={{ lineHeight: 1.5 }}>
<Paragraph>
@@ -59,7 +59,7 @@ export function ConfirmUnlinkAccountModal({
justifyContent: 'flex-end',
}}
>
- <Button style={{ marginRight: 10 }} onPress={close}>
+ <Button style={{ marginRight: 10 }} onPress={() => state.close()}>
<Trans>Cancel</Trans>
</Button>
<InitialFocus>
@@ -67,7 +67,7 @@ export function ConfirmUnlinkAccountModal({
variant="primary"
onPress={() => {
onUnlink();
- close();
+ state.close();
}}
>
<Trans>Unlink</Trans>
diff --git a/packages/desktop-client/src/components/modals/ConvertToScheduleModal.tsx b/packages/desktop-client/src/components/modals/ConvertToScheduleModal.tsx
index febd4ebc27..6c8b5e9ba4 100644
--- a/packages/desktop-client/src/components/modals/ConvertToScheduleModal.tsx
+++ b/packages/desktop-client/src/components/modals/ConvertToScheduleModal.tsx
@@ -42,11 +42,11 @@ export function ConvertToScheduleModal({
name="convert-to-schedule"
containerProps={{ style: { width: '30vw' } }}
>
- {({ state: { close } }) => (
+ {({ state }) => (
<>
<ModalHeader
title={t('Convert to Schedule')}
- rightContent={<ModalCloseButton onPress={close} />}
+ rightContent={<ModalCloseButton onPress={() => state.close()} />}
/>
<View style={{ lineHeight: 1.5 }}>
<Block>
@@ -95,7 +95,7 @@ export function ConvertToScheduleModal({
...(isNarrowWidth && { flex: 1 }),
}}
onPress={() => {
- close();
+ state.close();
onCancel?.();
}}
>
@@ -110,7 +110,7 @@ export function ConvertToScheduleModal({
...(isNarrowWidth && { flex: 1 }),
}}
onPress={() => {
- close();
+ state.close();
onConfirm();
}}
>
diff --git a/packages/desktop-client/src/components/modals/CopyWidgetToDashboardModal.tsx b/packages/desktop-client/src/components/modals/CopyWidgetToDashboardModal.tsx
index 9b953d3f3e..0135b5c08c 100644
--- a/packages/desktop-client/src/components/modals/CopyWidgetToDashboardModal.tsx
+++ b/packages/desktop-client/src/components/modals/CopyWidgetToDashboardModal.tsx
@@ -32,11 +32,11 @@ export function CopyWidgetToDashboardModal({
return (
<Modal name="copy-widget-to-dashboard">
- {({ state: { close } }) => (
+ {({ state }) => (
<>
<ModalHeader
title={t('Copy to dashboard')}
- rightContent={<ModalCloseButton onPress={close} />}
+ rightContent={<ModalCloseButton onPress={() => state.close()} />}
/>
<View style={{ lineHeight: 1.5 }}>
@@ -45,7 +45,7 @@ export function CopyWidgetToDashboardModal({
items={items}
onMenuSelect={item => {
onSelect(item);
- close();
+ state.close();
}}
/>
) : (
@@ -61,7 +61,7 @@ export function CopyWidgetToDashboardModal({
marginTop: 15,
}}
>
- <Button onPress={close}>
+ <Button onPress={() => state.close()}>
<Trans>Cancel</Trans>
</Button>
</View>
diff --git a/packages/desktop-client/src/components/modals/CoverModal.tsx b/packages/desktop-client/src/components/modals/CoverModal.tsx
index a8578e6655..7d3300256e 100644
--- a/packages/desktop-client/src/components/modals/CoverModal.tsx
+++ b/packages/desktop-client/src/components/modals/CoverModal.tsx
@@ -98,11 +98,11 @@ export function CoverModal({
return (
<Modal name="cover">
- {({ state: { close } }) => (
+ {({ state }) => (
<>
<ModalHeader
title={title}
- rightContent={<ModalCloseButton onPress={close} />}
+ rightContent={<ModalCloseButton onPress={() => state.close()} />}
/>
<View>
<FieldLabel title={t('Cover this amount:')} />
@@ -148,7 +148,7 @@ export function CoverModal({
}}
onPress={() => {
_onSubmit();
- close();
+ state.close();
}}
>
<Trans>Transfer</Trans>
diff --git a/packages/desktop-client/src/components/modals/CreateAccountModal.tsx b/packages/desktop-client/src/components/modals/CreateAccountModal.tsx
index 8c67785d88..aeef079729 100644
--- a/packages/desktop-client/src/components/modals/CreateAccountModal.tsx
+++ b/packages/desktop-client/src/components/modals/CreateAccountModal.tsx
@@ -335,11 +335,11 @@ export function CreateAccountModal({
return (
<Modal name="add-account">
- {({ state: { close } }) => (
+ {({ state }) => (
<>
<ModalHeader
title={title}
- rightContent={<ModalCloseButton onPress={close} />}
+ rightContent={<ModalCloseButton onPress={() => state.close()} />}
/>
<View style={{ maxWidth: 500, gap: 30, color: theme.pageText }}>
{upgradingAccountId == null && (
diff --git a/packages/desktop-client/src/components/modals/CreateEncryptionKeyModal.tsx b/packages/desktop-client/src/components/modals/CreateEncryptionKeyModal.tsx
index 6bbda48ddb..10d315595a 100644
--- a/packages/desktop-client/src/components/modals/CreateEncryptionKeyModal.tsx
+++ b/packages/desktop-client/src/components/modals/CreateEncryptionKeyModal.tsx
@@ -71,13 +71,13 @@ export function CreateEncryptionKeyModal({
return (
<Modal name="create-encryption-key">
- {({ state: { close } }) => (
+ {({ state }) => (
<>
<ModalHeader
title={
isRecreating ? t('Generate new key') : t('Enable encryption')
}
- rightContent={<ModalCloseButton onPress={close} />}
+ rightContent={<ModalCloseButton onPress={() => state.close()} />}
/>
<View
style={{
@@ -174,7 +174,7 @@ export function CreateEncryptionKeyModal({
<Form
onSubmit={e => {
e.preventDefault();
- void onCreateKey(close);
+ void onCreateKey(() => state.close());
}}
>
<View style={{ alignItems: 'center' }}>
diff --git a/packages/desktop-client/src/components/modals/CreateLocalAccountModal.tsx b/packages/desktop-client/src/components/modals/CreateLocalAccountModal.tsx
index 2709041597..cfab6d88d7 100644
--- a/packages/desktop-client/src/components/modals/CreateLocalAccountModal.tsx
+++ b/packages/desktop-client/src/components/modals/CreateLocalAccountModal.tsx
@@ -83,13 +83,13 @@ export function CreateLocalAccountModal() {
};
return (
<Modal name="add-local-account">
- {({ state: { close } }) => (
+ {({ state }) => (
<>
<ModalHeader
title={
<ModalTitle title={t('Create Local Account')} shrinkOnOverflow />
}
- rightContent={<ModalCloseButton onPress={close} />}
+ rightContent={<ModalCloseButton onPress={() => state.close()} />}
/>
<View>
<Form onSubmit={onSubmit}>
@@ -191,7 +191,7 @@ export function CreateLocalAccountModal() {
)}
<ModalButtons>
- <Button onPress={close}>
+ <Button onPress={() => state.close()}>
<Trans>Back</Trans>
</Button>
<Button
diff --git a/packages/desktop-client/src/components/modals/EditFieldModal.tsx b/packages/desktop-client/src/components/modals/EditFieldModal.tsx
index 014b998fb8..fa788105da 100644
--- a/packages/desktop-client/src/components/modals/EditFieldModal.tsx
+++ b/packages/desktop-client/src/components/modals/EditFieldModal.tsx
@@ -272,12 +272,12 @@ export function EditFieldModal({
},
}}
>
- {({ state: { close } }) => (
+ {({ state }) => (
<>
{isNarrowWidth && (
<ModalHeader
title={label}
- rightContent={<ModalCloseButton onPress={close} />}
+ rightContent={<ModalCloseButton onPress={() => state.close()} />}
/>
)}
<View>
@@ -291,7 +291,9 @@ export function EditFieldModal({
}}
/>
)}
- <View style={{ flex: 1 }}>{editor({ close })}</View>
+ <View style={{ flex: 1 }}>
+ {editor({ close: () => state.close() })}
+ </View>
</View>
</>
)}
diff --git a/packages/desktop-client/src/components/modals/EditRuleModal.tsx b/packages/desktop-client/src/components/modals/EditRuleModal.tsx
index 787dbc9852..e8faaae850 100644
--- a/packages/desktop-client/src/components/modals/EditRuleModal.tsx
+++ b/packages/desktop-client/src/components/modals/EditRuleModal.tsx
@@ -25,19 +25,19 @@ export function EditRuleModal({
return (
<Modal name="edit-rule">
- {({ state: { close } }) => (
+ {({ state }) => (
<>
<ModalHeader
title={t('Rule')}
- rightContent={<ModalCloseButton onPress={close} />}
+ rightContent={<ModalCloseButton onPress={() => state.close()} />}
/>
<RuleEditor
rule={defaultRule}
onSave={rule => {
originalOnSave?.(rule);
- close();
+ state.close();
}}
- onCancel={close}
+ onCancel={() => state.close()}
style={{
maxWidth: '100%',
width: 900,
diff --git a/packages/desktop-client/src/components/modals/EditUser.tsx b/packages/desktop-client/src/components/modals/EditUser.tsx
index c640da4e05..db59f62b15 100644
--- a/packages/desktop-client/src/components/modals/EditUser.tsx
+++ b/packages/desktop-client/src/components/modals/EditUser.tsx
@@ -133,7 +133,7 @@ export function EditUserFinanceApp({
const isExistingUser = 'id' in defaultUser && !!defaultUser.id;
return (
<Modal name="edit-user">
- {({ state: { close } }) => (
+ {({ state }) => (
<>
<ModalHeader
title={
@@ -143,14 +143,14 @@ export function EditUserFinanceApp({
})
: t('Add user')
}
- rightContent={<ModalCloseButton onPress={close} />}
+ rightContent={<ModalCloseButton onPress={() => state.close()} />}
/>
<EditUser
defaultUser={defaultUser}
onSave={async (method, user, setError) => {
if (await saveUser(method, user, setError)) {
originalOnSave(user);
- close();
+ state.close();
}
}}
/>
diff --git a/packages/desktop-client/src/components/modals/EnvelopeBalanceMenuModal.tsx b/packages/desktop-client/src/components/modals/EnvelopeBalanceMenuModal.tsx
index ad9da5c895..c195d17844 100644
--- a/packages/desktop-client/src/components/modals/EnvelopeBalanceMenuModal.tsx
+++ b/packages/desktop-client/src/components/modals/EnvelopeBalanceMenuModal.tsx
@@ -49,11 +49,11 @@ export function EnvelopeBalanceMenuModal({
return (
<Modal name="envelope-balance-menu">
- {({ state: { close } }) => (
+ {({ state }) => (
<>
<ModalHeader
title={<ModalTitle title={category.name} shrinkOnOverflow />}
- rightContent={<ModalCloseButton onPress={close} />}
+ rightContent={<ModalCloseButton onPress={() => state.close()} />}
/>
<View
style={{
diff --git a/packages/desktop-client/src/components/modals/EnvelopeBudgetMenuModal.tsx b/packages/desktop-client/src/components/modals/EnvelopeBudgetMenuModal.tsx
index 05841e6e01..789d3c13dc 100644
--- a/packages/desktop-client/src/components/modals/EnvelopeBudgetMenuModal.tsx
+++ b/packages/desktop-client/src/components/modals/EnvelopeBudgetMenuModal.tsx
@@ -66,11 +66,11 @@ export function EnvelopeBudgetMenuModal({
return (
<Modal name="envelope-budget-menu">
- {({ state: { close } }) => (
+ {({ state }) => (
<>
<ModalHeader
title={<ModalTitle title={category.name} shrinkOnOverflow />}
- rightContent={<ModalCloseButton onPress={close} />}
+ rightContent={<ModalCloseButton onPress={() => state.close()} />}
/>
<View
style={{
@@ -92,7 +92,7 @@ export function EnvelopeBudgetMenuModal({
focused={amountFocused}
onFocus={() => setAmountFocused(true)}
onBlur={() => setAmountFocused(false)}
- onEnter={close}
+ onEnter={() => state.close()}
zeroSign="+"
focusedStyle={{
width: 'auto',
diff --git a/packages/desktop-client/src/components/modals/EnvelopeBudgetMonthMenuModal.tsx b/packages/desktop-client/src/components/modals/EnvelopeBudgetMonthMenuModal.tsx
index eec79fa2b0..d6ef82f623 100644
--- a/packages/desktop-client/src/components/modals/EnvelopeBudgetMonthMenuModal.tsx
+++ b/packages/desktop-client/src/components/modals/EnvelopeBudgetMonthMenuModal.tsx
@@ -77,11 +77,11 @@ export function EnvelopeBudgetMonthMenuModal({
style: { height: '50vh' },
}}
>
- {({ state: { close } }) => (
+ {({ state }) => (
<>
<ModalHeader
title={displayMonth}
- rightContent={<ModalCloseButton onPress={close} />}
+ rightContent={<ModalCloseButton onPress={() => state.close()} />}
/>
<View
style={{
@@ -168,7 +168,7 @@ export function EnvelopeBudgetMonthMenuModal({
getItemStyle={() => defaultMenuItemStyle}
onCopyLastMonthBudget={() => {
onBudgetAction(month, 'copy-last');
- close();
+ state.close();
showUndoNotification({
message: t(
"{{displayMonth}} budgets have all been set to last month's budgeted amounts.",
@@ -178,7 +178,7 @@ export function EnvelopeBudgetMonthMenuModal({
}}
onSetBudgetsToZero={() => {
onBudgetAction(month, 'set-zero');
- close();
+ state.close();
showUndoNotification({
message: t(
'{{displayMonth}} budgets have all been set to zero.',
@@ -188,18 +188,18 @@ export function EnvelopeBudgetMonthMenuModal({
}}
onSetMonthsAverage={numberOfMonths => {
onBudgetAction(month, `set-${numberOfMonths}-avg`);
- close();
+ state.close();
showUndoNotification({
message: `${displayMonth} budgets have all been set to ${numberOfMonths === 12 ? 'yearly' : `${numberOfMonths} month`} average.`,
});
}}
onCheckTemplates={() => {
onBudgetAction(month, 'check-templates');
- close();
+ state.close();
}}
onApplyBudgetTemplates={() => {
onBudgetAction(month, 'apply-goal-template');
- close();
+ state.close();
showUndoNotification({
message: t(
'{{displayMonth}} budget templates have been applied.',
@@ -209,7 +209,7 @@ export function EnvelopeBudgetMonthMenuModal({
}}
onOverwriteWithBudgetTemplates={() => {
onBudgetAction(month, 'overwrite-goal-template');
- close();
+ state.close();
showUndoNotification({
message: t(
'{{displayMonth}} budget templates have been overwritten.',
@@ -219,7 +219,7 @@ export function EnvelopeBudgetMonthMenuModal({
}}
onEndOfMonthCleanup={() => {
onBudgetAction(month, 'cleanup-goal-template');
- close();
+ state.close();
showUndoNotification({
message: t(
'{{displayMonth}} end-of-month cleanup templates have been applied.',
diff --git a/packages/desktop-client/src/components/modals/EnvelopeBudgetSummaryModal.tsx b/packages/desktop-client/src/components/modals/EnvelopeBudgetSummaryModal.tsx
index 69175fbfe4..7084de45c2 100644
--- a/packages/desktop-client/src/components/modals/EnvelopeBudgetSummaryModal.tsx
+++ b/packages/desktop-client/src/components/modals/EnvelopeBudgetSummaryModal.tsx
@@ -158,11 +158,11 @@ export function EnvelopeBudgetSummaryModal({
return (
<Modal name="envelope-budget-summary">
- {({ state: { close } }) => (
+ {({ state }) => (
<>
<ModalHeader
title={t('Budget Summary')}
- rightContent={<ModalCloseButton onPress={close} />}
+ rightContent={<ModalCloseButton onPress={() => state.close()} />}
/>
<SheetNameProvider name={sheetForMonth(month)}>
<TotalsList
@@ -180,7 +180,7 @@ export function EnvelopeBudgetSummaryModal({
amountStyle={{
...styles.underlinedText,
}}
- onClick={() => onClick({ close })}
+ onClick={() => onClick({ close: () => state.close() })}
isTotalsListTooltipDisabled
/>
</SheetNameProvider>
diff --git a/packages/desktop-client/src/components/modals/EnvelopeIncomeBalanceMenuModal.tsx b/packages/desktop-client/src/components/modals/EnvelopeIncomeBalanceMenuModal.tsx
index 7dc2c70e49..e64ba9c233 100644
--- a/packages/desktop-client/src/components/modals/EnvelopeIncomeBalanceMenuModal.tsx
+++ b/packages/desktop-client/src/components/modals/EnvelopeIncomeBalanceMenuModal.tsx
@@ -54,11 +54,11 @@ export function EnvelopeIncomeBalanceMenuModal({
return (
<Modal name="envelope-income-balance-menu">
- {({ state: { close } }) => (
+ {({ state }) => (
<>
<ModalHeader
title={<ModalTitle title={category.name} shrinkOnOverflow />}
- rightContent={<ModalCloseButton onPress={close} />}
+ rightContent={<ModalCloseButton onPress={() => state.close()} />}
/>
<View
style={{
diff --git a/packages/desktop-client/src/components/modals/EnvelopeToBudgetMenuModal.tsx b/packages/desktop-client/src/components/modals/EnvelopeToBudgetMenuModal.tsx
index 4931fe3454..885f76f616 100644
--- a/packages/desktop-client/src/components/modals/EnvelopeToBudgetMenuModal.tsx
+++ b/packages/desktop-client/src/components/modals/EnvelopeToBudgetMenuModal.tsx
@@ -34,11 +34,11 @@ export function EnvelopeToBudgetMenuModal({
return (
<Modal name="envelope-summary-to-budget-menu">
- {({ state: { close } }) => (
+ {({ state }) => (
<>
<ModalHeader
showLogo
- rightContent={<ModalCloseButton onPress={close} />}
+ rightContent={<ModalCloseButton onPress={() => state.close()} />}
/>
<ToBudgetMenu
getItemStyle={() => defaultMenuItemStyle}
diff --git a/packages/desktop-client/src/components/modals/FixEncryptionKeyModal.tsx b/packages/desktop-client/src/components/modals/FixEncryptionKeyModal.tsx
index 0d5dedc372..2ece7dc07e 100644
--- a/packages/desktop-client/src/components/modals/FixEncryptionKeyModal.tsx
+++ b/packages/desktop-client/src/components/modals/FixEncryptionKeyModal.tsx
@@ -64,7 +64,7 @@ export function FixEncryptionKeyModal({
return (
<Modal name="fix-encryption-key">
- {({ state: { close } }) => (
+ {({ state }) => (
<>
<ModalHeader
title={
@@ -72,7 +72,7 @@ export function FixEncryptionKeyModal({
? t('Decrypt budget file')
: t('This file is encrypted')
}
- rightContent={<ModalCloseButton onPress={close} />}
+ rightContent={<ModalCloseButton onPress={() => state.close()} />}
/>
<View
style={{
@@ -111,7 +111,7 @@ export function FixEncryptionKeyModal({
<Form
onSubmit={e => {
e.preventDefault();
- void onUpdateKey(close);
+ void onUpdateKey(() => state.close());
}}
>
<View
@@ -164,7 +164,7 @@ export function FixEncryptionKeyModal({
height: isNarrowWidth ? styles.mobileMinHeight : undefined,
marginRight: 10,
}}
- onPress={close}
+ onPress={() => state.close()}
>
<Trans>Back</Trans>
</Button>
diff --git a/packages/desktop-client/src/components/modals/GoCardlessExternalMsgModal.tsx b/packages/desktop-client/src/components/modals/GoCardlessExternalMsgModal.tsx
index 828704ace5..8e2779d56b 100644
--- a/packages/desktop-client/src/components/modals/GoCardlessExternalMsgModal.tsx
+++ b/packages/desktop-client/src/components/modals/GoCardlessExternalMsgModal.tsx
@@ -273,11 +273,11 @@ export function GoCardlessExternalMsgModal({
onClose={onClose}
containerProps={{ style: { width: '30vw' } }}
>
- {({ state: { close } }) => (
+ {({ state }) => (
<>
<ModalHeader
title={t('Link Your Bank')}
- rightContent={<ModalCloseButton onPress={close} />}
+ rightContent={<ModalCloseButton onPress={() => state.close()} />}
/>
<View>
<Paragraph style={{ fontSize: 15 }}>
diff --git a/packages/desktop-client/src/components/modals/GoCardlessInitialiseModal.tsx b/packages/desktop-client/src/components/modals/GoCardlessInitialiseModal.tsx
index e814ae5f62..5bdbbec615 100644
--- a/packages/desktop-client/src/components/modals/GoCardlessInitialiseModal.tsx
+++ b/packages/desktop-client/src/components/modals/GoCardlessInitialiseModal.tsx
@@ -83,11 +83,11 @@ export const GoCardlessInitialiseModal = ({
return (
<Modal name="gocardless-init" containerProps={{ style: { width: '30vw' } }}>
- {({ state: { close } }) => (
+ {({ state }) => (
<>
<ModalHeader
title={t('Set up GoCardless')}
- rightContent={<ModalCloseButton onPress={close} />}
+ rightContent={<ModalCloseButton onPress={() => state.close()} />}
/>
<View style={{ display: 'flex', gap: 10 }}>
<Text>
@@ -142,7 +142,7 @@ export const GoCardlessInitialiseModal = ({
variant="primary"
isLoading={isLoading}
onPress={() => {
- void onSubmit(close);
+ void onSubmit(() => state.close());
}}
>
<Trans>Save and continue</Trans>
diff --git a/packages/desktop-client/src/components/modals/GoalTemplateModal.tsx b/packages/desktop-client/src/components/modals/GoalTemplateModal.tsx
index 84e95f7fdb..b85d80fc04 100644
--- a/packages/desktop-client/src/components/modals/GoalTemplateModal.tsx
+++ b/packages/desktop-client/src/components/modals/GoalTemplateModal.tsx
@@ -17,11 +17,11 @@ export function GoalTemplateModal() {
return (
<Modal name="goal-templates" containerProps={{ style: { width: 850 } }}>
- {({ state: { close } }) => (
+ {({ state }) => (
<>
<ModalHeader
title={t('Goal Templates')}
- rightContent={<ModalCloseButton onPress={close} />}
+ rightContent={<ModalCloseButton onPress={() => state.close()} />}
/>
<View>
<TableHeader>
diff --git a/packages/desktop-client/src/components/modals/HoldBufferModal.tsx b/packages/desktop-client/src/components/modals/HoldBufferModal.tsx
index 1aaa61a91a..2beb6a6408 100644
--- a/packages/desktop-client/src/components/modals/HoldBufferModal.tsx
+++ b/packages/desktop-client/src/components/modals/HoldBufferModal.tsx
@@ -41,11 +41,11 @@ export function HoldBufferModal({ onSubmit }: HoldBufferModalProps) {
return (
<Modal name="hold-buffer">
- {({ state: { close } }) => (
+ {({ state }) => (
<>
<ModalHeader
title={t('Hold for next month')}
- rightContent={<ModalCloseButton onPress={close} />}
+ rightContent={<ModalCloseButton onPress={() => state.close()} />}
/>
<View>
<FieldLabel title={t('Hold this amount:')} />{' '}
@@ -64,7 +64,7 @@ export function HoldBufferModal({ onSubmit }: HoldBufferModalProps) {
onUpdate={setAmount}
onEnter={() => {
_onSubmit(amount);
- close();
+ state.close();
}}
/>
</InitialFocus>
diff --git a/packages/desktop-client/src/components/modals/ImportTransactionsModal/ImportTransactionsModal.tsx b/packages/desktop-client/src/components/modals/ImportTransactionsModal/ImportTransactionsModal.tsx
index c42f70bf11..2c3d16064f 100644
--- a/packages/desktop-client/src/components/modals/ImportTransactionsModal/ImportTransactionsModal.tsx
+++ b/packages/desktop-client/src/components/modals/ImportTransactionsModal/ImportTransactionsModal.tsx
@@ -794,14 +794,14 @@ export function ImportTransactionsModal({
isLoading={loadingState === 'parsing'}
containerProps={{ style: { width: 800 } }}
>
- {({ state: { close } }) => (
+ {({ state }) => (
<>
<ModalHeader
title={
t('Import transactions') +
(filetype ? ` (${filetype.toUpperCase()})` : '')
}
- rightContent={<ModalCloseButton onPress={close} />}
+ rightContent={<ModalCloseButton onPress={() => state.close()} />}
/>
{error && !error.parsed && (
<View style={{ alignItems: 'center', marginBottom: 15 }}>
@@ -1133,7 +1133,7 @@ export function ImportTransactionsModal({
isDisabled={count === 0}
isLoading={loadingState === 'importing'}
onPress={() => {
- void onImport(close);
+ void onImport(() => state.close());
}}
>
<Trans count={count}>Import {{ count }} transactions</Trans>
diff --git a/packages/desktop-client/src/components/modals/KeyboardShortcutModal.tsx b/packages/desktop-client/src/components/modals/KeyboardShortcutModal.tsx
index b4486fc30e..02298b066e 100644
--- a/packages/desktop-client/src/components/modals/KeyboardShortcutModal.tsx
+++ b/packages/desktop-client/src/components/modals/KeyboardShortcutModal.tsx
@@ -464,7 +464,7 @@ export function KeyboardShortcutModal() {
return (
<Modal name="keyboard-shortcuts" containerProps={{ style: { width: 700 } }}>
- {({ state: { close } }) => (
+ {({ state }) => (
<>
<ModalHeader
title={
@@ -495,7 +495,7 @@ export function KeyboardShortcutModal() {
</Button>
) : null
}
- rightContent={<ModalCloseButton onPress={close} />}
+ rightContent={<ModalCloseButton onPress={() => state.close()} />}
/>
<View
style={{
diff --git a/packages/desktop-client/src/components/modals/LoadBackupModal.tsx b/packages/desktop-client/src/components/modals/LoadBackupModal.tsx
index 190c239550..0c4d998ebd 100644
--- a/packages/desktop-client/src/components/modals/LoadBackupModal.tsx
+++ b/packages/desktop-client/src/components/modals/LoadBackupModal.tsx
@@ -89,11 +89,11 @@ export function LoadBackupModal({
return (
<Modal name="load-backup" containerProps={{ style: { maxWidth: '30vw' } }}>
- {({ state: { close } }) => (
+ {({ state }) => (
<>
<ModalHeader
title={t('Load Backup')}
- rightContent={<ModalCloseButton onPress={close} />}
+ rightContent={<ModalCloseButton onPress={() => state.close()} />}
/>
<View style={{ marginBottom: 30 }}>
<View
diff --git a/packages/desktop-client/src/components/modals/ManageRulesModal.tsx b/packages/desktop-client/src/components/modals/ManageRulesModal.tsx
index 5f3074f48b..9a0de68d7c 100644
--- a/packages/desktop-client/src/components/modals/ManageRulesModal.tsx
+++ b/packages/desktop-client/src/components/modals/ManageRulesModal.tsx
@@ -21,11 +21,11 @@ export function ManageRulesModal({ payeeId }: ManageRulesModalProps) {
return (
<Modal name="manage-rules" isLoading={loading}>
- {({ state: { close } }) => (
+ {({ state }) => (
<>
<ModalHeader
title={t('Rules')}
- rightContent={<ModalCloseButton onPress={close} />}
+ rightContent={<ModalCloseButton onPress={() => state.close()} />}
/>
<ManageRules isModal payeeId={payeeId} setLoading={setLoading} />
</>
diff --git a/packages/desktop-client/src/components/modals/MergeUnusedPayeesModal.tsx b/packages/desktop-client/src/components/modals/MergeUnusedPayeesModal.tsx
index 02d9b83bb1..2960e35618 100644
--- a/packages/desktop-client/src/components/modals/MergeUnusedPayeesModal.tsx
+++ b/packages/desktop-client/src/components/modals/MergeUnusedPayeesModal.tsx
@@ -103,7 +103,7 @@ export function MergeUnusedPayeesModal({
return (
<Modal name="merge-unused-payees">
- {({ state: { close } }) => (
+ {({ state }) => (
<View style={{ padding: 20, maxWidth: 500 }}>
<View>
<Paragraph style={{ marginBottom: 10, fontWeight: 500 }}>
@@ -198,7 +198,7 @@ export function MergeUnusedPayeesModal({
style={{ marginRight: 10 }}
onPress={() => {
void onMerge(targetPayee);
- close();
+ state.close();
}}
>
<Trans>Merge</Trans>
@@ -208,13 +208,13 @@ export function MergeUnusedPayeesModal({
style={{ marginRight: 10 }}
onPress={() => {
void onMergeAndCreateRule(targetPayee);
- close();
+ state.close();
}}
>
<Trans>Merge and edit rule</Trans>
</Button>
)}
- <Button style={{ marginRight: 10 }} onPress={close}>
+ <Button style={{ marginRight: 10 }} onPress={() => state.close()}>
<Trans>Do nothing</Trans>
</Button>
</ModalButtons>
diff --git a/packages/desktop-client/src/components/modals/NotesModal.tsx b/packages/desktop-client/src/components/modals/NotesModal.tsx
index d10ca57ca7..acdd45779c 100644
--- a/packages/desktop-client/src/components/modals/NotesModal.tsx
+++ b/packages/desktop-client/src/components/modals/NotesModal.tsx
@@ -37,11 +37,11 @@ export function NotesModal({ id, name, onSave }: NotesModalProps) {
style: { height: '50vh' },
}}
>
- {({ state: { close } }) => (
+ {({ state }) => (
<>
<ModalHeader
title={t('Notes: {{name}}', { name })}
- rightContent={<ModalCloseButton onPress={close} />}
+ rightContent={<ModalCloseButton onPress={() => state.close()} />}
/>
<View
style={{
@@ -78,7 +78,7 @@ export function NotesModal({ id, name, onSave }: NotesModalProps) {
}}
onPress={() => {
_onSave();
- close();
+ state.close();
}}
>
<SvgCheck width={17} height={17} style={{ paddingRight: 5 }} />
diff --git a/packages/desktop-client/src/components/modals/OpenIDEnableModal.tsx b/packages/desktop-client/src/components/modals/OpenIDEnableModal.tsx
index eff81804f0..42c3d32765 100644
--- a/packages/desktop-client/src/components/modals/OpenIDEnableModal.tsx
+++ b/packages/desktop-client/src/components/modals/OpenIDEnableModal.tsx
@@ -67,11 +67,11 @@ export function OpenIDEnableModal({
return (
<Modal name="enable-openid">
- {({ state: { close } }) => (
+ {({ state }) => (
<>
<ModalHeader
title={t('Enable OpenID')}
- rightContent={<ModalCloseButton onPress={close} />}
+ rightContent={<ModalCloseButton onPress={() => state.close()} />}
/>
<View style={{ flexDirection: 'column' }}>
diff --git a/packages/desktop-client/src/components/modals/OutOfSyncMigrationsModal.tsx b/packages/desktop-client/src/components/modals/OutOfSyncMigrationsModal.tsx
index a8145644ee..60e63c7be9 100644
--- a/packages/desktop-client/src/components/modals/OutOfSyncMigrationsModal.tsx
+++ b/packages/desktop-client/src/components/modals/OutOfSyncMigrationsModal.tsx
@@ -27,7 +27,7 @@ export function OutOfSyncMigrationsModal() {
return (
<Modal name="out-of-sync-migrations">
- {({ state: { close } }) => (
+ {({ state }) => (
<>
<ModalHeader
title={<ModalTitle title={t('Please update Actual!')} />}
@@ -82,7 +82,7 @@ export function OutOfSyncMigrationsModal() {
style={{
padding: '10px 30px',
}}
- onPress={() => closeBudgetAndModal(close)}
+ onPress={() => closeBudgetAndModal(() => state.close())}
>
<Trans>Close Budget</Trans>
</Button>
diff --git a/packages/desktop-client/src/components/modals/PasswordEnableModal.tsx b/packages/desktop-client/src/components/modals/PasswordEnableModal.tsx
index 801ad1f4f5..0a331db6af 100644
--- a/packages/desktop-client/src/components/modals/PasswordEnableModal.tsx
+++ b/packages/desktop-client/src/components/modals/PasswordEnableModal.tsx
@@ -77,11 +77,11 @@ export function PasswordEnableModal({
return (
<Modal name="enable-password-auth">
- {({ state: { close } }) => (
+ {({ state }) => (
<>
<ModalHeader
title={t('Revert to server password')}
- rightContent={<ModalCloseButton onPress={close} />}
+ rightContent={<ModalCloseButton onPress={() => state.close()} />}
/>
<View style={{ flexDirection: 'column' }}>
diff --git a/packages/desktop-client/src/components/modals/PayeeAutocompleteModal.tsx b/packages/desktop-client/src/components/modals/PayeeAutocompleteModal.tsx
index defc7a862b..0d59cad6f0 100644
--- a/packages/desktop-client/src/components/modals/PayeeAutocompleteModal.tsx
+++ b/packages/desktop-client/src/components/modals/PayeeAutocompleteModal.tsx
@@ -51,7 +51,7 @@ export function PayeeAutocompleteModal({
},
}}
>
- {({ state: { close } }) => (
+ {({ state }) => (
<>
{isNarrowWidth && (
<ModalHeader
@@ -63,7 +63,7 @@ export function PayeeAutocompleteModal({
}
rightContent={
<ModalCloseButton
- onPress={close}
+ onPress={() => state.close()}
style={{ color: theme.menuAutoCompleteText }}
/>
}
@@ -75,7 +75,7 @@ export function PayeeAutocompleteModal({
focused
embedded
closeOnBlur={false}
- onClose={close}
+ onClose={() => state.close()}
onManagePayees={onManagePayees}
showManagePayees={!isNarrowWidth}
showMakeTransfer={!isNarrowWidth}
diff --git a/packages/desktop-client/src/components/modals/PluggyAiInitialiseModal.tsx b/packages/desktop-client/src/components/modals/PluggyAiInitialiseModal.tsx
index 5def5de3ac..ff2c01b381 100644
--- a/packages/desktop-client/src/components/modals/PluggyAiInitialiseModal.tsx
+++ b/packages/desktop-client/src/components/modals/PluggyAiInitialiseModal.tsx
@@ -101,11 +101,11 @@ export const PluggyAiInitialiseModal = ({
return (
<Modal name="pluggyai-init" containerProps={{ style: { width: '30vw' } }}>
- {({ state: { close } }) => (
+ {({ state }) => (
<>
<ModalHeader
title={t('Set-up Pluggy.ai')}
- rightContent={<ModalCloseButton onPress={close} />}
+ rightContent={<ModalCloseButton onPress={() => state.close()} />}
/>
<View style={{ display: 'flex', gap: 10 }}>
<Text>
@@ -180,7 +180,7 @@ export const PluggyAiInitialiseModal = ({
variant="primary"
isLoading={isLoading}
onPress={() => {
- void onSubmit(close);
+ void onSubmit(() => state.close());
}}
>
<Trans>Save and continue</Trans>
diff --git a/packages/desktop-client/src/components/modals/ScheduledTransactionMenuModal.tsx b/packages/desktop-client/src/components/modals/ScheduledTransactionMenuModal.tsx
index c69d68800f..14aff3a5ff 100644
--- a/packages/desktop-client/src/components/modals/ScheduledTransactionMenuModal.tsx
+++ b/packages/desktop-client/src/components/modals/ScheduledTransactionMenuModal.tsx
@@ -64,11 +64,11 @@ export function ScheduledTransactionMenuModal({
return (
<Modal name="scheduled-transaction-menu">
- {({ state: { close } }) => (
+ {({ state }) => (
<>
<ModalHeader
title={<ModalTitle title={schedule?.name || ''} shrinkOnOverflow />}
- rightContent={<ModalCloseButton onPress={close} />}
+ rightContent={<ModalCloseButton onPress={() => state.close()} />}
/>
<View
style={{
diff --git a/packages/desktop-client/src/components/modals/SelectLinkedAccountsModal.tsx b/packages/desktop-client/src/components/modals/SelectLinkedAccountsModal.tsx
index 75d4711684..36c9d97833 100644
--- a/packages/desktop-client/src/components/modals/SelectLinkedAccountsModal.tsx
+++ b/packages/desktop-client/src/components/modals/SelectLinkedAccountsModal.tsx
@@ -347,13 +347,13 @@ export function SelectLinkedAccountsModal({
: { width: 1000 },
}}
>
- {({ state: { close } }) => (
+ {({ state }) => (
<View
style={{ display: 'flex', flexDirection: 'column', height: '100%' }}
>
<ModalHeader
title={t('Link Accounts')}
- rightContent={<ModalCloseButton onPress={close} />}
+ rightContent={<ModalCloseButton onPress={() => state.close()} />}
/>
<View
diff --git a/packages/desktop-client/src/components/modals/SimpleFinInitialiseModal.tsx b/packages/desktop-client/src/components/modals/SimpleFinInitialiseModal.tsx
index f7c91c67b1..8d7f5a4feb 100644
--- a/packages/desktop-client/src/components/modals/SimpleFinInitialiseModal.tsx
+++ b/packages/desktop-client/src/components/modals/SimpleFinInitialiseModal.tsx
@@ -61,11 +61,11 @@ export const SimpleFinInitialiseModal = ({
return (
<Modal name="simplefin-init" containerProps={{ style: { width: 300 } }}>
- {({ state: { close } }) => (
+ {({ state }) => (
<>
<ModalHeader
title={t('Set-up SimpleFIN')}
- rightContent={<ModalCloseButton onPress={close} />}
+ rightContent={<ModalCloseButton onPress={() => state.close()} />}
/>
<View style={{ display: 'flex', gap: 10 }}>
<Text>
@@ -106,7 +106,7 @@ export const SimpleFinInitialiseModal = ({
autoFocus
isLoading={isLoading}
onPress={() => {
- void onSubmit(close);
+ void onSubmit(() => state.close());
}}
>
<Trans>Save and continue</Trans>
diff --git a/packages/desktop-client/src/components/modals/SingleInputModal.tsx b/packages/desktop-client/src/components/modals/SingleInputModal.tsx
index 14922e43d1..050a570402 100644
--- a/packages/desktop-client/src/components/modals/SingleInputModal.tsx
+++ b/packages/desktop-client/src/components/modals/SingleInputModal.tsx
@@ -50,13 +50,15 @@ export function SingleInputModal({
return (
<Modal name={name}>
- {({ state: { close } }) => (
+ {({ state }) => (
<>
- <Header rightContent={<ModalCloseButton onPress={close} />} />
+ <Header
+ rightContent={<ModalCloseButton onPress={() => state.close()} />}
+ />
<Form
onSubmit={e => {
_onSubmit(e);
- close();
+ state.close();
}}
>
<View>
diff --git a/packages/desktop-client/src/components/modals/TrackingBalanceMenuModal.tsx b/packages/desktop-client/src/components/modals/TrackingBalanceMenuModal.tsx
index 2d5b6c6dd8..9fd7ae7d69 100644
--- a/packages/desktop-client/src/components/modals/TrackingBalanceMenuModal.tsx
+++ b/packages/desktop-client/src/components/modals/TrackingBalanceMenuModal.tsx
@@ -47,11 +47,11 @@ export function TrackingBalanceMenuModal({
return (
<Modal name="tracking-balance-menu">
- {({ state: { close } }) => (
+ {({ state }) => (
<>
<ModalHeader
title={<ModalTitle title={category.name} shrinkOnOverflow />}
- rightContent={<ModalCloseButton onPress={close} />}
+ rightContent={<ModalCloseButton onPress={() => state.close()} />}
/>
<View
style={{
diff --git a/packages/desktop-client/src/components/modals/TrackingBudgetMenuModal.tsx b/packages/desktop-client/src/components/modals/TrackingBudgetMenuModal.tsx
index d11043548d..9538b76c05 100644
--- a/packages/desktop-client/src/components/modals/TrackingBudgetMenuModal.tsx
+++ b/packages/desktop-client/src/components/modals/TrackingBudgetMenuModal.tsx
@@ -66,11 +66,11 @@ export function TrackingBudgetMenuModal({
return (
<Modal name="tracking-budget-menu">
- {({ state: { close } }) => (
+ {({ state }) => (
<>
<ModalHeader
title={<ModalTitle title={category.name} shrinkOnOverflow />}
- rightContent={<ModalCloseButton onPress={close} />}
+ rightContent={<ModalCloseButton onPress={() => state.close()} />}
/>
<View
style={{
@@ -92,7 +92,7 @@ export function TrackingBudgetMenuModal({
focused={amountFocused}
onFocus={() => setAmountFocused(true)}
onBlur={() => setAmountFocused(false)}
- onEnter={close}
+ onEnter={() => state.close()}
zeroSign="+"
focusedStyle={{
width: 'auto',
diff --git a/packages/desktop-client/src/components/modals/TrackingBudgetMonthMenuModal.tsx b/packages/desktop-client/src/components/modals/TrackingBudgetMonthMenuModal.tsx
index 003b89d4ce..52e810cf5f 100644
--- a/packages/desktop-client/src/components/modals/TrackingBudgetMonthMenuModal.tsx
+++ b/packages/desktop-client/src/components/modals/TrackingBudgetMonthMenuModal.tsx
@@ -77,11 +77,11 @@ export function TrackingBudgetMonthMenuModal({
style: { height: '50vh' },
}}
>
- {({ state: { close } }) => (
+ {({ state }) => (
<>
<ModalHeader
title={displayMonth}
- rightContent={<ModalCloseButton onPress={close} />}
+ rightContent={<ModalCloseButton onPress={() => state.close()} />}
/>
<View
style={{
@@ -168,7 +168,7 @@ export function TrackingBudgetMonthMenuModal({
getItemStyle={() => defaultMenuItemStyle}
onCopyLastMonthBudget={() => {
onBudgetAction(month, 'copy-last');
- close();
+ state.close();
showUndoNotification({
message: t(
"{{displayMonth}} budgets have all been set to last month's budgeted amounts.",
@@ -178,7 +178,7 @@ export function TrackingBudgetMonthMenuModal({
}}
onSetBudgetsToZero={() => {
onBudgetAction(month, 'set-zero');
- close();
+ state.close();
showUndoNotification({
message: t(
'{{displayMonth}} budgets have all been set to zero.',
@@ -188,18 +188,18 @@ export function TrackingBudgetMonthMenuModal({
}}
onSetMonthsAverage={numberOfMonths => {
onBudgetAction(month, `set-${numberOfMonths}-avg`);
- close();
+ state.close();
showUndoNotification({
message: `${displayMonth} budgets have all been set to ${numberOfMonths === 12 ? 'yearly' : `${numberOfMonths} month`} average.`,
});
}}
onCheckTemplates={() => {
onBudgetAction(month, 'check-templates');
- close();
+ state.close();
}}
onApplyBudgetTemplates={() => {
onBudgetAction(month, 'apply-goal-template');
- close();
+ state.close();
showUndoNotification({
message: t(
'{{displayMonth}} budget templates have been applied.',
@@ -209,7 +209,7 @@ export function TrackingBudgetMonthMenuModal({
}}
onOverwriteWithBudgetTemplates={() => {
onBudgetAction(month, 'overwrite-goal-template');
- close();
+ state.close();
showUndoNotification({
message: t(
'{{displayMonth}} budget templates have been overwritten.',
diff --git a/packages/desktop-client/src/components/modals/TrackingBudgetSummaryModal.tsx b/packages/desktop-client/src/components/modals/TrackingBudgetSummaryModal.tsx
index 5033984944..543782b094 100644
--- a/packages/desktop-client/src/components/modals/TrackingBudgetSummaryModal.tsx
+++ b/packages/desktop-client/src/components/modals/TrackingBudgetSummaryModal.tsx
@@ -30,11 +30,11 @@ export function TrackingBudgetSummaryModal({
const currentMonth = monthUtils.currentMonth();
return (
<Modal name="tracking-budget-summary">
- {({ state: { close } }) => (
+ {({ state }) => (
<>
<ModalHeader
title={t('Budget Summary')}
- rightContent={<ModalCloseButton onPress={close} />}
+ rightContent={<ModalCloseButton onPress={() => state.close()} />}
/>
<SheetNameProvider name={sheetForMonth(month)}>
<SpaceBetween
diff --git a/packages/desktop-client/src/components/modals/TransferModal.tsx b/packages/desktop-client/src/components/modals/TransferModal.tsx
index c494fef992..25420ccfcc 100644
--- a/packages/desktop-client/src/components/modals/TransferModal.tsx
+++ b/packages/desktop-client/src/components/modals/TransferModal.tsx
@@ -90,11 +90,11 @@ export function TransferModal({
return (
<Modal name="transfer">
- {({ state: { close } }) => (
+ {({ state }) => (
<>
<ModalHeader
title={title}
- rightContent={<ModalCloseButton onPress={close} />}
+ rightContent={<ModalCloseButton onPress={() => state.close()} />}
/>
<View>
<View>
@@ -139,7 +139,7 @@ export function TransferModal({
}}
onPress={() => {
_onSubmit(amount, toCategoryId);
- close();
+ state.close();
}}
>
<Trans>Transfer</Trans>
diff --git a/packages/desktop-client/src/components/modals/UnmigrateBudgetAutomationsModal.tsx b/packages/desktop-client/src/components/modals/UnmigrateBudgetAutomationsModal.tsx
index 35876b1377..012937e481 100644
--- a/packages/desktop-client/src/components/modals/UnmigrateBudgetAutomationsModal.tsx
+++ b/packages/desktop-client/src/components/modals/UnmigrateBudgetAutomationsModal.tsx
@@ -108,13 +108,13 @@ export function UnmigrateBudgetAutomationsModal({
style: { width: 850, height: 650, paddingBottom: 20 },
}}
>
- {({ state: { close } }) => (
+ {({ state }) => (
<SpaceBetween direction="vertical" style={{ height: '100%' }}>
<ModalHeader
title={t('Un-migrate automations: {{category}}', {
category: category?.name,
})}
- rightContent={<ModalCloseButton onPress={close} />}
+ rightContent={<ModalCloseButton onPress={() => state.close()} />}
/>
{rendered === null ? (
<View
@@ -167,12 +167,12 @@ export function UnmigrateBudgetAutomationsModal({
</SpaceBetween>
)}
<SpaceBetween gap={10} style={{ justifyContent: 'flex-end' }}>
- <Button onPress={() => close()}>
+ <Button onPress={() => state.close()}>
<Trans>Cancel</Trans>
</Button>
<Button
variant="primary"
- onPress={() => onSave(close)}
+ onPress={() => onSave(() => state.close())}
isDisabled={saving}
>
{saving && (
diff --git a/packages/desktop-client/src/components/modals/manager/ConfirmChangeDocumentDir.tsx b/packages/desktop-client/src/components/modals/manager/ConfirmChangeDocumentDir.tsx
index d92005a873..7a682819b4 100644
--- a/packages/desktop-client/src/components/modals/manager/ConfirmChangeDocumentDir.tsx
+++ b/packages/desktop-client/src/components/modals/manager/ConfirmChangeDocumentDir.tsx
@@ -100,11 +100,11 @@ export function ConfirmChangeDocumentDirModal({
return (
<Modal name="confirm-change-document-dir">
- {({ state: { close } }) => (
+ {({ state }) => (
<>
<ModalHeader
title={t('Are you sure?')}
- rightContent={<ModalCloseButton onPress={close} />}
+ rightContent={<ModalCloseButton onPress={() => state.close()} />}
/>
<View
style={{
@@ -190,7 +190,7 @@ export function ConfirmChangeDocumentDirModal({
fontSize: 14,
alignSelf: 'center',
}}
- onPress={close}
+ onPress={() => state.close()}
>
<Trans>Cancel</Trans>
</Button>
@@ -202,7 +202,7 @@ export function ConfirmChangeDocumentDirModal({
fontSize: 14,
alignSelf: 'center',
}}
- onPress={() => moveDirectory(close)}
+ onPress={() => moveDirectory(() => state.close())}
>
<Trans>Change directory</Trans>
</ButtonWithLoading>
diff --git a/packages/desktop-client/src/components/modals/manager/DeleteFileModal.tsx b/packages/desktop-client/src/components/modals/manager/DeleteFileModal.tsx
index ffcec9ba50..1891485d82 100644
--- a/packages/desktop-client/src/components/modals/manager/DeleteFileModal.tsx
+++ b/packages/desktop-client/src/components/modals/manager/DeleteFileModal.tsx
@@ -46,11 +46,11 @@ export function DeleteFileModal({ file }: DeleteFileModalProps) {
return (
<Modal name="delete-budget">
- {({ state: { close } }) => (
+ {({ state }) => (
<>
<ModalHeader
title={t('Delete {{fileName}}', { fileName: file.name })}
- rightContent={<ModalCloseButton onPress={close} />}
+ rightContent={<ModalCloseButton onPress={() => state.close()} />}
/>
<View
style={{
@@ -95,7 +95,7 @@ export function DeleteFileModal({ file }: DeleteFileModalProps) {
);
setLoadingState(null);
- close();
+ state.close();
}}
>
<Trans>Delete file from all devices</Trans>
@@ -176,7 +176,7 @@ export function DeleteFileModal({ file }: DeleteFileModalProps) {
await dispatch(deleteBudget({ id: file.id }));
setLoadingState(null);
- close();
+ state.close();
}}
>
<Trans>Delete file locally</Trans>
diff --git a/packages/desktop-client/src/components/modals/manager/DuplicateFileModal.tsx b/packages/desktop-client/src/components/modals/manager/DuplicateFileModal.tsx
index 901b13f9cc..9c957d6270 100644
--- a/packages/desktop-client/src/components/modals/manager/DuplicateFileModal.tsx
+++ b/packages/desktop-client/src/components/modals/manager/DuplicateFileModal.tsx
@@ -116,14 +116,14 @@ export function DuplicateFileModal({
return (
<Modal name="duplicate-budget">
- {({ state: { close } }) => (
+ {({ state }) => (
<View style={{ maxWidth: 700 }}>
<ModalHeader
title={t('Duplicate "{{fileName}}"', { fileName: file.name })}
rightContent={
<ModalCloseButton
onPress={() => {
- close();
+ state.close();
if (onComplete) onComplete({ status: 'canceled' });
}}
/>
@@ -187,7 +187,7 @@ export function DuplicateFileModal({
<ModalButtons>
<Button
onPress={() => {
- close();
+ state.close();
if (onComplete) onComplete({ status: 'canceled' });
}}
>
diff --git a/packages/desktop-client/src/components/modals/manager/FilesSettingsModal.tsx b/packages/desktop-client/src/components/modals/manager/FilesSettingsModal.tsx
index 327b2dd717..e338a0487a 100644
--- a/packages/desktop-client/src/components/modals/manager/FilesSettingsModal.tsx
+++ b/packages/desktop-client/src/components/modals/manager/FilesSettingsModal.tsx
@@ -162,12 +162,14 @@ export function FilesSettingsModal() {
return (
<Modal name="files-settings">
- {({ state: { close } }) => (
+ {({ state }) => (
<>
<ModalHeader
title={t('Settings')}
rightContent={
- <ModalCloseButton onPress={() => closeModal(close)} />
+ <ModalCloseButton
+ onPress={() => closeModal(() => state.close())}
+ />
}
/>
<View
@@ -189,7 +191,7 @@ export function FilesSettingsModal() {
fontSize: 14,
alignSelf: 'center',
}}
- onPress={() => closeModal(close)}
+ onPress={() => closeModal(() => state.close())}
>
<Trans>OK</Trans>
</Button>
diff --git a/packages/desktop-client/src/components/modals/manager/ImportActualModal.tsx b/packages/desktop-client/src/components/modals/manager/ImportActualModal.tsx
index 17ccf0da29..6f0df26063 100644
--- a/packages/desktop-client/src/components/modals/manager/ImportActualModal.tsx
+++ b/packages/desktop-client/src/components/modals/manager/ImportActualModal.tsx
@@ -71,11 +71,11 @@ export function ImportActualModal() {
return (
<Modal name="import-actual" containerProps={{ style: { width: 400 } }}>
- {({ state: { close } }) => (
+ {({ state }) => (
<>
<ModalHeader
title={t('Import from Actual export')}
- rightContent={<ModalCloseButton onPress={close} />}
+ rightContent={<ModalCloseButton onPress={() => state.close()} />}
/>
<View style={{ ...styles.smallText, lineHeight: 1.5, marginTop: 20 }}>
{error && (
diff --git a/packages/desktop-client/src/components/modals/manager/ImportModal.tsx b/packages/desktop-client/src/components/modals/manager/ImportModal.tsx
index 0779721d98..ed44955fe2 100644
--- a/packages/desktop-client/src/components/modals/manager/ImportModal.tsx
+++ b/packages/desktop-client/src/components/modals/manager/ImportModal.tsx
@@ -57,11 +57,11 @@ export function ImportModal() {
return (
<Modal name="import" containerProps={{ style: { width: 400 } }}>
- {({ state: { close } }) => (
+ {({ state }) => (
<>
<ModalHeader
title={t('Import From')}
- rightContent={<ModalCloseButton onPress={close} />}
+ rightContent={<ModalCloseButton onPress={() => state.close()} />}
/>
<View style={{ ...styles.smallText, lineHeight: 1.5 }}>
{error && (
diff --git a/packages/desktop-client/src/components/modals/manager/ImportYNAB4Modal.tsx b/packages/desktop-client/src/components/modals/manager/ImportYNAB4Modal.tsx
index c98e549fea..4df148241d 100644
--- a/packages/desktop-client/src/components/modals/manager/ImportYNAB4Modal.tsx
+++ b/packages/desktop-client/src/components/modals/manager/ImportYNAB4Modal.tsx
@@ -55,11 +55,11 @@ export function ImportYNAB4Modal() {
return (
<Modal name="import-ynab4" containerProps={{ style: { width: 400 } }}>
- {({ state: { close } }) => (
+ {({ state }) => (
<>
<ModalHeader
title={t('Import from YNAB4')}
- rightContent={<ModalCloseButton onPress={close} />}
+ rightContent={<ModalCloseButton onPress={() => state.close()} />}
/>
<View style={{ ...styles.smallText, lineHeight: 1.5, marginTop: 20 }}>
{error && (
diff --git a/packages/desktop-client/src/components/modals/manager/ImportYNAB5Modal.tsx b/packages/desktop-client/src/components/modals/manager/ImportYNAB5Modal.tsx
index 555fcff340..6f7dfa8069 100644
--- a/packages/desktop-client/src/components/modals/manager/ImportYNAB5Modal.tsx
+++ b/packages/desktop-client/src/components/modals/manager/ImportYNAB5Modal.tsx
@@ -65,11 +65,11 @@ export function ImportYNAB5Modal() {
return (
<Modal name="import-ynab5" containerProps={{ style: { width: 400 } }}>
- {({ state: { close } }) => (
+ {({ state }) => (
<>
<ModalHeader
title={t('Import from nYNAB')}
- rightContent={<ModalCloseButton onPress={close} />}
+ rightContent={<ModalCloseButton onPress={() => state.close()} />}
/>
<View style={{ ...styles.smallText, lineHeight: 1.5, marginTop: 20 }}>
{error && (
diff --git a/packages/desktop-client/src/components/payees/CategoryLearning.tsx b/packages/desktop-client/src/components/payees/CategoryLearning.tsx
index 6300e0d0df..4a9608d6a0 100644
--- a/packages/desktop-client/src/components/payees/CategoryLearning.tsx
+++ b/packages/desktop-client/src/components/payees/CategoryLearning.tsx
@@ -23,11 +23,11 @@ export function CategoryLearning() {
name="payee-category-learning"
containerProps={{ style: { width: 600 } }}
>
- {({ state: { close } }) => (
+ {({ state }) => (
<>
<ModalHeader
title={t('Category Learning')}
- rightContent={<ModalCloseButton onPress={close} />}
+ rightContent={<ModalCloseButton onPress={() => state.close()} />}
/>
<Paragraph>
<Trans>
diff --git a/packages/desktop-client/src/components/schedules/DiscoverSchedules.tsx b/packages/desktop-client/src/components/schedules/DiscoverSchedules.tsx
index 49bda607a8..7e477dfc84 100644
--- a/packages/desktop-client/src/components/schedules/DiscoverSchedules.tsx
+++ b/packages/desktop-client/src/components/schedules/DiscoverSchedules.tsx
@@ -209,11 +209,11 @@ export function DiscoverSchedules() {
name="schedules-discover"
containerProps={{ style: { width: 850, height: 650 } }}
>
- {({ state: { close } }) => (
+ {({ state }) => (
<>
<ModalHeader
title={t('Found Schedules')}
- rightContent={<ModalCloseButton onPress={close} />}
+ rightContent={<ModalCloseButton onPress={() => state.close()} />}
/>
<Paragraph>
<Trans>
@@ -248,7 +248,7 @@ export function DiscoverSchedules() {
isDisabled={selectedInst.items.size === 0}
onPress={() => {
void onCreate();
- close();
+ state.close();
}}
>
<Trans>Create schedules</Trans>
diff --git a/packages/desktop-client/src/components/schedules/PostsOfflineNotification.tsx b/packages/desktop-client/src/components/schedules/PostsOfflineNotification.tsx
index 7b077b75f0..6264cad050 100644
--- a/packages/desktop-client/src/components/schedules/PostsOfflineNotification.tsx
+++ b/packages/desktop-client/src/components/schedules/PostsOfflineNotification.tsx
@@ -47,11 +47,11 @@ export function PostsOfflineNotification() {
return (
<Modal name="schedule-posts-offline-notification">
- {({ state: { close } }) => (
+ {({ state }) => (
<>
<ModalHeader
title={t('Post transactions?')}
- rightContent={<ModalCloseButton onPress={close} />}
+ rightContent={<ModalCloseButton onPress={() => state.close()} />}
/>
<Paragraph>
<Text>
@@ -91,7 +91,7 @@ export function PostsOfflineNotification() {
gap={10}
style={{ marginTop: 20, justifyContent: 'flex-end' }}
>
- <Button onPress={close}>
+ <Button onPress={() => state.close()}>
<Trans>Decide later</Trans>
</Button>
<Button
@@ -99,7 +99,7 @@ export function PostsOfflineNotification() {
autoFocus
onPress={() => {
void onPost();
- close();
+ state.close();
}}
>
<Trans>Post transactions</Trans>
diff --git a/packages/desktop-client/src/components/schedules/ScheduleEditModal.tsx b/packages/desktop-client/src/components/schedules/ScheduleEditModal.tsx
index 65ba6428f1..c22c37d9b5 100644
--- a/packages/desktop-client/src/components/schedules/ScheduleEditModal.tsx
+++ b/packages/desktop-client/src/components/schedules/ScheduleEditModal.tsx
@@ -216,7 +216,7 @@ export function ScheduleEditModal({ id, transaction }: ScheduleEditModalProps) {
: false;
return (
<Modal name="schedule-edit">
- {({ state: { close } }) => (
+ {({ state: modalState }) => (
<>
<ModalHeader
title={
@@ -224,7 +224,9 @@ export function ScheduleEditModal({ id, transaction }: ScheduleEditModalProps) {
? t(`Schedule: {{name}}`, { name: payee.name })
: t('Schedule')
}
- rightContent={<ModalCloseButton onPress={close} />}
+ rightContent={
+ <ModalCloseButton onPress={() => modalState.close()} />
+ }
/>
<ScheduleEditForm
fields={state.fields}
@@ -251,10 +253,13 @@ export function ScheduleEditModal({ id, transaction }: ScheduleEditModalProps) {
alignItems: 'center',
}}
>
- <Button onPress={close}>
+ <Button onPress={() => modalState.close()}>
<Trans>Cancel</Trans>
</Button>
- <Button variant="primary" onPress={() => onSave(close)}>
+ <Button
+ variant="primary"
+ onPress={() => onSave(() => modalState.close())}
+ >
{adding ? t('Add') : t('Save')}
</Button>
</SpaceBetween>
diff --git a/packages/desktop-client/src/components/schedules/ScheduleLink.tsx b/packages/desktop-client/src/components/schedules/ScheduleLink.tsx
index bf31c40918..1582d302d3 100644
--- a/packages/desktop-client/src/components/schedules/ScheduleLink.tsx
+++ b/packages/desktop-client/src/components/schedules/ScheduleLink.tsx
@@ -83,11 +83,11 @@ export function ScheduleLink({
},
}}
>
- {({ state: { close } }) => (
+ {({ state }) => (
<>
<ModalHeader
title={t('Link schedule')}
- rightContent={<ModalCloseButton onPress={close} />}
+ rightContent={<ModalCloseButton onPress={() => state.close()} />}
/>
<View
style={{
@@ -123,7 +123,7 @@ export function ScheduleLink({
variant="primary"
style={{ marginLeft: 15, padding: '4px 10px' }}
onPress={() => {
- close();
+ state.close();
void onCreate();
}}
>
@@ -149,7 +149,7 @@ export function ScheduleLink({
minimal
onSelect={id => {
void onSelect(id);
- close();
+ state.close();
}}
schedules={schedules}
statuses={statuses}
diff --git a/packages/desktop-client/src/components/schedules/UpcomingLength.tsx b/packages/desktop-client/src/components/schedules/UpcomingLength.tsx
index bb0d4b9e1c..111f55109a 100644
--- a/packages/desktop-client/src/components/schedules/UpcomingLength.tsx
+++ b/packages/desktop-client/src/components/schedules/UpcomingLength.tsx
@@ -75,11 +75,11 @@ export function UpcomingLength() {
name="schedules-upcoming-length"
containerProps={{ style: { width: 600 } }}
>
- {({ state: { close } }) => (
+ {({ state }) => (
<>
<ModalHeader
title={t('Change upcoming length')}
- rightContent={<ModalCloseButton onPress={close} />}
+ rightContent={<ModalCloseButton onPress={() => state.close()} />}
/>
<Paragraph>
<Trans>
@@ -128,7 +128,7 @@ export function UpcomingLength() {
isDisabled={!saveActive}
onPress={() => {
saveUpcomingLength();
- close();
+ state.close();
}}
type="submit"
variant="primary"
diff --git a/packages/desktop-client/src/i18n.test.ts b/packages/desktop-client/src/i18n.test.ts
index c433a8d3c6..37bf209a1d 100644
--- a/packages/desktop-client/src/i18n.test.ts
+++ b/packages/desktop-client/src/i18n.test.ts
@@ -35,7 +35,7 @@ describe('setI18NextLanguage', () => {
setI18NextLanguage('');
- expect(i18n.changeLanguage).toHaveBeenCalledWith('uk');
+ expect(vi.mocked(i18n).changeLanguage).toHaveBeenCalledWith('uk');
});
test('should set the provided language if it is available', () => {
@@ -43,7 +43,7 @@ describe('setI18NextLanguage', () => {
setI18NextLanguage(language);
- expect(i18n.changeLanguage).toHaveBeenCalledWith(language);
+ expect(vi.mocked(i18n).changeLanguage).toHaveBeenCalledWith(language);
});
test('should fallback to English if the provided language is unavailable', () => {
@@ -54,7 +54,7 @@ describe('setI18NextLanguage', () => {
expect(console.info).toHaveBeenCalledWith(
'Unknown locale unknown, falling back to en',
);
- expect(i18n.changeLanguage).toHaveBeenCalledWith('en');
+ expect(vi.mocked(i18n).changeLanguage).toHaveBeenCalledWith('en');
});
test('should successfully use a language with a region code if it is known', () => {
@@ -62,7 +62,7 @@ describe('setI18NextLanguage', () => {
setI18NextLanguage(language);
- expect(i18n.changeLanguage).toHaveBeenCalledWith(language);
+ expect(vi.mocked(i18n).changeLanguage).toHaveBeenCalledWith(language);
});
test('should fallback to base language if the provided language has an unknown region code', () => {
@@ -73,7 +73,7 @@ describe('setI18NextLanguage', () => {
expect(console.info).toHaveBeenCalledWith(
'Unknown locale uk-ZZ, falling back to uk-zz',
);
- expect(i18n.changeLanguage).toHaveBeenCalledWith('uk');
+ expect(vi.mocked(i18n).changeLanguage).toHaveBeenCalledWith('uk');
});
test('should fallback to lowercase language if the provided language has uppercase letters', () => {
@@ -84,6 +84,6 @@ describe('setI18NextLanguage', () => {
expect(console.info).toHaveBeenCalledWith(
'Unknown locale EN, falling back to en',
);
- expect(i18n.changeLanguage).toHaveBeenCalledWith('en');
+ expect(vi.mocked(i18n).changeLanguage).toHaveBeenCalledWith('en');
});
});
diff --git a/packages/loot-core/src/platform/server/fs/index.electron.ts b/packages/loot-core/src/platform/server/fs/index.electron.ts
index e0f5798014..185c309d02 100644
--- a/packages/loot-core/src/platform/server/fs/index.electron.ts
+++ b/packages/loot-core/src/platform/server/fs/index.electron.ts
@@ -49,7 +49,8 @@ export const demoBudgetPath: typeof T.demoBudgetPath = path.join(
'demo-budget',
);
-export const join: typeof T.join = path.join;
+export const join: typeof T.join = (...args: Parameters<typeof path.join>) =>
+ path.join(...args);
export const basename: typeof T.basename = filepath => path.basename(filepath);
diff --git a/packages/loot-core/src/server/api-models.ts b/packages/loot-core/src/server/api-models.ts
index 832965459b..43ff9044da 100644
--- a/packages/loot-core/src/server/api-models.ts
+++ b/packages/loot-core/src/server/api-models.ts
@@ -88,14 +88,17 @@ export const categoryGroupModel = {
name: group.name,
is_income: group.is_income ? true : false,
hidden: group.hidden ? true : false,
- categories: group.categories?.map(categoryModel.toExternal) || [],
+ categories:
+ group.categories?.map(cat => categoryModel.toExternal(cat)) || [],
};
},
fromExternal(group: APICategoryGroupEntity) {
const result = { ...group } as unknown as CategoryGroupEntity;
if ('categories' in group && group.categories) {
- result.categories = group.categories.map(categoryModel.fromExternal);
+ result.categories = group.categories.map(cat =>
+ categoryModel.fromExternal(cat),
+ );
}
return result;
},
diff --git a/packages/loot-core/src/server/api.ts b/packages/loot-core/src/server/api.ts
index f5fa407b47..8b6ce30690 100644
--- a/packages/loot-core/src/server/api.ts
+++ b/packages/loot-core/src/server/api.ts
@@ -632,14 +632,14 @@ handlers['api/categories-get'] = async function ({
checkFileOpen();
const result = await handlers['get-categories']();
return grouped
- ? result.grouped.map(categoryGroupModel.toExternal)
- : result.list.map(categoryModel.toExternal);
+ ? result.grouped.map(group => categoryGroupModel.toExternal(group))
+ : result.list.map(category => categoryModel.toExternal(category));
};
handlers['api/category-groups-get'] = async function () {
checkFileOpen();
const groups = await handlers['get-category-groups']();
- return groups.map(categoryGroupModel.toExternal);
+ return groups.map(group => categoryGroupModel.toExternal(group));
};
handlers['api/category-group-create'] = withMutation(async function ({
@@ -706,13 +706,13 @@ handlers['api/category-delete'] = withMutation(async function ({
handlers['api/common-payees-get'] = async function () {
checkFileOpen();
const payees = await handlers['common-payees-get']();
- return payees.map(payeeModel.toExternal);
+ return payees.map(payee => payeeModel.toExternal(payee));
};
handlers['api/payees-get'] = async function () {
checkFileOpen();
const payees = await handlers['payees-get']();
- return payees.map(payeeModel.toExternal);
+ return payees.map(payee => payeeModel.toExternal(payee));
};
handlers['api/payee-create'] = withMutation(async function ({ payee }) {
@@ -743,7 +743,7 @@ handlers['api/payees-merge'] = withMutation(async function ({
handlers['api/tags-get'] = async function () {
checkFileOpen();
const tags = await handlers['tags-get']();
- return tags.map(tagModel.toExternal);
+ return tags.map(tag => tagModel.toExternal(tag));
};
handlers['api/tag-create'] = withMutation(async function ({ tag }) {
diff --git a/packages/loot-core/src/server/models.ts b/packages/loot-core/src/server/models.ts
index 829f6a43fc..c07476b04b 100644
--- a/packages/loot-core/src/server/models.ts
+++ b/packages/loot-core/src/server/models.ts
@@ -156,7 +156,7 @@ export const categoryGroupModel = {
...categoryGroupEntity,
categories: categories
.filter(category => category.cat_group === categoryGroup.id)
- .map(categoryModel.fromDb),
+ .map(c => categoryModel.fromDb(c)),
};
},
};
diff --git a/packages/loot-core/src/server/payees/app.ts b/packages/loot-core/src/server/payees/app.ts
index d73c73e70d..d04d2bd909 100644
--- a/packages/loot-core/src/server/payees/app.ts
+++ b/packages/loot-core/src/server/payees/app.ts
@@ -60,12 +60,12 @@ async function createPayee({ name }: { name: PayeeEntity['name'] }) {
async function getCommonPayees(): Promise<PayeeEntity[]> {
// TODO: Update to an AQL query. Server must return AQL entities not the raw DB data.
- return (await db.getCommonPayees()).map(payeeModel.fromDb);
+ return (await db.getCommonPayees()).map(p => payeeModel.fromDb(p));
}
async function getPayees(): Promise<PayeeEntity[]> {
// TODO: Update to an AQL query. Server must return AQL entities not the raw DB data.
- return (await db.getPayees()).map(payeeModel.fromDb);
+ return (await db.getPayees()).map(p => payeeModel.fromDb(p));
}
async function getOrphanedPayees(): Promise<Array<Pick<PayeeEntity, 'id'>>> {
diff --git a/packages/loot-core/src/server/reports/app.ts b/packages/loot-core/src/server/reports/app.ts
index 5d0ad04fff..d3993bb18e 100644
--- a/packages/loot-core/src/server/reports/app.ts
+++ b/packages/loot-core/src/server/reports/app.ts
@@ -97,7 +97,7 @@ async function getReports() {
const { data }: { data: CustomReportData[] } = await aqlQuery(
q('custom_reports').select('*'),
);
- return sort(data.map(reportModel.toJS));
+ return sort(data.map(r => reportModel.toJS(r)));
}
async function reportNameExists(
diff --git a/packages/sync-server/src/app-sync/services/files-service.js b/packages/sync-server/src/app-sync/services/files-service.js
index 3138180a73..242dd90ad6 100644
--- a/packages/sync-server/src/app-sync/services/files-service.js
+++ b/packages/sync-server/src/app-sync/services/files-service.js
@@ -142,7 +142,7 @@ class FilesService {
WHERE files.deleted = 0 LIMIT ?`,
[userId, userId, limit],
)
- ).map(this.validate);
+ ).map(item => this.validate(item));
}
findUsersWithAccess(fileId) {
diff --git a/upcoming-release-notes/7163.md b/upcoming-release-notes/7163.md
new file mode 100644
index 0000000000..ce8c187ea2
--- /dev/null
+++ b/upcoming-release-notes/7163.md
@@ -0,0 +1,6 @@
+---
+category: Maintenance
+authors: [MatissJanis]
+---
+
+Lint: fix typescript/unbound-method issues