radames commited on
Commit
bc62831
1 Parent(s): f365598

reduce liveobject size

Browse files
frontend/src/lib/App.svelte CHANGED
@@ -19,7 +19,6 @@
19
  isRenderingCanvas
20
  } from '$lib/store';
21
  import { useMyPresence, useObject, useOthers } from '$lib/liveblocks';
22
- import { nanoid } from 'nanoid';
23
 
24
  const myPresence = useMyPresence();
25
  const others = useOthers();
@@ -160,15 +159,9 @@
160
  }
161
  // const imgBlob = await base64ToBlob(imgBase64);
162
  const promptImgParams = {
163
- prompt,
164
- imgURL: params.image.filename,
165
- position,
166
- date: new Date().getTime(),
167
- id: nanoid(),
168
- room: room
169
  };
170
  // const imgURL = await uploadImage(imgBlob, promptImgParams);
171
-
172
  $promptImgStorage.set(imageKey, new LiveObject(promptImgParams));
173
  // $promptImgStorage.set(imageKey, promptImgParams);
174
 
 
19
  isRenderingCanvas
20
  } from '$lib/store';
21
  import { useMyPresence, useObject, useOthers } from '$lib/liveblocks';
 
22
 
23
  const myPresence = useMyPresence();
24
  const others = useOthers();
 
159
  }
160
  // const imgBlob = await base64ToBlob(imgBase64);
161
  const promptImgParams = {
162
+ imgURL: params.image.filename
 
 
 
 
 
163
  };
164
  // const imgURL = await uploadImage(imgBlob, promptImgParams);
 
165
  $promptImgStorage.set(imageKey, new LiveObject(promptImgParams));
166
  // $promptImgStorage.set(imageKey, promptImgParams);
167
 
frontend/src/lib/PaintCanvas.svelte CHANGED
@@ -4,7 +4,13 @@
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';
@@ -28,6 +34,7 @@
28
  ): PromptImgObject[] {
29
  if (promptImgList) {
30
  //sorted by last updated
 
31
  const canvasPixels = new Map();
32
  for (const x of Array.from(Array(width / GRID_SIZE).keys())) {
33
  for (const y of Array.from(Array(height / GRID_SIZE).keys())) {
@@ -42,6 +49,24 @@
42
  return e;
43
  }
44
  })
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
45
  .sort((a, b) => b.date - a.date);
46
  // init
47
  for (const promptImg of list) {
 
4
  import { select } from 'd3-selection';
5
  import { onMount } from 'svelte';
6
  import { PUBLIC_UPLOADS } from '$env/static/public';
7
+ import {
8
+ currZoomTransform,
9
+ canvasEl,
10
+ isRenderingCanvas,
11
+ canvasSize,
12
+ selectedRoomID
13
+ } from '$lib/store';
14
 
15
  import { useMyPresence, useObject } from '$lib/liveblocks';
16
  import { LiveObject } from '@liveblocks/client';
 
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())) {
 
49
  return e;
50
  }
51
  })
52
+ .map((e) => {
53
+ const split_str = e.imgURL.split(/-|.jpg/);
54
+ const date = parseInt(split_str[0]);
55
+ const id = split_str[1];
56
+ const [x, y] = split_str[2].split('_');
57
+ const prompt = split_str.slice(3).join(' ');
58
+ return {
59
+ id,
60
+ date,
61
+ position: {
62
+ x: parseInt(x),
63
+ y: parseInt(y)
64
+ },
65
+ imgURL: e.imgURL,
66
+ prompt,
67
+ room: roomid
68
+ };
69
+ })
70
  .sort((a, b) => b.date - a.date);
71
  // init
72
  for (const promptImg of list) {