Skip to content

Commit 3597586

Browse files
committed
backend: fix unknown account code error after removing device
This fixed unknown account code error described in last commit. The frontend got notified in wrong order when a device is removed. The keystore event was pushed before accounts have been removed, leading to a short moment when the frontend thinks it has accounts but no more keystore. Changed order so that the backend sends the keystore event after accounts are uninitialized.
1 parent fb06d5d commit 3597586

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

backend/backend.go

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -549,16 +549,17 @@ func (backend *Backend) DeregisterKeystore() {
549549
fingerprint, _ := backend.keystore.RootFingerprint()
550550
backend.log.WithField("rootFingerprint", fingerprint).Info("deregistering keystore")
551551
backend.keystore = nil
552-
backend.Notify(observable.Event{
553-
Subject: "keystores",
554-
Action: action.Reload,
555-
})
556552

557-
backend.uninitAccounts()
558553
// TODO: classify accounts by keystore, remove only the ones belonging to the deregistered
559554
// keystore. For now we just remove all, then re-add the rest.
560555
backend.initPersistedAccounts()
561556
backend.emitAccountsStatusChanged()
557+
backend.uninitAccounts()
558+
559+
backend.Notify(observable.Event{
560+
Subject: "keystores",
561+
Action: action.Reload,
562+
})
562563
}
563564

564565
// Register registers the given device at this backend.

0 commit comments

Comments
 (0)