wip multiple rooms

This commit is contained in:
hugogogo
2023-01-09 12:23:41 +01:00
parent 258e7596fe
commit 45edd2f25f
8 changed files with 200 additions and 156 deletions

View File

@@ -3912,7 +3912,7 @@ var app = (function () {
return child_ctx;
}
// (50:1) <Button bind:layout new_layout="settings" my_class="settings dots icon">
// (53:1) <Button bind:layout new_layout="settings" my_class="settings dots icon">
function create_default_slot_3$5(ctx) {
let t;
@@ -3932,14 +3932,14 @@ var app = (function () {
block,
id: create_default_slot_3$5.name,
type: "slot",
source: "(50:1) <Button bind:layout new_layout=\\\"settings\\\" my_class=\\\"settings dots icon\\\">",
source: "(53:1) <Button bind:layout new_layout=\\\"settings\\\" my_class=\\\"settings dots icon\\\">",
ctx
});
return block;
}
// (55:1) <Button bind:layout new_layout="new" my_class="new transparent">
// (58:1) <Button bind:layout new_layout="new" my_class="new transparent">
function create_default_slot_2$9(ctx) {
let t;
@@ -3959,14 +3959,14 @@ var app = (function () {
block,
id: create_default_slot_2$9.name,
type: "slot",
source: "(55:1) <Button bind:layout new_layout=\\\"new\\\" my_class=\\\"new transparent\\\">",
source: "(58:1) <Button bind:layout new_layout=\\\"new\\\" my_class=\\\"new transparent\\\">",
ctx
});
return block;
}
// (60:1) <Button bind:layout new_layout="close" my_class="close icon">
// (63:1) <Button bind:layout new_layout="close" my_class="close icon">
function create_default_slot_1$9(ctx) {
let t;
@@ -3986,7 +3986,7 @@ var app = (function () {
block,
id: create_default_slot_1$9.name,
type: "slot",
source: "(60:1) <Button bind:layout new_layout=\\\"close\\\" my_class=\\\"close icon\\\">",
source: "(63:1) <Button bind:layout new_layout=\\\"close\\\" my_class=\\\"close icon\\\">",
ctx
});
@@ -4015,7 +4015,7 @@ var app = (function () {
return block;
}
// (74:3) {:then}
// (77:3) {:then}
function create_then_block$2(ctx) {
let each_1_anchor;
let current;
@@ -4104,14 +4104,14 @@ var app = (function () {
block,
id: create_then_block$2.name,
type: "then",
source: "(74:3) {:then}",
source: "(77:3) {:then}",
ctx
});
return block;
}
// (76:5) <Button my_class="list" on_click={get_room_messages}>
// (79:5) <Button my_class="list" on_click={get_room_messages}>
function create_default_slot$b(ctx) {
let t0_value = /*room*/ ctx[7].name + "";
let t0;
@@ -4139,14 +4139,14 @@ var app = (function () {
block,
id: create_default_slot$b.name,
type: "slot",
source: "(76:5) <Button my_class=\\\"list\\\" on_click={get_room_messages}>",
source: "(79:5) <Button my_class=\\\"list\\\" on_click={get_room_messages}>",
ctx
});
return block;
}
// (75:4) {#each rooms as room}
// (78:4) {#each rooms as room}
function create_each_block$6(ctx) {
let button;
let current;
@@ -4196,14 +4196,14 @@ var app = (function () {
block,
id: create_each_block$6.name,
type: "each",
source: "(75:4) {#each rooms as room}",
source: "(78:4) {#each rooms as room}",
ctx
});
return block;
}
// (71:21) <!-- promise is pending --> <p>rooms are loaded...</p> {:then}
// (74:21) <!-- promise is pending --> <p>rooms are loaded...</p> {:then}
function create_pending_block$2(ctx) {
let p;
@@ -4211,7 +4211,7 @@ var app = (function () {
c: function create() {
p = element("p");
p.textContent = "rooms are loaded...";
add_location(p, file$p, 72, 4, 1632);
add_location(p, file$p, 75, 4, 1671);
},
m: function mount(target, anchor) {
insert_dev(target, p, anchor);
@@ -4228,7 +4228,7 @@ var app = (function () {
block,
id: create_pending_block$2.name,
type: "pending",
source: "(71:21) <!-- promise is pending --> <p>rooms are loaded...</p> {:then}",
source: "(74:21) <!-- promise is pending --> <p>rooms are loaded...</p> {:then}",
ctx
});
@@ -4342,17 +4342,17 @@ var app = (function () {
t6 = space();
info.block.c();
attr_dev(p0, "class", "title svelte-1jygwt2");
add_location(p0, file$p, 65, 2, 1400);
add_location(p0, file$p, 68, 2, 1439);
attr_dev(p1, "class", "__center");
add_location(p1, file$p, 68, 4, 1510);
add_location(p1, file$p, 71, 4, 1549);
attr_dev(div0, "class", "__show_if_only_child");
add_location(div0, file$p, 67, 3, 1471);
add_location(div0, file$p, 70, 3, 1510);
attr_dev(div1, "class", "room_list");
add_location(div1, file$p, 66, 2, 1444);
add_location(div1, file$p, 69, 2, 1483);
attr_dev(div2, "class", "panel panel_home __border_top svelte-1jygwt2");
add_location(div2, file$p, 64, 1, 1354);
add_location(div2, file$p, 67, 1, 1393);
attr_dev(div3, "class", "grid_box svelte-1jygwt2");
add_location(div3, file$p, 46, 0, 995);
add_location(div3, file$p, 49, 0, 1034);
},
l: function claim(nodes) {
throw new Error("options.hydrate only works if the component was compiled with the `hydratable: true` option");
@@ -4481,6 +4481,7 @@ var app = (function () {
$$invalidate(1, rooms = data.rooms);
});
// get room messages
function get_room_messages() {
console.log("in get_room_messages");
@@ -4497,6 +4498,7 @@ var app = (function () {
msgs.update(msgs => data.messages);
});
// go to room
$$invalidate(0, layout = "room");
}
@@ -5405,7 +5407,7 @@ var app = (function () {
return child_ctx;
}
// (62:1) <Button bind:layout new_layout={back} my_class="back icon" my_title="go back {back}">
// (68:1) <Button bind:layout new_layout={back} my_class="back icon" my_title="go back {back}">
function create_default_slot_4$2(ctx) {
let t;
@@ -5425,14 +5427,14 @@ var app = (function () {
block,
id: create_default_slot_4$2.name,
type: "slot",
source: "(62:1) <Button bind:layout new_layout={back} my_class=\\\"back icon\\\" my_title=\\\"go back {back}\\\">",
source: "(68:1) <Button bind:layout new_layout={back} my_class=\\\"back icon\\\" my_title=\\\"go back {back}\\\">",
ctx
});
return block;
}
// (67:1) <Button my_class="new deactivate">
// (73:1) <Button my_class="new deactivate">
function create_default_slot_3$3(ctx) {
let t;
@@ -5452,14 +5454,14 @@ var app = (function () {
block,
id: create_default_slot_3$3.name,
type: "slot",
source: "(67:1) <Button my_class=\\\"new deactivate\\\">",
source: "(73:1) <Button my_class=\\\"new deactivate\\\">",
ctx
});
return block;
}
// (72:1) <Button bind:layout new_layout="close" my_class="close icon">
// (78:1) <Button bind:layout new_layout="close" my_class="close icon">
function create_default_slot_2$7(ctx) {
let t;
@@ -5479,14 +5481,14 @@ var app = (function () {
block,
id: create_default_slot_2$7.name,
type: "slot",
source: "(72:1) <Button bind:layout new_layout=\\\"close\\\" my_class=\\\"close icon\\\">",
source: "(78:1) <Button bind:layout new_layout=\\\"close\\\" my_class=\\\"close icon\\\">",
ctx
});
return block;
}
// (78:2) <Button bind:layout new_layout="create" my_class="create">
// (84:2) <Button bind:layout new_layout="create" my_class="create">
function create_default_slot_1$7(ctx) {
let t;
@@ -5506,14 +5508,14 @@ var app = (function () {
block,
id: create_default_slot_1$7.name,
type: "slot",
source: "(78:2) <Button bind:layout new_layout=\\\"create\\\" my_class=\\\"create\\\">",
source: "(84:2) <Button bind:layout new_layout=\\\"create\\\" my_class=\\\"create\\\">",
ctx
});
return block;
}
// (1:0) <script> import Button from './Element_button.svelte'; import { msgs, user }
// (1:0) <script> import Button from './Element_button.svelte'; import { msgs, user, socket }
function create_catch_block$1(ctx) {
const block = {
c: noop,
@@ -5528,14 +5530,14 @@ var app = (function () {
block,
id: create_catch_block$1.name,
type: "catch",
source: "(1:0) <script> import Button from './Element_button.svelte'; import { msgs, user }",
source: "(1:0) <script> import Button from './Element_button.svelte'; import { msgs, user, socket }",
ctx
});
return block;
}
// (89:3) {:then}
// (95:3) {:then}
function create_then_block$1(ctx) {
let each_1_anchor;
let current;
@@ -5624,14 +5626,14 @@ var app = (function () {
block,
id: create_then_block$1.name,
type: "then",
source: "(89:3) {:then}",
source: "(95:3) {:then}",
ctx
});
return block;
}
// (91:5) <Button my_class="list" on_click={join_rooms}>
// (97:5) <Button my_class="list" on_click={join_rooms}>
function create_default_slot$9(ctx) {
let t0_value = /*room*/ ctx[8].name + "";
let t0;
@@ -5659,14 +5661,14 @@ var app = (function () {
block,
id: create_default_slot$9.name,
type: "slot",
source: "(91:5) <Button my_class=\\\"list\\\" on_click={join_rooms}>",
source: "(97:5) <Button my_class=\\\"list\\\" on_click={join_rooms}>",
ctx
});
return block;
}
// (90:4) {#each rooms as room}
// (96:4) {#each rooms as room}
function create_each_block$4(ctx) {
let button;
let current;
@@ -5716,14 +5718,14 @@ var app = (function () {
block,
id: create_each_block$4.name,
type: "each",
source: "(90:4) {#each rooms as room}",
source: "(96:4) {#each rooms as room}",
ctx
});
return block;
}
// (86:21) <!-- promise is pending --> <p>rooms are loaded...</p> {:then}
// (92:21) <!-- promise is pending --> <p>rooms are loaded...</p> {:then}
function create_pending_block$1(ctx) {
let p;
@@ -5731,7 +5733,7 @@ var app = (function () {
c: function create() {
p = element("p");
p.textContent = "rooms are loaded...";
add_location(p, file$m, 87, 4, 1783);
add_location(p, file$m, 93, 4, 1920);
},
m: function mount(target, anchor) {
insert_dev(target, p, anchor);
@@ -5748,7 +5750,7 @@ var app = (function () {
block,
id: create_pending_block$1.name,
type: "pending",
source: "(86:21) <!-- promise is pending --> <p>rooms are loaded...</p> {:then}",
source: "(92:21) <!-- promise is pending --> <p>rooms are loaded...</p> {:then}",
ctx
});
@@ -5875,17 +5877,17 @@ var app = (function () {
p1.textContent = "/ there are no public rooms yet /";
t7 = space();
info.block.c();
add_location(p0, file$m, 80, 2, 1567);
add_location(p0, file$m, 86, 2, 1704);
attr_dev(p1, "class", "__center");
add_location(p1, file$m, 83, 4, 1657);
add_location(p1, file$m, 89, 4, 1794);
attr_dev(div0, "class", "__show_if_only_child");
add_location(div0, file$m, 82, 3, 1618);
add_location(div0, file$m, 88, 3, 1755);
attr_dev(div1, "class", "public_rooms");
add_location(div1, file$m, 81, 2, 1588);
add_location(div1, file$m, 87, 2, 1725);
attr_dev(div2, "class", "panel panel_new __border_top");
add_location(div2, file$m, 76, 1, 1439);
add_location(div2, file$m, 82, 1, 1576);
attr_dev(div3, "class", "grid_box svelte-1b4c0qx");
add_location(div3, file$m, 58, 0, 1106);
add_location(div3, file$m, 64, 0, 1243);
},
l: function claim(nodes) {
throw new Error("options.hydrate only works if the component was compiled with the `hydratable: true` option");
@@ -6023,10 +6025,12 @@ var app = (function () {
$$invalidate(2, rooms = data.rooms);
});
// join the room
function join_rooms(evt) {
console.log("inside join_rooms");
let room_name = { room_name: evt.target.innerText };
// join room
fetch('/api/v2/chat/join', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
@@ -6035,6 +6039,10 @@ var app = (function () {
console.log(data);
});
// join socket room
socket$1.emit('join', room_name);
// get messages from room
fetch('/api/v2/chat/messages').then(resp => resp.json()).then(data => {
console.log(data.messages);
@@ -6047,9 +6055,9 @@ var app = (function () {
msgs.update(msgs => data.messages);
});
// go to room
$$invalidate(0, layout = "room");
} /*
*/
}
const writable_props = ['layout', 'back'];
@@ -6081,6 +6089,7 @@ var app = (function () {
Button: Element_button,
msgs,
user,
socket: socket$1,
layout,
back,
rooms,
@@ -7668,7 +7677,7 @@ var app = (function () {
const { console: console_1$8 } = globals;
const file$h = "src/pieces/chat/Layout_create.svelte";
// (41:1) <Button bind:layout new_layout={back} my_class="back icon" my_title="go back {back}">
// (44:1) <Button bind:layout new_layout={back} my_class="back icon" my_title="go back {back}">
function create_default_slot_2$3(ctx) {
let t;
@@ -7688,14 +7697,14 @@ var app = (function () {
block,
id: create_default_slot_2$3.name,
type: "slot",
source: "(41:1) <Button bind:layout new_layout={back} my_class=\\\"back icon\\\" my_title=\\\"go back {back}\\\">",
source: "(44:1) <Button bind:layout new_layout={back} my_class=\\\"back icon\\\" my_title=\\\"go back {back}\\\">",
ctx
});
return block;
}
// (46:1) <Button my_class="create deactivate">
// (49:1) <Button my_class="create deactivate">
function create_default_slot_1$3(ctx) {
let t;
@@ -7715,14 +7724,14 @@ var app = (function () {
block,
id: create_default_slot_1$3.name,
type: "slot",
source: "(46:1) <Button my_class=\\\"create deactivate\\\">",
source: "(49:1) <Button my_class=\\\"create deactivate\\\">",
ctx
});
return block;
}
// (51:1) <Button bind:layout new_layout="close" my_class="close icon">
// (54:1) <Button bind:layout new_layout="close" my_class="close icon">
function create_default_slot$5(ctx) {
let t;
@@ -7742,14 +7751,14 @@ var app = (function () {
block,
id: create_default_slot$5.name,
type: "slot",
source: "(51:1) <Button bind:layout new_layout=\\\"close\\\" my_class=\\\"close icon\\\">",
source: "(54:1) <Button bind:layout new_layout=\\\"close\\\" my_class=\\\"close icon\\\">",
ctx
});
return block;
}
// (58:3) {#if response_status >= 300}
// (61:3) {#if response_status >= 300}
function create_if_block_1$5(ctx) {
let warning;
let current;
@@ -7790,14 +7799,14 @@ var app = (function () {
block,
id: create_if_block_1$5.name,
type: "if",
source: "(58:3) {#if response_status >= 300}",
source: "(61:3) {#if response_status >= 300}",
ctx
});
return block;
}
// (80:3) {#if room_type === 'protected'}
// (83:3) {#if room_type === 'protected'}
function create_if_block$b(ctx) {
let div;
let label;
@@ -7816,10 +7825,10 @@ var app = (function () {
t1 = space();
input = element("input");
attr_dev(p, "class", "svelte-1ulnmwp");
add_location(p, file$h, 81, 28, 2596);
add_location(p, file$h, 84, 28, 2695);
attr_dev(label, "for", "chat_pswd");
attr_dev(label, "class", "svelte-1ulnmwp");
add_location(label, file$h, 81, 5, 2573);
add_location(label, file$h, 84, 5, 2672);
attr_dev(input, "id", "chat_pswd");
attr_dev(input, "type", "password");
attr_dev(input, "placeholder", "minimum 8 characters");
@@ -7827,9 +7836,9 @@ var app = (function () {
attr_dev(input, "name", "password");
input.required = true;
attr_dev(input, "class", "svelte-1ulnmwp");
add_location(input, file$h, 82, 5, 2636);
add_location(input, file$h, 85, 5, 2735);
attr_dev(div, "class", "svelte-1ulnmwp");
add_location(div, file$h, 80, 4, 2562);
add_location(div, file$h, 83, 4, 2661);
},
m: function mount(target, anchor) {
insert_dev(target, div, anchor);
@@ -7860,7 +7869,7 @@ var app = (function () {
block,
id: create_if_block$b.name,
type: "if",
source: "(80:3) {#if room_type === 'protected'}",
source: "(83:3) {#if room_type === 'protected'}",
ctx
});
@@ -7995,17 +8004,17 @@ var app = (function () {
t16 = space();
input4 = element("input");
attr_dev(p0, "class", "svelte-1ulnmwp");
add_location(p0, file$h, 61, 26, 1749);
add_location(p0, file$h, 64, 26, 1848);
attr_dev(label0, "for", "chat_name");
attr_dev(label0, "class", "svelte-1ulnmwp");
add_location(label0, file$h, 61, 3, 1726);
add_location(label0, file$h, 64, 3, 1825);
attr_dev(input0, "id", "chat_name");
attr_dev(input0, "name", "room_name");
input0.required = true;
attr_dev(input0, "class", "svelte-1ulnmwp");
add_location(input0, file$h, 62, 3, 1783);
add_location(input0, file$h, 65, 3, 1882);
attr_dev(p1, "class", "svelte-1ulnmwp");
add_location(p1, file$h, 65, 4, 1926);
add_location(p1, file$h, 68, 4, 2025);
attr_dev(input1, "id", "chat_public");
attr_dev(input1, "type", "radio");
attr_dev(input1, "name", "room_type");
@@ -8014,12 +8023,12 @@ var app = (function () {
input1.required = true;
attr_dev(input1, "class", "svelte-1ulnmwp");
/*$$binding_groups*/ ctx[12][0].push(input1);
add_location(input1, file$h, 66, 4, 1944);
add_location(input1, file$h, 69, 4, 2043);
attr_dev(label1, "for", "chat_public");
attr_dev(label1, "class", "_radio svelte-1ulnmwp");
add_location(label1, file$h, 64, 3, 1881);
add_location(label1, file$h, 67, 3, 1980);
attr_dev(p2, "class", "svelte-1ulnmwp");
add_location(p2, file$h, 70, 4, 2137);
add_location(p2, file$h, 73, 4, 2236);
attr_dev(input2, "id", "chat_private");
attr_dev(input2, "type", "radio");
attr_dev(input2, "name", "room_type");
@@ -8028,12 +8037,12 @@ var app = (function () {
input2.required = true;
attr_dev(input2, "class", "svelte-1ulnmwp");
/*$$binding_groups*/ ctx[12][0].push(input2);
add_location(input2, file$h, 71, 4, 2156);
add_location(input2, file$h, 74, 4, 2255);
attr_dev(label2, "for", "chat_private");
attr_dev(label2, "class", "_radio hide svelte-1ulnmwp");
add_location(label2, file$h, 69, 3, 2086);
add_location(label2, file$h, 72, 3, 2185);
attr_dev(p3, "class", "svelte-1ulnmwp");
add_location(p3, file$h, 75, 4, 2355);
add_location(p3, file$h, 78, 4, 2454);
attr_dev(input3, "id", "chat_protected");
attr_dev(input3, "type", "radio");
attr_dev(input3, "name", "room_type");
@@ -8042,20 +8051,20 @@ var app = (function () {
input3.required = true;
attr_dev(input3, "class", "svelte-1ulnmwp");
/*$$binding_groups*/ ctx[12][0].push(input3);
add_location(input3, file$h, 76, 4, 2376);
add_location(input3, file$h, 79, 4, 2475);
attr_dev(label3, "for", "chat_protected");
attr_dev(label3, "class", "_radio hide svelte-1ulnmwp");
add_location(label3, file$h, 74, 3, 2302);
add_location(label3, file$h, 77, 3, 2401);
attr_dev(input4, "type", "submit");
input4.value = "⮡";
attr_dev(input4, "class", "svelte-1ulnmwp");
add_location(input4, file$h, 85, 3, 2800);
add_location(input4, file$h, 88, 3, 2899);
attr_dev(form, "class", "svelte-1ulnmwp");
add_location(form, file$h, 56, 2, 1575);
add_location(form, file$h, 59, 2, 1674);
attr_dev(div0, "class", "panel panel_create __border_top svelte-1ulnmwp");
add_location(div0, file$h, 55, 1, 1527);
add_location(div0, file$h, 58, 1, 1626);
attr_dev(div1, "class", "grid_box svelte-1ulnmwp");
add_location(div1, file$h, 37, 0, 1182);
add_location(div1, file$h, 40, 0, 1281);
},
l: function claim(nodes) {
throw new Error("options.hydrate only works if the component was compiled with the `hydratable: true` option");
@@ -8275,6 +8284,9 @@ var app = (function () {
if (response_data.message) $$invalidate(6, response_message = response_data.message);
console.log("response:", response_data, "status:", response_status, "message:", response_message);
// join socket room
socket$1.emit('join', room_name);
// go to room
if (response_status === 200 && response_message === "successfull room creation") $$invalidate(0, layout = "room");
}
@@ -8328,6 +8340,7 @@ var app = (function () {
};
$$self.$capture_state = () => ({
socket: socket$1,
Button: Element_button,
Warning: Element_warning,
layout,

File diff suppressed because one or more lines are too long