Skip to content

Commit 54505c3

Browse files
authored
fix: continue to the congrats view if some transaction has migrated the funds successfully (#87)
1 parent 849a49f commit 54505c3

File tree

2 files changed

+36
-4
lines changed

2 files changed

+36
-4
lines changed

packages/shared/lib/migration.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1405,6 +1405,18 @@ export const hasMigratedAndConfirmedAllSelectedBundles = derived(get(migration).
14051405
)
14061406
})
14071407

1408+
/**
1409+
* Determines if some migrated bundles are confirmed
1410+
*/
1411+
export const hasMigratedAndConfirmedSomeSelectedBundles = derived(get(migration).bundles, (_bundles) => {
1412+
const selectedBundles = _bundles.filter((bundle) => bundle.selected === true)
1413+
1414+
return (
1415+
selectedBundles.length &&
1416+
selectedBundles.some((bundle) => bundle.migrated === true && bundle.confirmed === true)
1417+
)
1418+
})
1419+
14081420
/**
14091421
* Total migration balance
14101422
*/

packages/shared/routes/setup/migrate/views/TransferFragmentedFunds.svelte

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
generateMigrationAddress,
1717
hardwareIndexes,
1818
hasMigratedAndConfirmedAllSelectedBundles,
19+
hasMigratedAndConfirmedSomeSelectedBundles,
1920
hasMigratedAnyBundle,
2021
migration,
2122
migrationAddress,
@@ -38,6 +39,7 @@
3839
let migrated = false
3940
let migratingFundsMessage = ''
4041
let fullSuccess = $hasMigratedAndConfirmedAllSelectedBundles
42+
let someSuccess = $hasMigratedAndConfirmedSomeSelectedBundles
4143
4244
const legacyLedger = $walletSetupType === SetupType.TrinityLedger
4345
$: animation = legacyLedger ? 'ledger-migrate-desktop' : 'migrate-desktop'
@@ -66,7 +68,7 @@
6668
busy = false
6769
}
6870
69-
const unsubscribe = hasMigratedAndConfirmedAllSelectedBundles.subscribe(
71+
const hasMigratedAndConfirmedAllSelectedBundlesUnsubscribe = hasMigratedAndConfirmedAllSelectedBundles.subscribe(
7072
(_hasMigratedAndConfirmedAllSelectedBundles) => {
7173
fullSuccess = _hasMigratedAndConfirmedAllSelectedBundles
7274
@@ -79,10 +81,15 @@
7981
}
8082
)
8183
84+
const hasMigratedAndConfirmedSomeSelectedBundlesUnsubscribe = hasMigratedAndConfirmedSomeSelectedBundles.subscribe(
85+
(_hasMigratedAndConfirmedSomeSelectedBundles) => {
86+
someSuccess = _hasMigratedAndConfirmedSomeSelectedBundles
87+
}
88+
)
89+
8290
let migratedAndUnconfirmedBundles = []
8391
84-
// TODO: add missing unsubscribe to onDestroy
85-
confirmedBundles.subscribe((newConfirmedBundles) => {
92+
const confirmedBundlesUnsubscribe = confirmedBundles.subscribe((newConfirmedBundles) => {
8693
newConfirmedBundles.forEach((bundle) => {
8794
if (bundle.confirmed) {
8895
migratedAndUnconfirmedBundles = migratedAndUnconfirmedBundles.filter(
@@ -173,7 +180,11 @@
173180
}
174181
})
175182
176-
onDestroy(unsubscribe)
183+
onDestroy(() => {
184+
hasMigratedAndConfirmedAllSelectedBundlesUnsubscribe()
185+
confirmedBundlesUnsubscribe()
186+
hasMigratedAndConfirmedSomeSelectedBundlesUnsubscribe()
187+
})
177188
178189
function handleMigrateClick() {
179190
if (legacyLedger) {
@@ -319,6 +330,15 @@
319330
<Spinner {busy} message={migratingFundsMessage} classes="justify-center" />
320331
{/if}
321332
</Button>
333+
{:else if someSuccess}
334+
<div class="flex flex-row justify-center items-center py-3 mt-2 w-full space-x-2">
335+
<Button classes="w-1/2 {$popupState.active && 'opacity-20'}" onClick={() => handleRerunClick()}>
336+
{locale('views.transferFragmentedFunds.rerun')}
337+
</Button>
338+
<Button classes="w-1/2" onClick={() => handleContinueClick()}>
339+
{locale('actions.continue')}
340+
</Button>
341+
</div>
322342
{:else if fullSuccess}
323343
<Button classes="w-full py-3 mt-2" onClick={() => handleContinueClick()}
324344
>{locale('actions.continue')}</Button

0 commit comments

Comments
 (0)