Spaces:
Runtime error
Runtime error
change init room logic
Browse files
frontend/src/lib/App.svelte
CHANGED
@@ -29,7 +29,6 @@
|
|
29 |
}
|
30 |
|
31 |
const promptImgStorage = useObject('promptImgStorage');
|
32 |
-
$: console.log('isRendering', $isRenderingCanvas);
|
33 |
|
34 |
$: isLoading = $myPresence?.status === Status.loading || $isRenderingCanvas || false;
|
35 |
function onShowModal(e: CustomEvent) {
|
|
|
29 |
}
|
30 |
|
31 |
const promptImgStorage = useObject('promptImgStorage');
|
|
|
32 |
|
33 |
$: isLoading = $myPresence?.status === Status.loading || $isRenderingCanvas || false;
|
34 |
function onShowModal(e: CustomEvent) {
|
frontend/src/lib/Buttons/RoomsSelector.svelte
CHANGED
@@ -42,7 +42,7 @@
|
|
42 |
|
43 |
<!-- svelte-ignore a11y-click-events-have-key-events -->
|
44 |
<div class="min-w-[20ch]">
|
45 |
-
{#if loadingRooms}
|
46 |
<div
|
47 |
class="text-sm rounded-2xl md:text-smtext-gray-700 py-1 font-medium tracking-tight relative ring-1 ring-blue-500 px-2"
|
48 |
title="Choose a different room"
|
|
|
42 |
|
43 |
<!-- svelte-ignore a11y-click-events-have-key-events -->
|
44 |
<div class="min-w-[20ch]">
|
45 |
+
{#if loadingRooms && selectedRoom}
|
46 |
<div
|
47 |
class="text-sm rounded-2xl md:text-smtext-gray-700 py-1 font-medium tracking-tight relative ring-1 ring-blue-500 px-2"
|
48 |
title="Choose a different room"
|
frontend/src/lib/PaintFrame.svelte
CHANGED
@@ -30,7 +30,7 @@
|
|
30 |
let frameElement: HTMLDivElement;
|
31 |
let dragEnabled = true;
|
32 |
let isDragging = false;
|
33 |
-
let firstLoading =
|
34 |
|
35 |
$: prompt = $myPresence?.currentPrompt;
|
36 |
$: isLoading =
|
@@ -41,7 +41,7 @@
|
|
41 |
y: transform.applyY(position.y)
|
42 |
};
|
43 |
|
44 |
-
$: if (!$isRenderingCanvas && firstLoading) {
|
45 |
cleanMask();
|
46 |
firstLoading = false;
|
47 |
}
|
@@ -98,6 +98,8 @@
|
|
98 |
})
|
99 |
.call(maskingHandler() as any)
|
100 |
.call(cursorUpdate);
|
|
|
|
|
101 |
});
|
102 |
|
103 |
function cursorUpdate(selection: any) {
|
|
|
30 |
let frameElement: HTMLDivElement;
|
31 |
let dragEnabled = true;
|
32 |
let isDragging = false;
|
33 |
+
let firstLoading: boolean | null = null;
|
34 |
|
35 |
$: prompt = $myPresence?.currentPrompt;
|
36 |
$: isLoading =
|
|
|
41 |
y: transform.applyY(position.y)
|
42 |
};
|
43 |
|
44 |
+
$: if (firstLoading !== null && !$isRenderingCanvas && firstLoading) {
|
45 |
cleanMask();
|
46 |
firstLoading = false;
|
47 |
}
|
|
|
98 |
})
|
99 |
.call(maskingHandler() as any)
|
100 |
.call(cursorUpdate);
|
101 |
+
|
102 |
+
firstLoading = true;
|
103 |
});
|
104 |
|
105 |
function cursorUpdate(selection: any) {
|
frontend/src/lib/store.ts
CHANGED
@@ -7,7 +7,7 @@ export const canvasEl = writable<HTMLCanvasElement>();
|
|
7 |
export const maskEl = writable<HTMLCanvasElement>();
|
8 |
export const selectedRoomID = writable<string | null>();
|
9 |
export const toggleAbout = writable<boolean>(false);
|
10 |
-
export const isRenderingCanvas = writable<boolean>(
|
11 |
export const showModal = writable<boolean>(false);
|
12 |
export const canvasSize = writable<{
|
13 |
width: number;
|
|
|
7 |
export const maskEl = writable<HTMLCanvasElement>();
|
8 |
export const selectedRoomID = writable<string | null>();
|
9 |
export const toggleAbout = writable<boolean>(false);
|
10 |
+
export const isRenderingCanvas = writable<boolean>(false);
|
11 |
export const showModal = writable<boolean>(false);
|
12 |
export const canvasSize = writable<{
|
13 |
width: number;
|
frontend/src/routes/+page.svelte
CHANGED
@@ -42,21 +42,25 @@
|
|
42 |
const rooms: RoomResponse[] = await res.json();
|
43 |
const emptyRoom = rooms.find((room) => room.users_count < MAX_CAPACITY) || null;
|
44 |
|
45 |
-
let
|
|
|
46 |
if (roomidParam) {
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
const
|
53 |
-
|
54 |
-
window.parent.postMessage({ queryString: queryString }, '*');
|
55 |
}
|
|
|
|
|
|
|
56 |
}
|
57 |
-
if
|
58 |
-
|
59 |
-
|
|
|
60 |
const queryString = '?' + new URLSearchParams(state).toString();
|
61 |
window.history.replaceState(null, '', queryString);
|
62 |
window.parent.postMessage({ queryString: queryString }, '*');
|
|
|
42 |
const rooms: RoomResponse[] = await res.json();
|
43 |
const emptyRoom = rooms.find((room) => room.users_count < MAX_CAPACITY) || null;
|
44 |
|
45 |
+
let queriedRoom: string | null = null;
|
46 |
+
// init if roomid is set via param
|
47 |
if (roomidParam) {
|
48 |
+
// if room is unlisted, skip the check
|
49 |
+
if (roomidParam.startsWith('secret-')) {
|
50 |
+
queriedRoom = roomidParam;
|
51 |
+
} else {
|
52 |
+
// if room is listed, check if it's full
|
53 |
+
const room = rooms.find((room) => room.room_id === roomidParam) || null;
|
54 |
+
queriedRoom = room && room.users_count < MAX_CAPACITY ? room.room_id : null;
|
|
|
55 |
}
|
56 |
+
} else {
|
57 |
+
// if roomid is not set via param, select the first empty room
|
58 |
+
queriedRoom = emptyRoom ? emptyRoom.room_id : null;
|
59 |
}
|
60 |
+
// if seleceted room is full, select the first empty room
|
61 |
+
if (queriedRoom) {
|
62 |
+
$selectedRoomID = queriedRoom;
|
63 |
+
const state = { roomid: queriedRoom };
|
64 |
const queryString = '?' + new URLSearchParams(state).toString();
|
65 |
window.history.replaceState(null, '', queryString);
|
66 |
window.parent.postMessage({ queryString: queryString }, '*');
|
requirements.txt
CHANGED
@@ -13,4 +13,5 @@ gradio==3.6
|
|
13 |
boto3==1.24.93
|
14 |
python-magic==0.4.27
|
15 |
fastapi-utils==0.2.1
|
16 |
-
shortuuid==1.0.
|
|
|
|
13 |
boto3==1.24.93
|
14 |
python-magic==0.4.27
|
15 |
fastapi-utils==0.2.1
|
16 |
+
shortuuid==1.0.
|
17 |
+
tqdm==4.64
|
stablediffusion-infinity/createRooms.py
CHANGED
@@ -53,6 +53,16 @@ async def create_room(db: sqlite3.Connection = Depends(get_db)):
|
|
53 |
return all
|
54 |
|
55 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
56 |
def createRoom(room_id, db):
|
57 |
payload = {"id": room_id, "defaultAccesses": ["room:write"]}
|
58 |
|
@@ -117,4 +127,5 @@ async def sync_rooms(db: sqlite3.Connection = Depends(get_db)):
|
|
117 |
|
118 |
|
119 |
if __name__ == "__main__":
|
120 |
-
uvicorn.run("createRooms:app", host="0.0.0.0",
|
|
|
|
53 |
return all
|
54 |
|
55 |
|
56 |
+
@app.get("/create-one-room/{room_id}")
|
57 |
+
async def create_one_room(room_id: str):
|
58 |
+
payload = {"id": room_id, "defaultAccesses": ["room:write"]}
|
59 |
+
|
60 |
+
response = requests.post(f"https://api.liveblocks.io/v2/rooms",
|
61 |
+
headers={"Authorization": f"Bearer {LIVEBLOCKS_SECRET}"}, json=payload)
|
62 |
+
data = response.json()
|
63 |
+
return data
|
64 |
+
|
65 |
+
|
66 |
def createRoom(room_id, db):
|
67 |
payload = {"id": room_id, "defaultAccesses": ["room:write"]}
|
68 |
|
|
|
127 |
|
128 |
|
129 |
if __name__ == "__main__":
|
130 |
+
uvicorn.run("createRooms:app", host="0.0.0.0",
|
131 |
+
log_level="debug", reload=True)
|