From 3d3fdd74256c2f968c06f58c0802f22c704f0103 Mon Sep 17 00:00:00 2001 From: Jean-Baptiste Dominguez Date: Fri, 7 Sep 2018 15:31:54 +0900 Subject: [PATCH 1/7] Fix languages --- src/js/services/uxLanguage.js | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/js/services/uxLanguage.js b/src/js/services/uxLanguage.js index 1fa446f01..b8e7c3b09 100644 --- a/src/js/services/uxLanguage.js +++ b/src/js/services/uxLanguage.js @@ -10,7 +10,7 @@ angular.module('copayApp.services') isoCode: 'en', rateCode: 'USD' }, { - name: 'català', + name: 'Català', isoCode: 'ca', rateCode: 'EUR' },{ @@ -59,10 +59,6 @@ angular.module('copayApp.services') name: 'Português', isoCode: 'pt', rateCode: 'EUR' - }, { - name: 'русский язык', - isoCode: 'ru', - rateCode: 'RUB' }, { name: '한국어', isoCode: 'ko', From 101e33ec367c3c3ea1e3103384b66bef986c5488 Mon Sep 17 00:00:00 2001 From: Brendon Duncan Date: Mon, 10 Sep 2018 20:26:13 +1200 Subject: [PATCH 2/7] Remove Games link on Android. --- src/js/services/bitcoincomService.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/js/services/bitcoincomService.js b/src/js/services/bitcoincomService.js index 68fd51a8a..62a75b4d1 100644 --- a/src/js/services/bitcoincomService.js +++ b/src/js/services/bitcoincomService.js @@ -85,7 +85,9 @@ angular.module('copayApp.services').factory('bitcoincomService', function(gettex }; var register = function() { - nextStepsService.register(cashGamesItem); + if (!platformInfo.isAndroid) { // To comply with Google Play policies + nextStepsService.register(cashGamesItem); + } nextStepsService.register(newsItem); nextStepsService.register(poolItem); nextStepsService.register(toolsItem); From 8bc73353d5154d9476d79fb57992cacfc6791f41 Mon Sep 17 00:00:00 2001 From: Brendon Duncan Date: Mon, 10 Sep 2018 20:26:33 +1200 Subject: [PATCH 3/7] Run command for Android emulator. --- Gruntfile.js | 4 ++++ app-template/package-template.json | 1 + 2 files changed, 5 insertions(+) diff --git a/Gruntfile.js b/Gruntfile.js index 160db85d5..1092b3de2 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -65,6 +65,9 @@ module.exports = function(grunt) { run_android: { command: 'cordova run android --device', }, + run_android_emulator: { + command: 'cordova run android --emulator', + }, sign_android: { // When the build log outputs "Built the following apk(s):", it seems to need the filename to start with "android-release". // It looks like it simply lists all apk files starting with "android-release" @@ -370,6 +373,7 @@ module.exports = function(grunt) { // Build android grunt.registerTask('start-android', ['build-android-debug', 'exec:run_android']); grunt.registerTask('build-android-debug', ['exec:build_android_debug']); + grunt.registerTask('start-android-emulator', ['build-android-debug', 'exec:run_android_emulator']); grunt.registerTask('build-android-release', ['prod', 'exec:build_android_release', 'sign-android']); grunt.registerTask('sign-android', ['exec:sign_android']); diff --git a/app-template/package-template.json b/app-template/package-template.json index 200c269f6..11b15bfcd 100644 --- a/app-template/package-template.json +++ b/app-template/package-template.json @@ -126,6 +126,7 @@ "start": "npm run build:www && ionic serve --nolivereload --nogulp -s --address 0.0.0.0", "start:chrome": "npm run build:www && ionic serve --nolivereload --nogulp -s --address 0.0.0.0 --browser \"google chrome\"", "start:android": "grunt start-android", + "start:android-emulator": "grunt start-android", "start:android-log": "grunt start-android && npm run log:android", "start:ios": "grunt start-ios", "start:windows": "npm run build:www && npm run build:windows", From ac82b51848235b4b39f41385bbb993407a582dee Mon Sep 17 00:00:00 2001 From: Brendon Duncan Date: Sat, 15 Sep 2018 14:45:39 +1200 Subject: [PATCH 4/7] Takes into account size of current transaction list when determining if overlap in transactions is enough to assume all have been retrieved. --- src/js/services/wallet-history.service.js | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/js/services/wallet-history.service.js b/src/js/services/wallet-history.service.js index e10e763e9..7a6f18a13 100644 --- a/src/js/services/wallet-history.service.js +++ b/src/js/services/wallet-history.service.js @@ -12,9 +12,9 @@ // How much to overlap on each end of the page, for mitigating inconsistent sort order. var PAGE_OVERLAP_FRACTION = 0.2; var PAGE_OVERLAP = Math.floor(PAGE_SIZE * PAGE_OVERLAP_FRACTION); - // The amount of transactions in the new overlapping resultset that we already know about. + // The fraction of transactions in the new overlapping resultset that we already know about. // If we know about at least this many, then there are probably no gaps. - var MIN_KNOWN_TX_OVERLAP = Math.floor(PAGE_OVERLAP * 0.5); + var MIN_KNOWN_TX_OVERLAP_FRACTION = 0.5; var SAFE_CONFIRMATIONS = 6; @@ -44,7 +44,10 @@ } }); - if (overlappingTxsCount >= MIN_KNOWN_TX_OVERLAP) { // We are good + var overlappingTxFraction = overlappingTxsCount / Math.min(cachedTxs.length, PAGE_OVERLAP); + console.log('overlappingTxFraction:', overlappingTxFraction); + + if (overlappingTxFraction >= MIN_KNOWN_TX_OVERLAP_FRACTION) { // We are good if (someTransactionsWereNew) { saveTxHistory(walletId, cachedTxs); } else if (overlappingTxsCount === newTxs.length) { @@ -80,7 +83,9 @@ } }); - if (overlappingTxsCount >= MIN_KNOWN_TX_OVERLAP) { // We are good + var overlappingTxFraction = overlappingTxsCount / Math.min(cachedTxs.length, PAGE_OVERLAP); + + if (overlappingTxFraction >= MIN_KNOWN_TX_OVERLAP_FRACTION) { // We are good if (someTransactionsWereNew) { var allTxs = uniqueNewTxs.concat(cachedTxs); saveTxHistory(walletId, allTxs); From ebc32a2d85867f3db73a0fd2a356ba2ec8543b64 Mon Sep 17 00:00:00 2001 From: Brendon Duncan Date: Sun, 16 Sep 2018 21:04:41 -0700 Subject: [PATCH 5/7] Added 'default' to mobile debug build configs. --- Gruntfile.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Gruntfile.js b/Gruntfile.js index 1092b3de2..7968f2510 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -366,13 +366,13 @@ module.exports = function(grunt) { grunt.registerTask('build-mobile-release', ['build-ios-release', 'build-android-release']); // Build ios - grunt.registerTask('start-ios', ['exec:build_ios_debug', 'exec:xcode']); - grunt.registerTask('build-ios-debug', ['exec:build_ios_debug']); + grunt.registerTask('start-ios', ['default', 'exec:build_ios_debug', 'exec:xcode']); + grunt.registerTask('build-ios-debug', ['default', 'exec:build_ios_debug']); grunt.registerTask('build-ios-release', ['prod', 'exec:build_ios_release']); // Build android grunt.registerTask('start-android', ['build-android-debug', 'exec:run_android']); - grunt.registerTask('build-android-debug', ['exec:build_android_debug']); + grunt.registerTask('build-android-debug', ['default', 'exec:build_android_debug']); grunt.registerTask('start-android-emulator', ['build-android-debug', 'exec:run_android_emulator']); grunt.registerTask('build-android-release', ['prod', 'exec:build_android_release', 'sign-android']); grunt.registerTask('sign-android', ['exec:sign_android']); From 3cad7d7ad86f4f723b73f0033e67d377391c9d6f Mon Sep 17 00:00:00 2001 From: Sebastiaan Pasma Date: Thu, 20 Sep 2018 15:58:42 +0200 Subject: [PATCH 6/7] Update confirmations on cached transactions --- src/js/services/wallet-history.service.js | 24 +++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/src/js/services/wallet-history.service.js b/src/js/services/wallet-history.service.js index 7a6f18a13..0738d4348 100644 --- a/src/js/services/wallet-history.service.js +++ b/src/js/services/wallet-history.service.js @@ -66,16 +66,21 @@ function addLatestTransactions(walletId, cachedTxs, newTxs) { var cachedTxIds = {}; - cachedTxs.forEach(function forCachedTx(tx){ - cachedTxIds[tx.txid] = true; + cachedTxs.forEach(function forCachedTx(tx, txIndex){ + cachedTxIds[tx.txid] = txIndex; }); var someTransactionsWereNew = false; + var confirmationsUpdated = false; var overlappingTxsCount = 0; var uniqueNewTxs = []; newTxs.forEach(function forNewTx(tx){ - if (cachedTxIds[tx.txid]) { + if (typeof cachedTxIds[tx.txid] !== "undefined") { + if (cachedTxs[cachedTxIds[tx.txid]].confirmations < SAFE_CONFIRMATIONS && tx.confirmations >= SAFE_CONFIRMATIONS) { + cachedTxs[cachedTxIds[tx.txid]].confirmations = tx.confirmations; + confirmationsUpdated = true; + } overlappingTxsCount++; } else { someTransactionsWereNew = true; @@ -91,6 +96,9 @@ saveTxHistory(walletId, allTxs); return allTxs; } else { + if (confirmationsUpdated) { + saveTxHistory(walletId, cachedTxs); + } return cachedTxs; } } else { @@ -104,6 +112,8 @@ // Only clear the cache once we have received new transactions from the server. /** + * @param wallet + * @param start * @param {function(err, txs)} cb - transactions is always an array, may be empty */ function fetchTxHistoryByPage(wallet, start, cb) { @@ -187,7 +197,7 @@ }); return processedTxs; - }; + } function saveTxHistory(walletId, processedTxs) { storageService.setTxHistory(processedTxs, walletId, function onSetTxHistory(error){ @@ -197,7 +207,6 @@ }); } - function updateLocalTxHistoryByPage(wallet, getLatest, flushCacheOnNew, cb) { if (flushCacheOnNew) { @@ -240,10 +249,5 @@ }); } } - - - } - - })(); \ No newline at end of file From ea51e035abd3fe8066669c1e13faed876b04404b Mon Sep 17 00:00:00 2001 From: Brendon Duncan Date: Fri, 21 Sep 2018 03:56:51 -0700 Subject: [PATCH 7/7] Fixed updating of confirmations of cached transactions. Cache now properly cleared on first fetch from Wallet Details screen. --- .../controllers/wallet-details.controller.js | 4 +- src/js/services/wallet-history.service.js | 50 +++++++++++++------ 2 files changed, 37 insertions(+), 17 deletions(-) diff --git a/src/js/controllers/wallet-details.controller.js b/src/js/controllers/wallet-details.controller.js index f3109db8b..cef57925e 100644 --- a/src/js/controllers/wallet-details.controller.js +++ b/src/js/controllers/wallet-details.controller.js @@ -400,8 +400,8 @@ angular.module('copayApp.controllers').controller('walletDetailsController', fun var refreshInterval; - $scope.$on("$ionicView.afterEnter", function(event, data) { - $scope.updateAll(); + $scope.$on("$ionicView.afterEnter", function onAfterEnter(event, data) { + $scope.updateAll(true, true); // refreshAmountSection(); refreshInterval = $interval($scope.onRefresh, 10 * 1000); $timeout(function() { diff --git a/src/js/services/wallet-history.service.js b/src/js/services/wallet-history.service.js index 0738d4348..13fc8d636 100644 --- a/src/js/services/wallet-history.service.js +++ b/src/js/services/wallet-history.service.js @@ -27,20 +27,23 @@ function addEarlyTransactions(walletId, cachedTxs, newTxs) { - var cachedTxIds = {}; + var cachedTxIndexFromId = {}; cachedTxs.forEach(function forCachedTx(tx){ - cachedTxIds[tx.txid] = true; + cachedTxIndexFromId[tx.txid] = true; }); + var confirmationsUpdated = false; var someTransactionsWereNew = false; var overlappingTxsCount = 0; newTxs.forEach(function forNewTx(tx){ - if (cachedTxIds[tx.txid]) { - overlappingTxsCount++; - } else { + if (typeof cachedTxIndexFromId[tx.txid] === "undefined") { someTransactionsWereNew = true; cachedTxs.push(tx); + } else { + var txUpdated = updateCachedTx(cachedTxs, cachedTxIndexFromId, tx); + confirmationsUpdated = confirmationsUpdated || txUpdated; + overlappingTxsCount++; } }); @@ -50,6 +53,8 @@ if (overlappingTxFraction >= MIN_KNOWN_TX_OVERLAP_FRACTION) { // We are good if (someTransactionsWereNew) { saveTxHistory(walletId, cachedTxs); + } else if (confirmationsUpdated) { + saveTxHistory(walletId, cachedTxs); } else if (overlappingTxsCount === newTxs.length) { allTransactionsFetched = true; } @@ -65,9 +70,9 @@ } function addLatestTransactions(walletId, cachedTxs, newTxs) { - var cachedTxIds = {}; + var cachedTxIndexFromId = {}; cachedTxs.forEach(function forCachedTx(tx, txIndex){ - cachedTxIds[tx.txid] = txIndex; + cachedTxIndexFromId[tx.txid] = txIndex; }); var someTransactionsWereNew = false; @@ -76,15 +81,13 @@ var uniqueNewTxs = []; newTxs.forEach(function forNewTx(tx){ - if (typeof cachedTxIds[tx.txid] !== "undefined") { - if (cachedTxs[cachedTxIds[tx.txid]].confirmations < SAFE_CONFIRMATIONS && tx.confirmations >= SAFE_CONFIRMATIONS) { - cachedTxs[cachedTxIds[tx.txid]].confirmations = tx.confirmations; - confirmationsUpdated = true; - } - overlappingTxsCount++; - } else { + if (typeof cachedTxIndexFromId[tx.txid] === "undefined") { someTransactionsWereNew = true; uniqueNewTxs.push(tx); + } else { + var txUpdated = updateCachedTx(cachedTxs, cachedTxIndexFromId, tx); + confirmationsUpdated = confirmationsUpdated || txUpdated; + overlappingTxsCount++; } }); @@ -207,8 +210,25 @@ }); } - function updateLocalTxHistoryByPage(wallet, getLatest, flushCacheOnNew, cb) { + /** + * Returns true if the cached tx was updated + * @param {*} cachedTxs + * @param {*} cachedTxIndexFromId - Indices for cachedTxs, based on txid + * @param {*} tx - The most recent tx info + */ + function updateCachedTx(cachedTxs, cachedTxIndexFromId, tx) { + var updated = false; + var txIndex = cachedTxIndexFromId[tx.txid]; + var cachedTx = cachedTxs[txIndex]; + if (cachedTx.confirmations < SAFE_CONFIRMATIONS && tx.confirmations > cachedTx.confirmations) { + cachedTxs[txIndex].confirmations = tx.confirmations; + updated = true; + } + return updated; + } + + function updateLocalTxHistoryByPage(wallet, getLatest, flushCacheOnNew, cb) { if (flushCacheOnNew) { fetchTxHistoryByPage(wallet, 0, function onFetchTxHistory(err, txs){ if (err) {