mirror of
https://github.com/kuhyx/wake-alarm.git
synced 2026-11-22 17:42:18 +01:00
Peek the bypass stamp on tick, take it on dismiss
Two session screens ticked on one bypass re-ring (emulator, 2026-11-23): the first took the stamp and marked bypass:fsi_revoked, the second found none and overwrote it with deadline:bathroomIn. Screens now only peek; the dismiss, which records the re-ring, takes it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
9d98a57909
commit
032358cc03
@ -146,6 +146,7 @@ object AlarmChannel {
|
||||
// dismiss sequence in front the moment it is looked at.
|
||||
"isRinging" -> result.success(AlarmService.running)
|
||||
"takeBypassReRing" -> result.success(BypassReRing.take(context))
|
||||
"peekBypassReRing" -> result.success(BypassReRing.peek(context))
|
||||
"beginStepCount" -> {
|
||||
StepCounter.markRingStart(context)
|
||||
result.success(null)
|
||||
|
||||
@ -19,6 +19,11 @@ object BypassReRing {
|
||||
prefs(context).edit().putString(KEY, BypassRules.encodeStamp(cause, date)).commit()
|
||||
}
|
||||
|
||||
/** The stamped cause, left in place: every screen ticking on this ring sees it. */
|
||||
fun peek(context: Context): String? =
|
||||
BypassRules.takeStamp(prefs(context).getString(KEY, null), LocalDate.now().toString())
|
||||
|
||||
/** The stamped cause, cleared: called once, when the re-ring is recorded. */
|
||||
fun take(context: Context): String? {
|
||||
val stored = prefs(context).getString(KEY, null) ?: return null
|
||||
prefs(context).edit().remove(KEY).commit()
|
||||
|
||||
@ -212,6 +212,11 @@ class AlarmScheduler {
|
||||
Future<String?> takeBypassReRing() =>
|
||||
_channel.invokeMethod<String>('takeBypassReRing');
|
||||
|
||||
/// [takeBypassReRing] without clearing it, for the session screen's tick:
|
||||
/// two screens can tick on one ring, and only the dismiss records it.
|
||||
Future<String?> peekBypassReRing() =>
|
||||
_channel.invokeMethod<String>('peekBypassReRing');
|
||||
|
||||
/// Raw presence observations: `ssid`, `bssid`, `lat`, `lon`, `accuracy`,
|
||||
/// `distanceMeters`, `reason`.
|
||||
///
|
||||
|
||||
@ -39,7 +39,7 @@ Future<void> pointNativeAtLeg(
|
||||
Future<String> nativeRingReason(
|
||||
AlarmScheduler scheduler,
|
||||
MorningSession session,
|
||||
) async => session.reRingReasonFor(await scheduler.takeBypassReRing());
|
||||
) async => session.reRingReasonFor(await scheduler.peekBypassReRing());
|
||||
|
||||
/// The notification's one line: glyph + position count, with a running-clock
|
||||
/// marker when the re-ring was spent.
|
||||
|
||||
@ -28,7 +28,7 @@ void main() {
|
||||
calls.add(call.method);
|
||||
if (call.method == 'hasNfc') return true;
|
||||
if (call.method == 'isRinging') return true;
|
||||
if (call.method == 'takeBypassReRing') return bypassCause;
|
||||
if (call.method == 'peekBypassReRing') return bypassCause;
|
||||
return null;
|
||||
},
|
||||
);
|
||||
@ -58,7 +58,10 @@ void main() {
|
||||
) async {
|
||||
bypassCause = 'suspended';
|
||||
expect(await ringReasonAfterOneTick(tester), 'bypass:suspended');
|
||||
expect(calls, contains('takeBypassReRing'));
|
||||
// Only the dismiss takes the stamp: two screens can tick on one ring
|
||||
// (emulator 2026-11-23), and the second must not see it gone.
|
||||
expect(calls, contains('peekBypassReRing'));
|
||||
expect(calls, isNot(contains('takeBypassReRing')));
|
||||
});
|
||||
|
||||
testWidgets('a ring nothing stamped is the deadline', (tester) async {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user