Compare commits

..

4 commits

5 changed files with 23 additions and 7 deletions

View file

@ -28,6 +28,7 @@
.message-content {
color: var(--foreground-color-2);
white-space: pre-wrap;
}
.pending {

View file

@ -44,10 +44,14 @@
};
const onKeydown = async (e) => {
if (e.code !== "Enter")
return;
await sendMessage();
if (e.code === "Enter") {
if (e.shiftKey) {
return;
} else {
e.preventDefault();
await sendMessage();
}
}
};
</script>
@ -82,13 +86,13 @@
</style>
<div class="message-input-container">
<input
<textarea
placeholder={`Send something interesting to #${channel.name}`}
type="text"
class="message-input"
on:keydown={ onKeydown }
bind:value={ messageInput }
>
/>
{#if $smallViewport}
<button class="icon-button send-button" on:click="{ sendMessage }">
<SendIcon />

View file

@ -224,6 +224,9 @@ class MessageStore extends Store {
}
async loadOlderMessages(beforeCommitToStore=null) {
if (this.channelId === -1)
return;
const oldestMessage = this.value[0];
const endpoint = oldestMessage ? `channels/${this.channelId}/messages/?before=${oldestMessage.id}` : `channels/${this.channelId}/messages`;
const res = await request("GET", apiRoute(endpoint), true, null);
@ -298,11 +301,14 @@ class OverlayStore extends Store {
toast: null,
login: null,
createAccount: null,
settings: null
editMessage: null,
settings: null,
}, "OverlayStore");
}
open(name, props={}) {
if (this.value[name] === undefined)
throw new Error(`OverlayStore.open: tried to open unknown overlay with name '${name}' (undefined in overlay map)`);
this.value[name] = props;
this.updated();
}

View file

@ -17,4 +17,5 @@ export const gatewayErrors = {
ALREADY_AUTHENTICATED: { code: 4006, message: "Already authenticated" },
PAYLOAD_TOO_LARGE: { code: 4007, message: "Payload too large" },
TOO_MANY_SESSIONS: { code: 4008, message: "Too many sessions" },
NOT_AUTHENTICATED: { code: 4009, message: "Not authenticated" },
};

View file

@ -245,6 +245,10 @@ export default function(server: Server) {
return closeWithBadPayload(ws, "d: expected numeric '0'");
}
if (!ws.state.ready) {
return closeWithError(ws, gatewayErrors.NOT_AUTHENTICATED);
}
// TODO: also check session here
ws.state.alive = true;
break;