small changes and clean comments

This commit is contained in:
simplonco
2023-01-05 10:26:09 +01:00
parent e16dc56314
commit 286d79ed06
6 changed files with 34 additions and 41 deletions

View File

@@ -7879,7 +7879,7 @@ var app = (function () {
return child_ctx;
}
// (50:1) <Button bind:layout new_layout={back} my_class="back icon" my_title="go back {back}">
// (46: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;
@@ -7899,14 +7899,14 @@ var app = (function () {
block,
id: create_default_slot_4$2.name,
type: "slot",
source: "(50:1) <Button bind:layout new_layout={back} my_class=\\\"back icon\\\" my_title=\\\"go back {back}\\\">",
source: "(46:1) <Button bind:layout new_layout={back} my_class=\\\"back icon\\\" my_title=\\\"go back {back}\\\">",
ctx
});
return block;
}
// (55:1) <Button bind:layout new_layout="room_set" my_class="room_name transparent">
// (51:1) <Button bind:layout new_layout="room_set" my_class="room_name transparent">
function create_default_slot_3$4(ctx) {
let t;
@@ -7926,14 +7926,14 @@ var app = (function () {
block,
id: create_default_slot_3$4.name,
type: "slot",
source: "(55:1) <Button bind:layout new_layout=\\\"room_set\\\" my_class=\\\"room_name transparent\\\">",
source: "(51:1) <Button bind:layout new_layout=\\\"room_set\\\" my_class=\\\"room_name transparent\\\">",
ctx
});
return block;
}
// (60:1) <Button bind:layout new_layout="close" my_class="close icon">
// (56:1) <Button bind:layout new_layout="close" my_class="close icon">
function create_default_slot_2$8(ctx) {
let t;
@@ -7953,14 +7953,14 @@ var app = (function () {
block,
id: create_default_slot_2$8.name,
type: "slot",
source: "(60:1) <Button bind:layout new_layout=\\\"close\\\" my_class=\\\"close icon\\\">",
source: "(56:1) <Button bind:layout new_layout=\\\"close\\\" my_class=\\\"close icon\\\">",
ctx
});
return block;
}
// (68:4) <Msg name={msg.name}>
// (64:4) <Msg name={msg.name}>
function create_default_slot_1$8(ctx) {
let html_tag;
let raw_value = /*msg*/ ctx[4].content + "";
@@ -7989,14 +7989,14 @@ var app = (function () {
block,
id: create_default_slot_1$8.name,
type: "slot",
source: "(68:4) <Msg name={msg.name}>",
source: "(64:4) <Msg name={msg.name}>",
ctx
});
return block;
}
// (67:3) {#each $msgs as msg}
// (63:3) {#each $msgs as msg}
function create_each_block$4(ctx) {
let msg_1;
let current;
@@ -8046,14 +8046,14 @@ var app = (function () {
block,
id: create_each_block$4.name,
type: "each",
source: "(67:3) {#each $msgs as msg}",
source: "(63:3) {#each $msgs as msg}",
ctx
});
return block;
}
// (85:1) <Button my_class="send" on_click={send_msg}>
// (81:1) <Button my_class="send" on_click={send_msg}>
function create_default_slot$a(ctx) {
let t;
@@ -8073,7 +8073,7 @@ var app = (function () {
block,
id: create_default_slot$a.name,
type: "slot",
source: "(85:1) <Button my_class=\\\"send\\\" on_click={send_msg}>",
source: "(81:1) <Button my_class=\\\"send\\\" on_click={send_msg}>",
ctx
});
@@ -8200,17 +8200,17 @@ var app = (function () {
t4 = space();
create_component(button3.$$.fragment);
attr_dev(div0, "class", "msg_thread svelte-1quyp80");
add_location(div0, file$m, 65, 2, 1218);
add_location(div0, file$m, 61, 2, 1104);
attr_dev(div1, "class", "panel panel_msg svelte-1quyp80");
add_location(div1, file$m, 64, 1, 1186);
add_location(div1, file$m, 60, 1, 1072);
attr_dev(div2, "class", "text_area svelte-1quyp80");
attr_dev(div2, "contenteditable", "true");
if (/*msg*/ ctx[4] === void 0) add_render_callback(() => /*div2_input_handler*/ ctx[10].call(div2));
add_location(div2, file$m, 74, 2, 1392);
add_location(div2, file$m, 70, 2, 1278);
attr_dev(div3, "class", "panel_write svelte-1quyp80");
add_location(div3, file$m, 73, 1, 1364);
add_location(div3, file$m, 69, 1, 1250);
attr_dev(div4, "class", "grid_box svelte-1quyp80");
add_location(div4, file$m, 46, 0, 798);
add_location(div4, file$m, 42, 0, 684);
},
l: function claim(nodes) {
throw new Error("options.hydrate only works if the component was compiled with the `hydratable: true` option");
@@ -8396,11 +8396,7 @@ var app = (function () {
let msg = "";
let text_area;
//let msgs = [];
function add_msg(from, message) {
if (from === user.username) from = "me";
//msgs = [...msgs, { content: message, name: from }];
function add_local_msg(from, message) {
msgs.update(msgs => [...msgs, { content: message, name: from }]);
}
@@ -8409,7 +8405,7 @@ var app = (function () {
if (msg.length > 0) {
socket$1.emit('message', msg);
add_msg("me", msg);
add_local_msg("me", msg);
}
$$invalidate(4, msg = "");
@@ -8465,13 +8461,12 @@ var app = (function () {
Button: Chat_button,
Msg: Chat_msg,
socket: socket$1,
user,
msgs,
layout,
back,
msg,
text_area,
add_msg,
add_local_msg,
send_msg,
send_msg_if,
$msgs
@@ -14038,12 +14033,11 @@ var app = (function () {
console.log("socket.io pong");
});
socket$1.on('message', (from, message) => {
socket$1.on('message', function (from, message) {
console.log("received msg:", message, from);
if (from === user.username) from = "me";
//msgs = [...msgs, { content: message, name: from }];
msgs.update(msgs => [...msgs, { content: message, name: from }]);
}); //add_msg(name, message);
});
const writable_props = ['color'];

File diff suppressed because one or more lines are too long

View File

@@ -9,6 +9,7 @@
import { socket, user } from './Chat_socket.svelte';
import { msgs } from './Store_msg.js';
// pbm: sometimes socket is still undefined here
socket.on('connect', function(){
console.log("socket.io connected");
@@ -47,13 +48,12 @@
console.log("socket.io pong");
});
socket.on('message', (from, message) => {
socket.on('message', function(from, message)
{
console.log("received msg:", message, from);
if (from === user.username)
from = "me";
//msgs = [...msgs, { content: message, name: from }];
msgs.update(msgs => [...msgs, { content: message, name: from }]);
//add_msg(name, message);
});
</script>

View File

@@ -3,7 +3,7 @@
import Button from './Chat_button.svelte';
import Msg from './Chat_msg.svelte';
import { socket, user } from './Chat_socket.svelte';
import { socket } from './Chat_socket.svelte';
import { msgs } from './Store_msg.js';
export let layout = "";
@@ -11,13 +11,9 @@
let msg = "";
let text_area;
//let msgs = [];
function add_msg(from, message)
function add_local_msg(from, message)
{
if (from === user.username)
from = "me";
//msgs = [...msgs, { content: message, name: from }];
msgs.update(msgs => [...msgs, { content: message, name: from }]);
}
@@ -26,7 +22,7 @@
msg = msg.trim();
if (msg.length > 0) {
socket.emit('message', msg);
add_msg("me", msg);
add_local_msg("me", msg);
}
msg = "";

View File

@@ -1,5 +1,7 @@
import { writable } from 'svelte/store';
export let user = writable({});
export let socket = writable({});
export let msgs = writable([]);