Radish alpha
r
Radicle web interface
Radicle
Git (anonymous pull)
Log in to clone via SSH
Properly `await` promises
Rūdolfs Ošiņš committed 2 years ago
commit dd3b514dfc7a420dd77e049ba60ea74350561ce4
parent 37f6cccced511e1cc548bc7fa7d6a423feb2d1fc
4 files changed +14 -14
modified src/App/Header/Connect.svelte
@@ -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">
modified src/components/Clipboard.svelte
@@ -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>
modified src/lib/utils.ts
@@ -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(
modified src/views/projects/Issue.svelte
@@ -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