feat: implement whisper, (double)click on avatar

Users can insert a mention by clicking, and initiate a whisper by
double-clicking on the avatar on a user's chat message
This commit is contained in:
2023-02-14 00:23:07 +01:00
parent 38f926b32f
commit 7d581afcaf
6 changed files with 52 additions and 9 deletions

View File

@@ -1,11 +1,20 @@
<script lang="ts">
import { tick } from "svelte"
import { send } from "./chat";
import { send, whisper } from "./chat";
let input = "";
export let input = "";
async function keydown(e: KeyboardEvent) {
if(e.key === "Enter") {
send(input);
console.log(e);
const tokens = input.trim().split(" ");
if(tokens[0] === '/w') {
const who = tokens[1];
const m = tokens.slice(2).join(' ');
whisper(who, m);
} else {
send(input);
}
e.preventDefault();
await tick();
input = "";