Skip to content
This repository has been archived by the owner on Nov 23, 2023. It is now read-only.

Fix camera photo not adding to assets tile #245

Merged
merged 1 commit into from
Nov 1, 2023
Merged
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
11 changes: 7 additions & 4 deletions src/frontend/ui/tiles/WebCamera.svelte
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<script lang="ts">
import { onMount } from "svelte";
import { cacheStore } from "../../lib/stores/CacheStore";
import { set } from "zod";
import { projectsStore } from "../../lib/stores/ProjectStore";

const ws = new WebSocket("ws://localhost:60606");

Expand Down Expand Up @@ -52,13 +52,16 @@

context?.drawImage(imageBitmap, 0, 0);

canvas.toBlob((blob) => {
canvas.toBlob(async (blob) => {
// const blobUrl = URL.createObjectURL(blob);
if (blob)
cacheStore.addCacheObject(blob, {
if (blob && $projectsStore.activeProject) {
const cacheId = await cacheStore.addCacheObject(blob, {
contentType: "image/png",
name: `Webcam Capture ${Math.floor(100000 * Math.random())}`,
});
if (cacheId)
window.apis.projectApi.addCacheObjects($projectsStore.activeProject.id, [cacheId]);
}
}, "image/png"); // You can specify the MIME type here
})
.catch((err: string) => console.log("Error while taking photo ", err));
Expand Down
Loading