Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Use spread operator for updateSettings() #2808

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 8 additions & 15 deletions views/Settings/ChannelsSettings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ export default class ChannelsSettings extends React.Component<
simpleTaprootChannel,
lsps1ShowPurchaseButton
} = this.state;
const { updateSettings }: any = SettingsStore;
const { settings, updateSettings }: any = SettingsStore;

return (
<Screen>
Expand Down Expand Up @@ -126,10 +126,8 @@ export default class ChannelsSettings extends React.Component<
});
await updateSettings({
channels: {
min_confs: newMinConfs,
privateChannel,
scidAlias,
simpleTaprootChannel
...settings.channels,
min_confs: newMinConfs
}
});
}}
Expand Down Expand Up @@ -157,10 +155,8 @@ export default class ChannelsSettings extends React.Component<
});
await updateSettings({
channels: {
min_confs,
privateChannel: !privateChannel,
scidAlias,
simpleTaprootChannel
...settings.channels,
privateChannel: !privateChannel
}
});
}}
Expand Down Expand Up @@ -194,10 +190,8 @@ export default class ChannelsSettings extends React.Component<
});
await updateSettings({
channels: {
min_confs,
privateChannel,
scidAlias: !scidAlias,
simpleTaprootChannel
...settings.channels,
scidAlias: !scidAlias
}
});
}}
Expand Down Expand Up @@ -239,12 +233,11 @@ export default class ChannelsSettings extends React.Component<

await updateSettings({
channels: {
min_confs,
...settings.channels,
privateChannel:
!simpleTaprootChannel
? true
: privateChannel,
scidAlias,
simpleTaprootChannel:
!simpleTaprootChannel
}
Expand Down
63 changes: 14 additions & 49 deletions views/Settings/Display.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ export default class Display extends React.Component<
showMillisatoshiAmounts,
selectNodeOnStartup
} = this.state;
const { updateSettings }: any = SettingsStore;
const { settings, updateSettings }: any = SettingsStore;

return (
<Screen>
Expand Down Expand Up @@ -127,13 +127,8 @@ export default class Display extends React.Component<
});
await updateSettings({
display: {
theme: value,
displayNickname,
bigKeypadButtons,
defaultView,
showAllDecimalPlaces,
removeDecimalSpaces,
showMillisatoshiAmounts
...settings.display,
theme: value
}
});
SystemNavigationBar.setNavigationColor(
Expand All @@ -158,13 +153,8 @@ export default class Display extends React.Component<
});
await updateSettings({
display: {
defaultView: value,
displayNickname,
bigKeypadButtons,
theme,
showAllDecimalPlaces,
removeDecimalSpaces,
showMillisatoshiAmounts
...settings.display,
defaultView: value
}
});
}}
Expand Down Expand Up @@ -194,13 +184,8 @@ export default class Display extends React.Component<
});
await updateSettings({
display: {
defaultView,
theme,
bigKeypadButtons,
displayNickname: !displayNickname,
showAllDecimalPlaces,
removeDecimalSpaces,
showMillisatoshiAmounts
...settings.display,
displayNickname: !displayNickname
}
});
}}
Expand Down Expand Up @@ -231,13 +216,8 @@ export default class Display extends React.Component<
});
await updateSettings({
display: {
defaultView,
theme,
displayNickname,
bigKeypadButtons: !bigKeypadButtons,
showAllDecimalPlaces,
removeDecimalSpaces,
showMillisatoshiAmounts
...settings.display,
bigKeypadButtons: !bigKeypadButtons
}
});
}}
Expand Down Expand Up @@ -269,14 +249,9 @@ export default class Display extends React.Component<
});
await updateSettings({
display: {
defaultView,
theme,
displayNickname,
bigKeypadButtons,
...settings.display,
showAllDecimalPlaces:
!showAllDecimalPlaces,
removeDecimalSpaces,
showMillisatoshiAmounts
!showAllDecimalPlaces
}
});
}}
Expand Down Expand Up @@ -308,14 +283,9 @@ export default class Display extends React.Component<
});
await updateSettings({
display: {
defaultView,
theme,
displayNickname,
bigKeypadButtons,
showAllDecimalPlaces,
...settings.display,
removeDecimalSpaces:
!removeDecimalSpaces,
showMillisatoshiAmounts
!removeDecimalSpaces
}
});
}}
Expand Down Expand Up @@ -347,12 +317,7 @@ export default class Display extends React.Component<
});
await updateSettings({
display: {
defaultView,
theme,
displayNickname,
bigKeypadButtons,
showAllDecimalPlaces,
removeDecimalSpaces,
...settings.display,
showMillisatoshiAmounts:
!showMillisatoshiAmounts
}
Expand Down
93 changes: 18 additions & 75 deletions views/Settings/InvoicesSettings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -98,14 +98,13 @@ export default class InvoicesSettings extends React.Component<
memo,
expiry,
timePeriod,
expirySeconds,
routeHints,
ampInvoice,
blindedPaths,
showCustomPreimageField,
displayAmountOnInvoice
} = this.state;
const { implementation, updateSettings }: any = SettingsStore;
const { implementation, settings, updateSettings }: any = SettingsStore;

const ADDRESS_TYPES = BackendUtils.supportsTaproot()
? [
Expand Down Expand Up @@ -196,15 +195,8 @@ export default class InvoicesSettings extends React.Component<
this.setState({ memo: text });
await updateSettings({
invoices: {
addressType,
memo: text,
expiry,
timePeriod,
expirySeconds,
routeHints,
ampInvoice,
blindedPaths,
showCustomPreimageField
...settings.invoices,
memo: text
}
});
}}
Expand Down Expand Up @@ -256,15 +248,9 @@ export default class InvoicesSettings extends React.Component<
});
await updateSettings({
invoices: {
addressType,
memo,
...settings.invoices,
expiry: text,
timePeriod,
expirySeconds,
routeHints,
ampInvoice,
blindedPaths,
showCustomPreimageField
expirySeconds
}
});
}}
Expand Down Expand Up @@ -322,15 +308,9 @@ export default class InvoicesSettings extends React.Component<

await updateSettings({
invoices: {
addressType,
memo,
expiry,
...settings.invoices,
timePeriod: value,
expirySeconds,
routeHints,
ampInvoice,
blindedPaths,
showCustomPreimageField
expirySeconds
}
});
}}
Expand Down Expand Up @@ -376,15 +356,8 @@ export default class InvoicesSettings extends React.Component<
});
await updateSettings({
invoices: {
addressType,
memo,
expiry,
timePeriod,
expirySeconds,
routeHints: !routeHints,
ampInvoice,
blindedPaths,
showCustomPreimageField
...settings.invoices,
routeHints: !routeHints
}
});
}}
Expand Down Expand Up @@ -431,14 +404,8 @@ export default class InvoicesSettings extends React.Component<
});
await updateSettings({
invoices: {
addressType,
memo,
expiry,
timePeriod,
expirySeconds,
routeHints,
ampInvoice: !ampInvoice,
showCustomPreimageField
...settings.invoices,
ampInvoice: !ampInvoice
}
});
}}
Expand Down Expand Up @@ -487,15 +454,10 @@ export default class InvoicesSettings extends React.Component<

await updateSettings({
invoices: {
addressType,
memo,
expiry,
timePeriod,
expirySeconds,
routeHints: false,
ampInvoice: false,
...settings.invoices,
blindedPaths: !blindedPaths,
showCustomPreimageField
routeHints: false,
ampInvoice: false
}
});
}}
Expand Down Expand Up @@ -536,13 +498,7 @@ export default class InvoicesSettings extends React.Component<
});
await updateSettings({
invoices: {
addressType,
memo,
expiry,
timePeriod,
expirySeconds,
routeHints,
ampInvoice,
...settings.invoices,
showCustomPreimageField:
!showCustomPreimageField
}
Expand Down Expand Up @@ -582,14 +538,7 @@ export default class InvoicesSettings extends React.Component<
});
await updateSettings({
invoices: {
addressType,
memo,
expiry,
timePeriod,
expirySeconds,
routeHints,
ampInvoice,
showCustomPreimageField,
...settings.invoices,
displayAmountOnInvoice:
!displayAmountOnInvoice
}
Expand Down Expand Up @@ -637,14 +586,8 @@ export default class InvoicesSettings extends React.Component<
this.setState({ addressType: d.value });
await updateSettings({
invoices: {
addressType: d.value,
memo,
expiry,
timePeriod,
expirySeconds,
routeHints,
ampInvoice,
showCustomPreimageField
...settings.invoices,
addressType: d.value
}
});
this.modalBoxRef.current?.close();
Expand Down
Loading