Properly await promises

Signed-off-by: Rūdolfs Ošiņš <rudolfs@osins.org>
This commit is contained in:
Rūdolfs Ošiņš
2023-05-29 15:54:00 +02:00
parent 37f6cccced
commit dd3b514dfc
4 changed files with 14 additions and 14 deletions
+6 -6
View File
@@ -16,8 +16,8 @@
icon = "clipboard-small";
}, 800);
function copyToClipboard(clipboard: string) {
void toClipboard(clipboard);
async function copyToClipboard(clipboard: string): Promise<void> {
await toClipboard(clipboard);
icon = "checkmark-small";
restoreIcon();
}
@@ -181,8 +181,8 @@
<!-- svelte-ignore a11y-click-events-have-key-events -->
<span
class="cmd"
on:click={() => {
copyToClipboard(command);
on:click={async () => {
await copyToClipboard(command);
}}>
{command}
<div class="cmd-clipboard">
@@ -199,9 +199,9 @@
<!-- svelte-ignore a11y-click-events-have-key-events -->
<div
class="id-container"
on:click={() => {
on:click={async () => {
if ($sessionStore) {
copyToClipboard($sessionStore.publicKey);
await copyToClipboard($sessionStore.publicKey);
}
}}>
<div class="id">
+3 -3
View File
@@ -19,12 +19,12 @@
icon = small ? "clipboard-small" : "clipboard";
}, 800);
const copy = () => {
void toClipboard(text);
async function copy() {
await toClipboard(text);
dispatch("copied");
icon = small ? "checkmark-small" : "checkmark";
restoreIcon();
};
}
</script>
<style>
+1 -1
View File
@@ -8,7 +8,7 @@ import { base } from "@app/lib/router";
import { config } from "@app/lib/config";
export async function toClipboard(text: string): Promise<void> {
return navigator.clipboard.writeText(text);
await navigator.clipboard.writeText(text);
}
export function getRawBasePath(
+4 -4
View File
@@ -257,8 +257,8 @@
{#if $sessionStore}
<Textarea
resizable
on:submit={() => {
void createComment(commentBody);
on:submit={async () => {
await createComment(commentBody);
commentBody = "";
}}
bind:value={commentBody}
@@ -273,8 +273,8 @@
variant="secondary"
size="small"
disabled={!commentBody}
on:click={() => {
void createComment(commentBody);
on:click={async () => {
await createComment(commentBody);
commentBody = "";
}}>
Comment