Spaces:
Runtime error
Runtime error
clear storage as needed
Browse files
frontend/src/lib/PaintCanvas.svelte
CHANGED
|
@@ -34,13 +34,32 @@
|
|
| 34 |
): PromptImgObject[] {
|
| 35 |
if (promptImgList) {
|
| 36 |
//sorted by last updated
|
| 37 |
-
const roomid = $selectedRoomID || ''
|
| 38 |
const canvasPixels = new Map();
|
| 39 |
for (const x of Array.from(Array(width / GRID_SIZE).keys())) {
|
| 40 |
for (const y of Array.from(Array(height / GRID_SIZE).keys())) {
|
| 41 |
canvasPixels.set(`${x * GRID_SIZE}_${y * GRID_SIZE}`, null);
|
| 42 |
}
|
| 43 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 44 |
const list: PromptImgObject[] = Object.values(promptImgList)
|
| 45 |
.map((e) => {
|
| 46 |
if (e instanceof LiveObject) {
|
|
@@ -68,6 +87,7 @@
|
|
| 68 |
};
|
| 69 |
})
|
| 70 |
.sort((a, b) => b.date - a.date);
|
|
|
|
| 71 |
// init
|
| 72 |
for (const promptImg of list) {
|
| 73 |
const x = promptImg.position.x;
|
|
@@ -83,6 +103,14 @@
|
|
| 83 |
}
|
| 84 |
const ids = new Set([...canvasPixels.values()]);
|
| 85 |
const filteredImages = list.filter((promptImg) => ids.has(promptImg.id));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 86 |
return filteredImages.reverse().filter((promptImg) => !imagesOnCanvas.has(promptImg.id));
|
| 87 |
}
|
| 88 |
return [];
|
|
|
|
| 34 |
): PromptImgObject[] {
|
| 35 |
if (promptImgList) {
|
| 36 |
//sorted by last updated
|
| 37 |
+
const roomid = $selectedRoomID || '';
|
| 38 |
const canvasPixels = new Map();
|
| 39 |
for (const x of Array.from(Array(width / GRID_SIZE).keys())) {
|
| 40 |
for (const y of Array.from(Array(height / GRID_SIZE).keys())) {
|
| 41 |
canvasPixels.set(`${x * GRID_SIZE}_${y * GRID_SIZE}`, null);
|
| 42 |
}
|
| 43 |
}
|
| 44 |
+
|
| 45 |
+
// Object.values(promptImgList).map((e) => {
|
| 46 |
+
// let obj;
|
| 47 |
+
// if (e instanceof LiveObject) {
|
| 48 |
+
// obj = e.toObject();
|
| 49 |
+
// } else {
|
| 50 |
+
// obj = e;
|
| 51 |
+
// }
|
| 52 |
+
// // const obj = promptImg.toObject();
|
| 53 |
+
// if (obj.position) {
|
| 54 |
+
// const key = `${obj.position.x}_${obj.position.y}`;
|
| 55 |
+
// console.log('key', key);
|
| 56 |
+
// const promptImgParams = {
|
| 57 |
+
// imgURL: obj.imgURL
|
| 58 |
+
// };
|
| 59 |
+
// $promptImgStorage.set(key, promptImgParams);
|
| 60 |
+
// }
|
| 61 |
+
// });
|
| 62 |
+
|
| 63 |
const list: PromptImgObject[] = Object.values(promptImgList)
|
| 64 |
.map((e) => {
|
| 65 |
if (e instanceof LiveObject) {
|
|
|
|
| 87 |
};
|
| 88 |
})
|
| 89 |
.sort((a, b) => b.date - a.date);
|
| 90 |
+
|
| 91 |
// init
|
| 92 |
for (const promptImg of list) {
|
| 93 |
const x = promptImg.position.x;
|
|
|
|
| 103 |
}
|
| 104 |
const ids = new Set([...canvasPixels.values()]);
|
| 105 |
const filteredImages = list.filter((promptImg) => ids.has(promptImg.id));
|
| 106 |
+
|
| 107 |
+
// remove images that are under other images
|
| 108 |
+
list
|
| 109 |
+
.filter((promptImg) => !ids.has(promptImg.id))
|
| 110 |
+
.map((promptImg) => {
|
| 111 |
+
const key = `${promptImg.position.x}_${promptImg.position.y}`;
|
| 112 |
+
$promptImgStorage.delete(key);
|
| 113 |
+
});
|
| 114 |
return filteredImages.reverse().filter((promptImg) => !imagesOnCanvas.has(promptImg.id));
|
| 115 |
}
|
| 116 |
return [];
|