diff --git a/apps/app/src/camera/camera.vibe b/apps/app/src/camera/camera.vibe index 2b042b235b..8819c1f410 100644 --- a/apps/app/src/camera/camera.vibe +++ b/apps/app/src/camera/camera.vibe @@ -238,12 +238,15 @@ effect function writeFlash(ticket: number, setting: Flash): void!!(CameraPort | try SubscriptionRef.set(assets.flashWrites, { ticket, setting, applied }) } +/** Whether Android answered an ask for access: a grant it gave or refused, never the one a failed ask leaves. */ +const answeredAsk = (said: Camera.Event): boolean => (said.type === "accessIs" || said.type === "microphoneIs") && said.grant !== "Unasked" + function carry(fx: Camera.Effect, proof: Accepted<"app__camera", Camera.Event>): CameraJob { const filed = () => fileReceipt("app__camera", fx.tag, proof) const filedIf = (happened: boolean) => happened ? filed() : undefined switch (fx.tag) { - case "AskAccess": return answer("camera permission", receipted(permission("camera"), () => true, filed), { type: "accessIs", grant: "Unasked", now: untimed }, From.phone) - case "AskMicrophone": return answer("mic permission", receipted(permission("microphone"), () => true, filed), { type: "microphoneIs", grant: "Unasked" }, From.phone) + case "AskAccess": return answer("camera permission", receipted(permission("camera"), answeredAsk, filed), { type: "accessIs", grant: "Unasked", now: untimed }, From.phone) + case "AskMicrophone": return answer("mic permission", receipted(permission("microphone"), answeredAsk, filed), { type: "microphoneIs", grant: "Unasked" }, From.phone) case "OpenSettings": return run("camera settings", effect { const opened = try (try SystemSettings).open("AppPermissions", "") filedIf(opened !== "NotAtAll") @@ -280,10 +283,7 @@ function carry(fx: Camera.Effect, proof: Accepted<"app__camera", Camera.Event>): filedIf(ok) return { type: "recordingVerified", ok, now: untimed } as const }, { type: "recordingVerified", ok: false, now: untimed }, From.phone) - case "OpenLast": return run("open last capture", effect { - try openLast(fx.photo) - filed() - }, From.phone) + case "OpenLast": return run("open last capture", map(openLast(fx.photo), filedIf), From.phone) case "Uncover": return run("uncover Camera", map(uncover(), filedIf), From.phone) case "Answer": return run(`answered request ${fx.request}`, Effect.void, From.phone) } @@ -451,7 +451,8 @@ const videoThumbnail = started(effect { }))) }, "saved camera video thumbnail") -effect function openLast(photo: number): void!!(CameraAssets | PhotosPort | Shell.Machine) { +/** Hand capture `photo` to Photos and open it: whether Photos opened. */ +effect function openLast(photo: number): boolean!!(CameraAssets | PhotosPort | Shell.Machine) { const media = try (try CameraAssets).read(photo) if (media !== undefined) { const ownedId = ownedCaptureId(media.path, media.mime.startsWith("video/")) @@ -459,7 +460,7 @@ effect function openLast(photo: number): void!!(CameraAssets | PhotosPort | Shel try (try PhotosPort).handoff({ libraryId: media.libraryId, ownedId }) } } - try openView("Photos") + return try openView("Photos") } module bytes { diff --git a/apps/app/src/update/page.vibe b/apps/app/src/update/page.vibe index 3f3c1e4729..1575f44d77 100644 --- a/apps/app/src/update/page.vibe +++ b/apps/app/src/update/page.vibe @@ -45,9 +45,12 @@ effect function reconnected(filed: () => unknown): void!!Agent { } // spec/app/update/page.md, "The refusal is explained only for a manual update this page itself refused" -effect function told(): void!!(Page.Machine | Toasts.Machine | Said) { +/** Say why the update was refused, where the page has a reason to give: whether it said one. */ +effect function told(): boolean!!(Page.Machine | Toasts.Machine | Said) { const text = Page.noticeText(try (try Page.Machine).get()) - if (text !== "") try say(text, true) + if (text === "") return false + try say(text, true) + return true } function carry(fx: Out, proof: Accepted<"app__update__page", Event>): Job { @@ -57,10 +60,7 @@ function carry(fx: Out, proof: Accepted<"app__update__page", Event>): Job said.type === "flushed" && said.saved, filed), { type: "flushed", activation, saved: false, engaged: Page.calm }); when { tag: "Continue", let activation }: answer("continue", continued(activation, filed), { type: "continued" }); when { tag: "Reconnect", let activation }: run(`reconnect ${activation}`, reconnected(filed)); - when { tag: "Toast" }: run("toast", effect { - try told() - filed() - }); + when { tag: "Toast" }: run("toast", effect { if (try told()) filed() }); } } diff --git a/apps/app/src/update/updates.vibe b/apps/app/src/update/updates.vibe index 18c5442cd3..128b14a5c4 100644 --- a/apps/app/src/update/updates.vibe +++ b/apps/app/src/update/updates.vibe @@ -127,8 +127,7 @@ function carry(fx: Out, proof: Accepted<"app__update", Event>): Job said.type === "endInstall" && said.ending === "Finished", filed), { type: "endInstall", ending: "Deferred", now: untimed }); when { tag: "OpenInstallSettings" }: run("allow", effect { - try (try LauncherUpdates).allowAutomatic() - filed() + if (try (try LauncherUpdates).allowAutomatic()) filed() }); } }