mirror of
https://github.com/BlueWallet/BlueWallet.git
synced 2025-02-24 07:28:07 +01:00
Merge branch 'master' into amountregex
This commit is contained in:
commit
c335b64b42
9 changed files with 70 additions and 29 deletions
|
@ -44,6 +44,17 @@ async function connectMain() {
|
|||
usingPeer = savedPeer;
|
||||
}
|
||||
|
||||
try {
|
||||
await DefaultPreference.setName('group.io.bluewallet.bluewallet');
|
||||
await DefaultPreference.set(AppStorage.ELECTRUM_HOST, usingPeer.host);
|
||||
await DefaultPreference.set(AppStorage.ELECTRUM_TCP_PORT, usingPeer.tcp);
|
||||
await DefaultPreference.set(AppStorage.ELECTRUM_SSL_PORT, usingPeer.ssl);
|
||||
RNWidgetCenter.reloadAllTimelines();
|
||||
} catch (e) {
|
||||
// Must be running on Android
|
||||
console.log(e);
|
||||
}
|
||||
|
||||
try {
|
||||
console.log('begin connection:', JSON.stringify(usingPeer));
|
||||
mainClient = new ElectrumClient(usingPeer.ssl || usingPeer.tcp, usingPeer.host, usingPeer.ssl ? 'tls' : 'tcp');
|
||||
|
@ -105,17 +116,6 @@ async function getSavedPeer() {
|
|||
const host = await AsyncStorage.getItem(AppStorage.ELECTRUM_HOST);
|
||||
const port = await AsyncStorage.getItem(AppStorage.ELECTRUM_TCP_PORT);
|
||||
const sslPort = await AsyncStorage.getItem(AppStorage.ELECTRUM_SSL_PORT);
|
||||
try {
|
||||
await DefaultPreference.setName('group.io.bluewallet.bluewallet');
|
||||
await DefaultPreference.set(AppStorage.ELECTRUM_HOST, host);
|
||||
await DefaultPreference.set(AppStorage.ELECTRUM_TCP_PORT, port);
|
||||
await DefaultPreference.set(AppStorage.ELECTRUM_SSL_PORT, sslPort);
|
||||
RNWidgetCenter.reloadAllTimelines();
|
||||
} catch (e) {
|
||||
// Must be running on Android
|
||||
console.log(e);
|
||||
}
|
||||
|
||||
return { host, tcp: port, ssl: sslPort };
|
||||
}
|
||||
|
||||
|
|
|
@ -9,6 +9,7 @@ const constants = require('./constants');
|
|||
const PUSH_TOKEN = 'PUSH_TOKEN';
|
||||
const GROUNDCONTROL_BASE_URI = 'GROUNDCONTROL_BASE_URI';
|
||||
const NOTIFICATIONS_STORAGE = 'NOTIFICATIONS_STORAGE';
|
||||
const NOTIFICATIONS_NO_AND_DONT_ASK_FLAG = 'NOTIFICATIONS_NO_AND_DONT_ASK_FLAG';
|
||||
let alreadyConfigured = false;
|
||||
let baseURI = constants.groundControlUri;
|
||||
|
||||
|
@ -118,6 +119,10 @@ function Notifications(props) {
|
|||
});
|
||||
};
|
||||
|
||||
Notifications.cleanUserOptOutFlag = async function () {
|
||||
return AsyncStorage.removeItem(NOTIFICATIONS_NO_AND_DONT_ASK_FLAG);
|
||||
};
|
||||
|
||||
/**
|
||||
* Should be called when user is most interested in receiving push notifications.
|
||||
* If we dont have a token it will show alert asking whether
|
||||
|
@ -134,13 +139,26 @@ function Notifications(props) {
|
|||
return true;
|
||||
}
|
||||
|
||||
if (await AsyncStorage.getItem(NOTIFICATIONS_NO_AND_DONT_ASK_FLAG)) {
|
||||
// user doesnt want them
|
||||
return false;
|
||||
}
|
||||
|
||||
return new Promise(function (resolve) {
|
||||
Alert.alert(
|
||||
loc.settings.notifications,
|
||||
'Would you like to receive notifications when you get incoming payments?',
|
||||
loc.notifications.would_you_like_to_receive_notifications,
|
||||
[
|
||||
{
|
||||
text: 'Ask Me Later',
|
||||
text: loc.notifications.no_and_dont_ask,
|
||||
onPress: () => {
|
||||
AsyncStorage.setItem(NOTIFICATIONS_NO_AND_DONT_ASK_FLAG, '1');
|
||||
resolve(false);
|
||||
},
|
||||
style: 'cancel',
|
||||
},
|
||||
{
|
||||
text: loc.notifications.ask_me_later,
|
||||
onPress: () => {
|
||||
resolve(false);
|
||||
},
|
||||
|
|
|
@ -33,14 +33,13 @@ export const BlueStorageProvider = ({ children }) => {
|
|||
const refreshAllWalletTransactions = async lastSnappedTo => {
|
||||
let noErr = true;
|
||||
try {
|
||||
// await BlueElectrum.ping();
|
||||
await BlueElectrum.waitTillConnected();
|
||||
const balanceStart = +new Date();
|
||||
await fetchWalletBalances(lastSnappedTo || 0);
|
||||
await fetchWalletBalances(lastSnappedTo);
|
||||
const balanceEnd = +new Date();
|
||||
console.log('fetch balance took', (balanceEnd - balanceStart) / 1000, 'sec');
|
||||
const start = +new Date();
|
||||
await fetchWalletTransactions(lastSnappedTo || 0);
|
||||
await fetchWalletTransactions(lastSnappedTo);
|
||||
const end = +new Date();
|
||||
console.log('fetch tx took', (end - start) / 1000, 'sec');
|
||||
} catch (err) {
|
||||
|
|
|
@ -290,6 +290,11 @@
|
|||
"save": "Save",
|
||||
"saved": "Saved"
|
||||
},
|
||||
"notifications": {
|
||||
"would_you_like_to_receive_notifications": "Would you like to receive notifications when you get incoming payments?",
|
||||
"no_and_dont_ask": "No and dont ask",
|
||||
"ask_me_later": "Ask Me Later"
|
||||
},
|
||||
"transactions": {
|
||||
"cancel_explain": "We will replace this transaction with the one that pays you and has higher fees. This effectively cancels transaction. This is called RBF - Replace By Fee.",
|
||||
"cancel_no": "This transaction is not replaceable",
|
||||
|
|
10
package-lock.json
generated
10
package-lock.json
generated
|
@ -18096,9 +18096,9 @@
|
|||
"optional": true
|
||||
},
|
||||
"prettier": {
|
||||
"version": "2.1.1",
|
||||
"resolved": "https://registry.npmjs.org/prettier/-/prettier-2.1.1.tgz",
|
||||
"integrity": "sha512-9bY+5ZWCfqj3ghYBLxApy2zf6m+NJo5GzmLTpr9FsApsfjriNnS2dahWReHMi7qNPhhHl9SYHJs2cHZLgexNIw=="
|
||||
"version": "2.1.2",
|
||||
"resolved": "https://registry.npmjs.org/prettier/-/prettier-2.1.2.tgz",
|
||||
"integrity": "sha512-16c7K+x4qVlJg9rEbXl7HEGmQyZlG4R9AgP+oHKRMsMsuk8s+ATStlf1NpDqyBI1HpVyfjLOeMhH2LvuNvV5Vg=="
|
||||
},
|
||||
"prettier-linter-helpers": {
|
||||
"version": "1.0.0",
|
||||
|
@ -19091,8 +19091,8 @@
|
|||
"integrity": "sha512-vJzJE3zI1XUtqthrX3Dh2TBQWB+xFyaGhF52KBq9FjJUN5ws4xpLZJxBWa1KbGV3DilmcSZ4jmZR5LGordwE7w=="
|
||||
},
|
||||
"react-native-secure-key-store": {
|
||||
"version": "git+https://github.com/BlueWallet/react-native-secure-key-store.git#4ba25dedb3d5ae15c22fd0ea0555116055630966",
|
||||
"from": "git+https://github.com/BlueWallet/react-native-secure-key-store.git#4ba25dedb3d5ae15c22fd0ea0555116055630966"
|
||||
"version": "git+https://github.com/BlueWallet/react-native-secure-key-store.git#4828fd1a67d12e4c0e21eee0bee673fde75e6f9a",
|
||||
"from": "git+https://github.com/BlueWallet/react-native-secure-key-store.git#4828fd1a67d12e4c0e21eee0bee673fde75e6f9a"
|
||||
},
|
||||
"react-native-share": {
|
||||
"version": "4.0.2",
|
||||
|
|
|
@ -111,7 +111,7 @@
|
|||
"path-browserify": "1.0.1",
|
||||
"payjoin-client": "git+https://github.com/bitcoinjs/payjoin-client.git#31d2118a4c0d00192d975f3a6da2a96238f8f7a5",
|
||||
"pbkdf2": "3.1.1",
|
||||
"prettier": "2.1.1",
|
||||
"prettier": "2.1.2",
|
||||
"process": "0.11.10",
|
||||
"prop-types": "15.7.2",
|
||||
"react": "16.13.1",
|
||||
|
@ -147,7 +147,7 @@
|
|||
"react-native-reanimated": "1.13.1",
|
||||
"react-native-safe-area-context": "3.1.8",
|
||||
"react-native-screens": "2.11.0",
|
||||
"react-native-secure-key-store": "git+https://github.com/BlueWallet/react-native-secure-key-store.git#4ba25dedb3d5ae15c22fd0ea0555116055630966",
|
||||
"react-native-secure-key-store": "git+https://github.com/BlueWallet/react-native-secure-key-store.git#4828fd1a67d12e4c0e21eee0bee673fde75e6f9a",
|
||||
"react-native-share": "4.0.2",
|
||||
"react-native-snap-carousel": "3.9.1",
|
||||
"react-native-sortable-list": "0.0.24",
|
||||
|
|
|
@ -30,6 +30,7 @@ const NotificationSettings = () => {
|
|||
setNotificationsEnabled(value); // so the slider is not 'jumpy'
|
||||
if (value) {
|
||||
// user is ENABLING notifications
|
||||
await Notifications.cleanUserOptOutFlag();
|
||||
if (await Notifications.getPushToken()) {
|
||||
// we already have a token, so we just need to reenable ALL level on groundcontrol:
|
||||
await Notifications.setLevels(true);
|
||||
|
|
|
@ -33,7 +33,6 @@ const A = require('../../blue_modules/analytics');
|
|||
const LocalQRCode = require('@remobile/react-native-qrcode-local-image');
|
||||
|
||||
const WalletsListSections = { CAROUSEL: 'CAROUSEL', LOCALTRADER: 'LOCALTRADER', TRANSACTIONS: 'TRANSACTIONS' };
|
||||
let lastSnappedTo = 0;
|
||||
const isDesktop = getSystemName() === 'Mac OS X';
|
||||
|
||||
const WalletsList = () => {
|
||||
|
@ -135,14 +134,20 @@ const WalletsList = () => {
|
|||
};
|
||||
|
||||
/**
|
||||
* Forcefully fetches TXs and balance for lastSnappedTo (i.e. current) wallet.
|
||||
* Forcefully fetches TXs and balance for ALL wallets.
|
||||
* Triggered manually by user on pull-to-refresh.
|
||||
*/
|
||||
const refreshTransactions = () => {
|
||||
setIsLoading(true);
|
||||
refreshAllWalletTransactions(lastSnappedTo).finally(() => setIsLoading(false));
|
||||
refreshAllWalletTransactions().finally(() => setIsLoading(false));
|
||||
};
|
||||
|
||||
useEffect(
|
||||
refreshTransactions,
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
[],
|
||||
); // call refreshTransactions() only once, when screen mounts
|
||||
|
||||
const handleClick = index => {
|
||||
console.log('click', index);
|
||||
const wallet = carouselData[index];
|
||||
|
@ -186,7 +191,11 @@ const WalletsList = () => {
|
|||
|
||||
const onSnapToItem = index => {
|
||||
console.log('onSnapToItem', index);
|
||||
lastSnappedTo = index;
|
||||
if (wallets[index] && (wallets[index].timeToRefreshBalance() || wallets[index].timeToRefreshTransaction())) {
|
||||
console.log(wallets[index].getLabel(), 'thinks its time to refresh either balance or transactions. refetching both');
|
||||
setIsLoading(true);
|
||||
refreshAllWalletTransactions(index).finally(() => setIsLoading(false));
|
||||
}
|
||||
};
|
||||
|
||||
const renderListHeaderComponent = () => {
|
||||
|
@ -222,6 +231,7 @@ const WalletsList = () => {
|
|||
};
|
||||
|
||||
const renderLocalTrader = () => {
|
||||
if (carouselData.every(wallet => wallet === false)) return null;
|
||||
if (carouselData.length > 0 && !carouselData.some(wallet => wallet.type === PlaceholderWallet.type)) {
|
||||
return (
|
||||
<TouchableOpacity
|
||||
|
|
|
@ -15,8 +15,15 @@ export default class WalletMigrate {
|
|||
// 0: Let's start!
|
||||
async start() {
|
||||
if (Platform.OS === 'ios') {
|
||||
const defaultPreferenceGroupName = await DefaultPreference.getName();
|
||||
console.log('----- defaultPreferenceGroupName');
|
||||
console.log(defaultPreferenceGroupName);
|
||||
console.log('----- ');
|
||||
const isNotFirstLaunch = await DefaultPreference.get('RnSksIsAppInstalled');
|
||||
if (!isNotFirstLaunch) {
|
||||
console.log('----- isNotFirstLaunch');
|
||||
console.log(isNotFirstLaunch);
|
||||
console.log('----- ');
|
||||
if (isNotFirstLaunch === undefined) {
|
||||
try {
|
||||
console.warn('It is the first launch...');
|
||||
await RNSecureKeyStore.setResetOnAppUninstallTo(false);
|
||||
|
@ -26,10 +33,11 @@ export default class WalletMigrate {
|
|||
console.log('----- ');
|
||||
await RNSecureKeyStore.setResetOnAppUninstallTo(deleteWalletsFromKeychain === '1');
|
||||
await RNSecureKeyStore.get(AppStorage.DELETE_WALLET_AFTER_UNINSTALL);
|
||||
await DefaultPreference.set('RnSksIsAppInstalled', '1');
|
||||
} catch (e) {
|
||||
console.log(e);
|
||||
}
|
||||
} else {
|
||||
console.warn('It is NOT the first launch...');
|
||||
}
|
||||
await DefaultPreference.set('RnSksIsAppInstalled', '1');
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue