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

Commit

Permalink
Fix camera photo not adding to assets tile
Browse files Browse the repository at this point in the history
  • Loading branch information
SharkmanZA committed Oct 27, 2023
1 parent 1302d02 commit edd45ff
Showing 1 changed file with 7 additions and 4 deletions.
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

0 comments on commit edd45ff

Please sign in to comment.