v0.2.4: fix countdown notification not appearing + wrong time-remaining
All checks were successful
build-apk / build (push) Successful in 28m23s
All checks were successful
build-apk / build (push) Successful in 28m23s
Countdown notification "nothing appears" on session start: - The small icon was the adaptive launcher mipmap (applicationInfo.icon), which Android 13+/GrapheneOS rejects as an invalid notification small icon and drops the post silently. Ship a proper white-on-transparent vector small icon (bbp_stat_parking) inside the module and use it. - showCountdown now returns a diagnostic string (posted / notifications disabled / exception) instead of swallowing failures; JS logs the branch, permission result, and native outcome to the in-app diagnostics log. - Log the raw active-session payload in refreshSessionStatus (element shape was previously unconfirmed). Time remaining showed "7694 min": - API's TimeRemaining is SECONDS, not minutes. Format it as hours+minutes in SessionDetail; annotate the type. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
9323bbd6c6
commit
2b973348bc
7 changed files with 73 additions and 16 deletions
|
|
@ -53,13 +53,28 @@ function fmtLeft(min: number): string {
|
|||
|
||||
/** Post (or replace) the ongoing status notification for a session end time. */
|
||||
export async function showSessionStatus(args: { zoneName: string; endTime: Date }): Promise<void> {
|
||||
if (!(await getCountdownEnabled())) return;
|
||||
await ensureNotificationPermission();
|
||||
if (!(await getCountdownEnabled())) {
|
||||
logLine('[STATUS] skip: countdown disabled');
|
||||
return;
|
||||
}
|
||||
const granted = await ensureNotificationPermission();
|
||||
const ends = args.endTime.toLocaleTimeString([], { hour: 'numeric', minute: '2-digit' });
|
||||
logLine(
|
||||
`[STATUS] show native=${hasNativeCountdown} perm=${granted} end=${args.endTime.toISOString()}`,
|
||||
);
|
||||
|
||||
if (hasNativeCountdown) {
|
||||
// Native chronometer: a live ticking countdown, updated by the OS.
|
||||
await showCountdown(`Parking · ${args.zoneName}`, `Expires ${ends}`, args.endTime.getTime());
|
||||
try {
|
||||
const diag = await showCountdown(
|
||||
`Parking · ${args.zoneName}`,
|
||||
`Expires ${ends}`,
|
||||
args.endTime.getTime(),
|
||||
);
|
||||
logLine(`[STATUS] native result: ${diag}`);
|
||||
} catch (e: any) {
|
||||
logLine(`[STATUS] native threw: ${e?.message ?? e}`);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -103,6 +118,7 @@ export async function refreshSessionStatus(): Promise<void> {
|
|||
}
|
||||
try {
|
||||
const res = await ps.getActiveParkingSessions();
|
||||
logLine(`[STATUS] active sessions raw: ${JSON.stringify(res.ParkingSession ?? [])}`);
|
||||
const withEnd = (res.ParkingSession ?? [])
|
||||
.map((s: any) => ({ s, end: parseApiTime(s.EndTime ?? s.EndTimeDisplay) }))
|
||||
.filter((x) => x.end != null && x.end.getTime() > Date.now())
|
||||
|
|
|
|||
|
|
@ -21,6 +21,16 @@ type DetailRoute = RouteProp<RootStackParamList, 'SessionDetail'>;
|
|||
const show = (v: unknown) => (v == null || v === '' ? '—' : String(v));
|
||||
const dollars = (v: unknown) => (v == null || v === '' ? undefined : `$${v}`);
|
||||
|
||||
/** API's TimeRemaining is in SECONDS — render it as a human "Xh Ym". */
|
||||
const fmtRemaining = (secs: unknown): string | undefined => {
|
||||
const n = Number(secs);
|
||||
if (!Number.isFinite(n) || n <= 0) return undefined;
|
||||
const total = Math.round(n / 60);
|
||||
const h = Math.floor(total / 60);
|
||||
const m = total % 60;
|
||||
return h ? (m ? `${h}h ${m}m` : `${h}h`) : `${m}m`;
|
||||
};
|
||||
|
||||
export function SessionDetailScreen() {
|
||||
const { colors } = useTheme();
|
||||
const { session, kind } = useRoute<DetailRoute>().params;
|
||||
|
|
@ -90,7 +100,7 @@ export function SessionDetailScreen() {
|
|||
['Space', s.SpaceName ?? s.Space],
|
||||
['Started', s.StartTimeDisplay ?? s.StartTime],
|
||||
['Ends', s.EndTimeDisplay ?? s.EndTime],
|
||||
['Time remaining', s.TimeRemaining != null ? `${s.TimeRemaining} min` : undefined],
|
||||
['Time remaining', fmtRemaining(s.TimeRemaining)],
|
||||
['Amount', dollars(s.Amount)],
|
||||
];
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue