rooms have name

This commit is contained in:
hugogogo
2023-01-09 16:29:27 +01:00
parent e71e555ea4
commit e23699dd51
6 changed files with 63 additions and 48 deletions

View File

@@ -3336,6 +3336,7 @@ var app = (function () {
let msgs = writable([]);
let layout = writable("close");
let room_name = writable("");
let user;
let socket$1;
function set_user(new_user) { user = new_user; }
@@ -3884,19 +3885,20 @@ var app = (function () {
console.log(data.message);
socket$1.emit('join', room_name);
}
async function change_room(room_name) {
async function change_room(name) {
console.log("in change_room");
let name = {
room_name: room_name,
let r_name = {
room_name: name,
};
const response = await fetch('/api/v2/chat/change', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify(name),
body: JSON.stringify(r_name),
});
let data = await response.json();
console.log(data.message);
await get_room_messages();
room_name.set(name);
layout.set("room");
}
async function get_all_rooms() {
@@ -4640,7 +4642,7 @@ var app = (function () {
function get_each_context$5(ctx, list, i) {
const child_ctx = ctx.slice();
child_ctx[3] = list[i];
child_ctx[4] = list[i];
return child_ctx;
}
@@ -4677,11 +4679,14 @@ var app = (function () {
const block = {
c: function create() {
t = text("<room_name>");
t = text(/*$room_name*/ ctx[2]);
},
m: function mount(target, anchor) {
insert_dev(target, t, anchor);
},
p: function update(ctx, dirty) {
if (dirty & /*$room_name*/ 4) set_data_dev(t, /*$room_name*/ ctx[2]);
},
d: function destroy(detaching) {
if (detaching) detach_dev(t);
}
@@ -4728,7 +4733,7 @@ var app = (function () {
// (57:4) <Msg name={msg.name}>
function create_default_slot_1$8(ctx) {
let html_tag;
let raw_value = /*msg*/ ctx[3].message + "";
let raw_value = /*msg*/ ctx[4].message + "";
let html_anchor;
const block = {
@@ -4742,7 +4747,7 @@ var app = (function () {
insert_dev(target, html_anchor, anchor);
},
p: function update(ctx, dirty) {
if (dirty & /*$msgs*/ 4 && raw_value !== (raw_value = /*msg*/ ctx[3].message + "")) html_tag.p(raw_value);
if (dirty & /*$msgs*/ 8 && raw_value !== (raw_value = /*msg*/ ctx[4].message + "")) html_tag.p(raw_value);
},
d: function destroy(detaching) {
if (detaching) detach_dev(html_anchor);
@@ -4768,7 +4773,7 @@ var app = (function () {
msg_1 = new Element_msg({
props: {
name: /*msg*/ ctx[3].name,
name: /*msg*/ ctx[4].name,
$$slots: { default: [create_default_slot_1$8] },
$$scope: { ctx }
},
@@ -4785,9 +4790,9 @@ var app = (function () {
},
p: function update(ctx, dirty) {
const msg_1_changes = {};
if (dirty & /*$msgs*/ 4) msg_1_changes.name = /*msg*/ ctx[3].name;
if (dirty & /*$msgs*/ 8) msg_1_changes.name = /*msg*/ ctx[4].name;
if (dirty & /*$$scope, $msgs*/ 1028) {
if (dirty & /*$$scope, $msgs*/ 2056) {
msg_1_changes.$$scope = { dirty, ctx };
}
@@ -4895,7 +4900,7 @@ var app = (function () {
$$inline: true
});
let each_value = /*$msgs*/ ctx[2];
let each_value = /*$msgs*/ ctx[3];
validate_each_argument(each_value);
let each_blocks = [];
@@ -4910,7 +4915,7 @@ var app = (function () {
button3 = new Element_button({
props: {
my_class: "send",
on_click: /*send_msg*/ ctx[4],
on_click: /*send_msg*/ ctx[5],
$$slots: { default: [create_default_slot$a] },
$$scope: { ctx }
},
@@ -4939,17 +4944,17 @@ var app = (function () {
t4 = space();
create_component(button3.$$.fragment);
attr_dev(div0, "class", "msg_thread svelte-1quyp80");
add_location(div0, file$n, 54, 2, 928);
add_location(div0, file$n, 54, 2, 934);
attr_dev(div1, "class", "panel panel_msg svelte-1quyp80");
add_location(div1, file$n, 53, 1, 896);
add_location(div1, file$n, 53, 1, 902);
attr_dev(div2, "class", "text_area svelte-1quyp80");
attr_dev(div2, "contenteditable", "true");
if (/*msg*/ ctx[3] === void 0) add_render_callback(() => /*div2_input_handler*/ ctx[6].call(div2));
add_location(div2, file$n, 63, 2, 1102);
if (/*msg*/ ctx[4] === void 0) add_render_callback(() => /*div2_input_handler*/ ctx[7].call(div2));
add_location(div2, file$n, 63, 2, 1108);
attr_dev(div3, "class", "panel_write svelte-1quyp80");
add_location(div3, file$n, 62, 1, 1074);
add_location(div3, file$n, 62, 1, 1080);
attr_dev(div4, "class", "grid_box svelte-1quyp80");
add_location(div4, file$n, 35, 0, 544);
add_location(div4, file$n, 35, 0, 555);
},
l: function claim(nodes) {
throw new Error("options.hydrate only works if the component was compiled with the `hydratable: true` option");
@@ -4973,19 +4978,19 @@ var app = (function () {
append_dev(div4, div3);
append_dev(div3, div2);
if (/*msg*/ ctx[3] !== void 0) {
div2.innerHTML = /*msg*/ ctx[3];
if (/*msg*/ ctx[4] !== void 0) {
div2.innerHTML = /*msg*/ ctx[4];
}
/*div2_binding*/ ctx[7](div2);
/*div2_binding*/ ctx[8](div2);
append_dev(div4, t4);
mount_component(button3, div4, null);
current = true;
if (!mounted) {
dispose = [
listen_dev(div2, "input", /*div2_input_handler*/ ctx[6]),
listen_dev(div2, "keypress", /*enter_send_msg*/ ctx[5], false, false, false)
listen_dev(div2, "input", /*div2_input_handler*/ ctx[7]),
listen_dev(div2, "keypress", /*enter_send_msg*/ ctx[6], false, false, false)
];
mounted = true;
@@ -4996,28 +5001,28 @@ var app = (function () {
if (dirty & /*back*/ 1) button0_changes.new_layout = /*back*/ ctx[0];
if (dirty & /*back*/ 1) button0_changes.my_title = "go back " + /*back*/ ctx[0];
if (dirty & /*$$scope*/ 1024) {
if (dirty & /*$$scope*/ 2048) {
button0_changes.$$scope = { dirty, ctx };
}
button0.$set(button0_changes);
const button1_changes = {};
if (dirty & /*$$scope*/ 1024) {
if (dirty & /*$$scope, $room_name*/ 2052) {
button1_changes.$$scope = { dirty, ctx };
}
button1.$set(button1_changes);
const button2_changes = {};
if (dirty & /*$$scope*/ 1024) {
if (dirty & /*$$scope*/ 2048) {
button2_changes.$$scope = { dirty, ctx };
}
button2.$set(button2_changes);
if (dirty & /*$msgs*/ 4) {
each_value = /*$msgs*/ ctx[2];
if (dirty & /*$msgs*/ 8) {
each_value = /*$msgs*/ ctx[3];
validate_each_argument(each_value);
let i;
@@ -5044,13 +5049,13 @@ var app = (function () {
check_outros();
}
if (dirty & /*msg*/ 8 && /*msg*/ ctx[3] !== div2.innerHTML) {
div2.innerHTML = /*msg*/ ctx[3];
if (dirty & /*msg*/ 16 && /*msg*/ ctx[4] !== div2.innerHTML) {
div2.innerHTML = /*msg*/ ctx[4];
}
const button3_changes = {};
if (dirty & /*$$scope*/ 1024) {
if (dirty & /*$$scope*/ 2048) {
button3_changes.$$scope = { dirty, ctx };
}
@@ -5088,7 +5093,7 @@ var app = (function () {
destroy_component(button1);
destroy_component(button2);
destroy_each(each_blocks, detaching);
/*div2_binding*/ ctx[7](null);
/*div2_binding*/ ctx[8](null);
destroy_component(button3);
mounted = false;
run_all(dispose);
@@ -5107,9 +5112,12 @@ var app = (function () {
}
function instance$q($$self, $$props, $$invalidate) {
let $room_name;
let $msgs;
validate_store(room_name, 'room_name');
component_subscribe($$self, room_name, $$value => $$invalidate(2, $room_name = $$value));
validate_store(msgs, 'msgs');
component_subscribe($$self, msgs, $$value => $$invalidate(2, $msgs = $$value));
component_subscribe($$self, msgs, $$value => $$invalidate(3, $msgs = $$value));
let { $$slots: slots = {}, $$scope } = $$props;
validate_slots('Layout_room', slots, []);
let { back = "" } = $$props;
@@ -5117,7 +5125,7 @@ var app = (function () {
let text_area;
function send_msg() {
$$invalidate(3, msg = msg.trim());
$$invalidate(4, msg = msg.trim());
if (msg.length > 0) {
socket$1.emit('message', msg);
@@ -5125,7 +5133,7 @@ var app = (function () {
console.log(msgs);
}
$$invalidate(3, msg = "");
$$invalidate(4, msg = "");
text_area.focus();
}
@@ -5144,7 +5152,7 @@ var app = (function () {
function div2_input_handler() {
msg = this.innerHTML;
$$invalidate(3, msg);
$$invalidate(4, msg);
}
function div2_binding($$value) {
@@ -5163,6 +5171,7 @@ var app = (function () {
socket: socket$1,
msgs,
add_msg,
room_name,
Button: Element_button,
Msg: Element_msg,
back,
@@ -5170,12 +5179,13 @@ var app = (function () {
text_area,
send_msg,
enter_send_msg,
$room_name,
$msgs
});
$$self.$inject_state = $$props => {
if ('back' in $$props) $$invalidate(0, back = $$props.back);
if ('msg' in $$props) $$invalidate(3, msg = $$props.msg);
if ('msg' in $$props) $$invalidate(4, msg = $$props.msg);
if ('text_area' in $$props) $$invalidate(1, text_area = $$props.text_area);
};
@@ -5186,6 +5196,7 @@ var app = (function () {
return [
back,
text_area,
$room_name,
$msgs,
msg,
send_msg,

File diff suppressed because one or more lines are too long