Spaces:
Runtime error
Runtime error
to fix sync problem
Browse files
frontend/src/lib/App.svelte
CHANGED
@@ -9,6 +9,8 @@
|
|
9 |
import { PUBLIC_WS_INPAINTING } from '$env/static/public';
|
10 |
import type { PromptImgKey } from '$lib/types';
|
11 |
import { Status } from '$lib/types';
|
|
|
|
|
12 |
import {
|
13 |
loadingState,
|
14 |
currZoomTransform,
|
@@ -167,7 +169,9 @@
|
|
167 |
};
|
168 |
// const imgURL = await uploadImage(imgBlob, promptImgParams);
|
169 |
|
|
|
170 |
$promptImgStorage.set(imageKey, promptImgParams);
|
|
|
171 |
console.log(params.image.url);
|
172 |
$loadingState = data.success ? 'Complete' : 'Error';
|
173 |
clearStateMsg();
|
|
|
9 |
import { PUBLIC_WS_INPAINTING } from '$env/static/public';
|
10 |
import type { PromptImgKey } from '$lib/types';
|
11 |
import { Status } from '$lib/types';
|
12 |
+
import { LiveObject } from '@liveblocks/client';
|
13 |
+
|
14 |
import {
|
15 |
loadingState,
|
16 |
currZoomTransform,
|
|
|
169 |
};
|
170 |
// const imgURL = await uploadImage(imgBlob, promptImgParams);
|
171 |
|
172 |
+
// $promptImgStorage.set(imageKey, new LiveObject(promptImgParams));
|
173 |
$promptImgStorage.set(imageKey, promptImgParams);
|
174 |
+
|
175 |
console.log(params.image.url);
|
176 |
$loadingState = data.success ? 'Complete' : 'Error';
|
177 |
clearStateMsg();
|
frontend/src/lib/PaintCanvas.svelte
CHANGED
@@ -4,9 +4,11 @@
|
|
4 |
import { select } from 'd3-selection';
|
5 |
import { onMount } from 'svelte';
|
6 |
import { PUBLIC_UPLOADS } from '$env/static/public';
|
7 |
-
import { currZoomTransform, canvasEl, isRenderingCanvas, canvasSize} from '$lib/store';
|
8 |
|
9 |
import { useMyPresence, useObject } from '$lib/liveblocks';
|
|
|
|
|
10 |
import type { PromptImgObject } from '$lib/types';
|
11 |
import { FRAME_SIZE, GRID_SIZE } from '$lib/constants';
|
12 |
|
@@ -21,7 +23,11 @@
|
|
21 |
|
22 |
const imagesOnCanvas = new Set();
|
23 |
|
24 |
-
function getpromptImgList(
|
|
|
|
|
|
|
|
|
25 |
if (promptImgList) {
|
26 |
//sorted by last updated
|
27 |
const canvasPixels = new Map();
|
@@ -30,7 +36,15 @@
|
|
30 |
canvasPixels.set(`${x * GRID_SIZE}_${y * GRID_SIZE}`, null);
|
31 |
}
|
32 |
}
|
33 |
-
const list: PromptImgObject[] = Object.values(promptImgList)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
34 |
// init
|
35 |
for (const promptImg of list) {
|
36 |
const x = promptImg.position.x;
|
|
|
4 |
import { select } from 'd3-selection';
|
5 |
import { onMount } from 'svelte';
|
6 |
import { PUBLIC_UPLOADS } from '$env/static/public';
|
7 |
+
import { currZoomTransform, canvasEl, isRenderingCanvas, canvasSize } from '$lib/store';
|
8 |
|
9 |
import { useMyPresence, useObject } from '$lib/liveblocks';
|
10 |
+
import { LiveObject } from '@liveblocks/client';
|
11 |
+
|
12 |
import type { PromptImgObject } from '$lib/types';
|
13 |
import { FRAME_SIZE, GRID_SIZE } from '$lib/constants';
|
14 |
|
|
|
23 |
|
24 |
const imagesOnCanvas = new Set();
|
25 |
|
26 |
+
function getpromptImgList(
|
27 |
+
promptImgList: Record<string, LiveObject<PromptImgObject> | PromptImgObject>
|
28 |
+
): PromptImgObject[] {
|
29 |
+
console.log('promptImgList', promptImgList);
|
30 |
+
|
31 |
if (promptImgList) {
|
32 |
//sorted by last updated
|
33 |
const canvasPixels = new Map();
|
|
|
36 |
canvasPixels.set(`${x * GRID_SIZE}_${y * GRID_SIZE}`, null);
|
37 |
}
|
38 |
}
|
39 |
+
const list: PromptImgObject[] = Object.values(promptImgList)
|
40 |
+
.map((e) => {
|
41 |
+
if (e instanceof LiveObject) {
|
42 |
+
return e.toObject();
|
43 |
+
} else {
|
44 |
+
return e;
|
45 |
+
}
|
46 |
+
})
|
47 |
+
.sort((a, b) => b.date - a.date);
|
48 |
// init
|
49 |
for (const promptImg of list) {
|
50 |
const x = promptImg.position.x;
|