Skip to content

Commit

Permalink
Merge pull request #2192 from myxmaster/fix-navigation-upgrade-regres…
Browse files Browse the repository at this point in the history
…sions

Fix navigation upgrade regressions
  • Loading branch information
kaloudis authored May 22, 2024
2 parents 8800627 + a54b3c9 commit 7abc7a9
Show file tree
Hide file tree
Showing 26 changed files with 101 additions and 99 deletions.
4 changes: 2 additions & 2 deletions stores/SettingsStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { doTorRequest, RequestMethod } from '../utils/TorUtils';
// lndhub
import LoginRequest from './../models/LoginRequest';

interface Node {
export interface Node {
host?: string;
port?: string;
url?: string;
Expand All @@ -20,11 +20,11 @@ interface Node {
certVerification?: boolean;
enableTor?: boolean;
nickname?: string;
photo?: string;
// LNC
pairingPhrase?: string;
mailboxServer?: string;
customMailboxServer?: string;
photo?: string;
}

interface PrivacySettings {
Expand Down
2 changes: 1 addition & 1 deletion utils/PhotoUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ const BTCpay = require('..//assets/images/BTCpay.jpg');
const CLN = require('..//assets/images/CLN.jpg');
const LND = require('..//assets/images/LND.jpg');

const getPhoto = (photo: string | null): string => {
const getPhoto = (photo: string | undefined): string => {
if (typeof photo === 'string' && photo.includes('rnfs://')) {
const fileName = photo.replace('rnfs://', '');
return `file://${RNFS.DocumentDirectoryPath}/${fileName}`;
Expand Down
2 changes: 1 addition & 1 deletion views/Accounts/ImportingAccount.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ export default class ImportingAccount extends React.Component<
master_key_fingerprint,
address_type,
dry_run: false
}).then(() => navigation.navigate('Wallet'))
}).then(() => navigation.popTo('Wallet'))
}
/>
</View>
Expand Down
4 changes: 2 additions & 2 deletions views/Channels/Channel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ export default class ChannelView extends React.Component<
if (implementation === 'lightning-node-connect') {
this.subscribeChannelClose(streamingCall);
} else {
if (!ChannelsStore.closeChannelErr) navigation.navigate('Wallet');
if (!ChannelsStore.closeChannelErr) navigation.popTo('Wallet');
}
};

Expand Down Expand Up @@ -145,7 +145,7 @@ export default class ChannelView extends React.Component<
) {
handleChannelClose();
this.listener = null;
this.props.navigation.navigate('Wallet');
this.props.navigation.popTo('Wallet');
} else {
handleChannelCloseError(new Error(result));
this.listener = null;
Expand Down
2 changes: 1 addition & 1 deletion views/ContactDetails.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ export default class ContactDetails extends React.Component<
);

console.log('Contact imported successfully!');
this.props.navigation.navigate('Contacts', { loading: true });
this.props.navigation.popTo('Contacts');
};

toggleFavorite = () => {
Expand Down
6 changes: 2 additions & 4 deletions views/NostrContacts.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -610,9 +610,7 @@ export default class NostrContacts extends React.Component<
)}
onPress={async () => {
await this.importContacts();
navigation.navigate('Contacts', {
loading: true
});
navigation.popTo('Contacts');
}}
containerStyle={{
paddingBottom: 12,
Expand All @@ -632,7 +630,7 @@ export default class NostrContacts extends React.Component<
}`}
onPress={async () => {
await this.importContacts();
navigation.navigate('Contacts', { loading: true });
navigation.popTo('Contacts');
}}
containerStyle={{ paddingBottom: 12, paddingTop: 8 }}
secondary
Expand Down
5 changes: 2 additions & 3 deletions views/PSBT.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -224,9 +224,8 @@ export default class PSBT extends React.Component<PSBTProps, PSBTState> {
<Screen>
<Header
leftComponent="Back"
onBack={() => {
navigation.navigate('Wallet');
}}
onBack={() => navigation.popTo('Wallet')}
navigateBackOnBackPress={false}
centerComponent={{
text: 'PSBT',
style: { color: themeColor('text') }
Expand Down
2 changes: 1 addition & 1 deletion views/Receive.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1468,7 +1468,7 @@ export default class Receive extends React.Component<
name: 'list',
size: 25
}}
onPress={() => navigation.navigate('Wallet')}
onPress={() => navigation.popTo('Wallet')}
containerStyle={{ width: '100%' }}
/>
</View>
Expand Down
4 changes: 2 additions & 2 deletions views/SendingLightning.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ export default class SendingLightning extends React.Component<
(this.successfullySent(TransactionsStore) ||
this.inTransit(TransactionsStore))
) {
navigation.navigate('Wallet');
navigation.popTo('Wallet');
return true;
}
return false;
Expand Down Expand Up @@ -447,7 +447,7 @@ export default class SendingLightning extends React.Component<
color: themeColor('background')
}}
onPress={() =>
navigation.navigate('Wallet', {
navigation.popTo('Wallet', {
refresh: true
})
}
Expand Down
4 changes: 1 addition & 3 deletions views/SendingOnChain.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -261,9 +261,7 @@ export default class SendingOnChain extends React.Component<
color: themeColor('background')
}}
containerStyle={{ width: '100%' }}
onPress={() =>
navigation.navigate('Wallet')
}
onPress={() => navigation.popTo('Wallet')}
buttonStyle={{ height: 40 }}
/>
)}
Expand Down
6 changes: 3 additions & 3 deletions views/Settings/AddContact.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ export default class AddContact extends React.Component<
);

console.log('Contact updated successfully!');
navigation.navigate('Contacts', { loading: true });
navigation.popTo('Contacts');
} else {
// Creating a new contact
const contactId = uuidv4();
Expand Down Expand Up @@ -200,7 +200,7 @@ export default class AddContact extends React.Component<
);

console.log('Contact saved successfully!');
navigation.navigate('Contacts', { loading: true });
navigation.popTo('Contacts');

// Reset the input fields after saving the contact
this.setState({
Expand Down Expand Up @@ -243,7 +243,7 @@ export default class AddContact extends React.Component<
);

console.log('Contact deleted successfully!');
navigation.navigate('Contacts', { loading: true });
navigation.popTo('Contacts');
} catch (error) {
console.log('Error deleting contact:', error);
}
Expand Down
16 changes: 3 additions & 13 deletions views/Settings/Contacts.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import NostrichIcon from '../../assets/images/SVG/Nostrich.svg';

interface ContactsSettingsProps {
navigation: StackNavigationProp<any, any>;
route: Route<'Contacts', { SendScreen: boolean; loading: boolean }>;
route: Route<'Contacts', { SendScreen: boolean }>;
}

interface ContactsSettingsState {
Expand Down Expand Up @@ -58,16 +58,6 @@ export default class Contacts extends React.Component<
this.props.navigation.addListener('focus', () => this.loadContacts());
}

UNSAFE_componentWillReceiveProps(
nextProps: Readonly<ContactsSettingsProps>
): void {
const loading = nextProps.route.params?.loading;

if (loading) {
this.setState({ loading });
}
}

loadContacts = async () => {
try {
this.setState({ loading: true });
Expand All @@ -86,7 +76,7 @@ export default class Contacts extends React.Component<
}
};

displayAddress = (item) => {
displayAddress = (item: Contact) => {
const contact = new Contact(item);
const {
hasLnAddress,
Expand Down Expand Up @@ -400,7 +390,7 @@ export default class Contacts extends React.Component<
<FlatList
data={nonFavoriteContacts}
renderItem={this.renderContactItem}
keyExtractor={(item, index) => index.toString()}
keyExtractor={(_, index) => index.toString()}
scrollEnabled={false}
/>
{!loading && contacts.length > 1 && (
Expand Down
2 changes: 1 addition & 1 deletion views/Settings/EmbeddedNode/DisasterRecoveryAdvanced.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ export default class DisasterRecoveryAdvanced extends React.Component<
await triggerRecovery(
selected.backup
);
navigation.navigate('Wallet');
navigation.popTo('Wallet');
}
}}
/>
Expand Down
2 changes: 1 addition & 1 deletion views/Settings/EmbeddedNode/RestoreChannelBackups.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ export default class RestoreChannelBackups extends React.Component<
await restoreChannelBackups(
channelBackupsBase64
);
navigation.navigate('Wallet');
navigation.popTo('Wallet');
} catch (e) {
console.log('e', e);
this.setState({
Expand Down
7 changes: 3 additions & 4 deletions views/Settings/LightningAddress/NostrRelays.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -94,10 +94,9 @@ export default class NostrRelays extends React.Component<
<Icon
name="arrow-back"
onPress={() => {
navigation.navigate(
'LightningAddress',
{ relays }
);
navigation.popTo('LightningAddress', {
relays
});
}}
color={themeColor('text')}
underlayColor="transparent"
Expand Down
Loading

0 comments on commit 7abc7a9

Please sign in to comment.