aboutsummaryrefslogtreecommitdiff
path: root/source/ui/PinView.mc
diff options
context:
space:
mode:
Diffstat (limited to 'source/ui/PinView.mc')
-rw-r--r--source/ui/PinView.mc62
1 files changed, 45 insertions, 17 deletions
diff --git a/source/ui/PinView.mc b/source/ui/PinView.mc
index af18e2b..da032ad 100644
--- a/source/ui/PinView.mc
+++ b/source/ui/PinView.mc
@@ -16,7 +16,9 @@
// * Entered digits show as dots. A wrong PIN vibrates and shows any wait.
// * Creating or changing the PIN asks twice.
// * Key derivation (about 1 s) runs as a job on a timer, so the screen
-// shows "Checking..." and the watchdog never trips.
+// shows "Checking..." and the watchdog never trips. So does the work
+// after a correct or new PIN (LockJob: pending entries are promoted,
+// waiting "Require PIN" changes applied); its lines go to the results.
// The typed digits are a ByteArray that is wiped after every attempt.
import Toybox.Attention;
@@ -58,6 +60,10 @@ class PinView extends WatchUi.View {
private var _jobPin as ByteArray? = null;
// The running derivation's timer driver (kept so it isn't collected).
var runner as Jobs.JobRunner? = null;
+ private var _lockJob as LockJob? = null;
+ // A LockJob ran for this screen's PIN (a legacy PIN's new PIN runs a
+ // second one, which adds to the first one's lines).
+ private var _lockJobRan as Boolean = false;
private var _ticker as Timer.Timer? = null;
private var _keys as Array<Array<Number>> = [] as Array<Array<Number>>; // [x, y, w, h, key]
private var _shownLogged as Boolean = false;
@@ -79,6 +85,11 @@ class PinView extends WatchUi.View {
}
function onHide() as Void {
+ if (_lockJobRan && _lockJob == null) {
+ // Closed (or replaced): a "Confirm all" that follows has taken
+ // the lock lines already; else they are in the results.
+ ChangeQueue.takeLockLines();
+ }
var ticker = _ticker;
if (ticker != null) {
ticker.stop();
@@ -234,24 +245,16 @@ class PinView extends WatchUi.View {
}
function onUnlockDone() as Void {
- busy = false;
- _shownLogged = false;
Bytes.wipe(_jobPin);
_jobPin = null;
var vault = AppState.theVault();
if (vault.finishUnlock(_job as PinJob)) {
_job = null;
- vault.promotePending();
- ChangeQueue.applyLocks(vault);
- // Unlocked: "Encrypt names" can now reach locked entries.
- AppState.processSettings();
- if (legacy) {
- askForNewPin();
- return;
- }
- succeed();
+ startLockJob();
return;
}
+ busy = false;
+ _shownLogged = false;
_job = null;
buzz();
if (!vault.hasPin()) {
@@ -264,14 +267,39 @@ class PinView extends WatchUi.View {
}
function onSetDone() as Void {
- busy = false;
Bytes.wipe(_jobPin);
_jobPin = null;
- var vault = AppState.theVault();
- vault.finishSetPin(_job as PinJob);
+ AppState.theVault().finishSetPin(_job as PinJob);
_job = null;
- vault.promotePending();
- ChangeQueue.applyLocks(vault);
+ startLockJob();
+ }
+
+ // Unlocked: promote the pending entries and apply waiting "Require
+ // PIN" changes in steps, still showing the busy state (BACK waits).
+ private function startLockJob() as Void {
+ var job = new LockJob(AppState.theVault(), !_lockJobRan);
+ _lockJobRan = true;
+ _lockJob = job;
+ var r = new Jobs.JobRunner(job, 1, method(:onLockJobDone));
+ r.start();
+ runner = r;
+ }
+
+ function onLockJobDone() as Void {
+ busy = false;
+ _shownLogged = false;
+ var job = _lockJob as LockJob;
+ _lockJob = null;
+ if (job.lines.size() > 0) {
+ Results.add(job.lines); // the list says "Results ready (menu)"
+ }
+ // "Encrypt names" can now reach locked entries, and a lock just
+ // applied changes what the glance may show.
+ AppState.processSettings();
+ if (legacy) {
+ askForNewPin();
+ return;
+ }
succeed();
}