Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 9 additions & 8 deletions apps/app/src/camera/camera.vibe
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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)
}
Expand Down Expand Up @@ -451,15 +451,16 @@ 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/"))
if (media.libraryId !== undefined || ownedId !== undefined) {
try (try PhotosPort).handoff({ libraryId: media.libraryId, ownedId })
}
}
try openView("Photos")
return try openView("Photos")
}

module bytes {
Expand Down
12 changes: 6 additions & 6 deletions apps/app/src/update/page.vibe
Original file line number Diff line number Diff line change
Expand Up @@ -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<Event, LauncherUpdates | LauncherActivations | Updates.Machine | Engagements | Agent | Page.Machine | Toasts.Machine | Said, []> {
Expand All @@ -57,10 +60,7 @@ function carry(fx: Out, proof: Accepted<"app__update__page", Event>): Job<Event,
when { tag: "Flush", let activation }: answer("flush", receipted(flushed(activation), (said) => 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() });
}
}

Expand Down
3 changes: 1 addition & 2 deletions apps/app/src/update/updates.vibe
Original file line number Diff line number Diff line change
Expand Up @@ -127,8 +127,7 @@ function carry(fx: Out, proof: Accepted<"app__update", Event>): Job<Event, Launc
when { tag: "StartInstall", let version, let digest, let signer, let manifest, let automatic }:
answer("install", receipted(installing({ version, digest, signer, manifest, automatic }), (said) => 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()
});
}
}
Expand Down
Loading