Skip to content

Commit

Permalink
Merge pull request #2808 from myxmaster/spread_operator_for_updateset…
Browse files Browse the repository at this point in the history
…tings

Use spread operator for updateSettings()
  • Loading branch information
kaloudis authored Feb 7, 2025
2 parents cbe13eb + 7ea87cf commit d0b606d
Show file tree
Hide file tree
Showing 8 changed files with 87 additions and 371 deletions.
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

0 comments on commit d0b606d

Please sign in to comment.