Skip to content

Commit

Permalink
call getSettingsAndNavigate less often
Browse files Browse the repository at this point in the history
  • Loading branch information
myxmaster committed Dec 21, 2024
1 parent 9042771 commit 2779bda
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 4 deletions.
9 changes: 9 additions & 0 deletions stores/SettingsStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1210,6 +1210,7 @@ export default class SettingsStore {
selectNodeOnStartup: false
};
@observable public posStatus: string = 'unselected';
@observable public posWasEnabled: boolean = false;
@observable public loading = false;
@observable btcPayError: string | null;
@observable sponsorsError: string | null;
Expand All @@ -1225,6 +1226,7 @@ export default class SettingsStore {
@observable implementation: Implementations;
@observable certVerification: boolean | undefined;
@observable public loggedIn = false;
@observable public comingFromLockscreen: boolean = false;
@observable public connecting = true;
@observable public lurkerExposed = false;
// LNDHub
Expand Down Expand Up @@ -1661,6 +1663,13 @@ export default class SettingsStore {
...newSetting
};

if (
newSetting.pos?.posEnabled &&
newSetting.pos.posEnabled !== PosEnabled.Disabled
) {
this.posWasEnabled = true;
}

await this.setSettings(JSON.stringify(newSettings));
// ensure we get the enhanced settings set
const settings = await this.getSettings(true);
Expand Down
8 changes: 7 additions & 1 deletion views/Lockscreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -249,8 +249,14 @@ export default class Lockscreen extends React.Component<
} else if (deleteDuressPin) {
this.deleteDuressPin();
} else {
setPosStatus('inactive');
if (
(SettingsStore.settings?.pos?.posEnabled ||
PosEnabled.Disabled) !== PosEnabled.Disabled
) {
setPosStatus('inactive');
}
this.resetAuthenticationAttempts();
SettingsStore.comingFromLockscreen = true;
this.proceed();
}
} else if (
Expand Down
21 changes: 18 additions & 3 deletions views/Wallet/Wallet.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,18 @@ export default class Wallet extends React.Component<WalletProps, WalletState> {
'hardwareBackPress',
this.handleBackButton.bind(this)
);
this.getSettingsAndNavigate();

const { SettingsStore } = this.props;

if (
this.state.initialLoad ||
SettingsStore.posWasEnabled ||
SettingsStore.comingFromLockscreen
) {
this.getSettingsAndNavigate();
SettingsStore.posWasEnabled = false;
SettingsStore.comingFromLockscreen = false;
}
};

private handleBlur = () => this.backPressSubscription?.remove();
Expand Down Expand Up @@ -235,8 +246,12 @@ export default class Wallet extends React.Component<WalletProps, WalletState> {
loginBackground
) {
SettingsStore.setLoginStatus(false);
} else if (nextAppState === 'active' && SettingsStore.loginRequired()) {
this.props.navigation.navigate('Lockscreen');
} else if (nextAppState === 'active') {
if (SettingsStore.loginRequired()) {
this.props.navigation.navigate('Lockscreen');
} else {
this.getSettingsAndNavigate();
}
}
};

Expand Down

0 comments on commit 2779bda

Please sign in to comment.