Radish alpha
r
rad:z4V1sjrXqjvFdnCUbxPFqd5p4DtH5
Radicle web interface
Radicle
Git
Simplify share button link resolution
Merged rudolfs opened 1 year ago

We just use the radicleExplorer that is configured in the app config and don’t query the node for it. Besides simplifying things this also makes the button work on iOS again, because we don’t have the async http request anymore.

check check-visual check-unit-test check-http-client-unit-test check-radicle-httpd check-e2e check-build check-http 👉 Preview 👉 Workflow runs 👉 Branch on GitHub

7 files changed +12 -36 87979c5f 472993c6
modified src/views/projects/Commit.svelte
@@ -64,7 +64,7 @@
                <IconSmall name="chevron-left-right" />
              </Button>
            </Link>
-
            <Share {baseUrl} />
+
            <Share />
          </div>
        </span>
        <CommitAuthorship {header}>
modified src/views/projects/Issue.svelte
@@ -136,7 +136,7 @@
              <span class="txt-missing">No title</span>
            {/if}
          </div>
-
          <Share {baseUrl} />
+
          <Share />
        </svelte:fragment>
        <svelte:fragment slot="state">
          {#if issue.state.status === "open"}
modified src/views/projects/Issues.svelte
@@ -167,7 +167,7 @@
      </DropdownList>
    </Popover>

-
    <Share {baseUrl} />
+
    <Share />
  </div>

  <List items={allIssues}>
modified src/views/projects/Patch.svelte
@@ -304,7 +304,7 @@
          {:else}
            <span class="txt-missing">No title</span>
          {/if}
-
          <Share {baseUrl} />
+
          <Share />
        </svelte:fragment>
        <svelte:fragment slot="state">
          <Badge size="tiny" variant={badgeColor(patch.state.status)}>
modified src/views/projects/Patches.svelte
@@ -174,7 +174,7 @@
      </DropdownList>
    </Popover>

-
    <Share {baseUrl} />
+
    <Share />
  </div>

  <List items={allPatches}>
modified src/views/projects/Share.svelte
@@ -1,52 +1,28 @@
<script lang="ts">
-
  import type { BaseUrl } from "@http-client";
-

  import config from "virtual:config";
  import debounce from "lodash/debounce";
-
  import { HttpdClient } from "@http-client";
  import { toClipboard } from "@app/lib/utils";

  import Button from "@app/components/Button.svelte";
  import IconSmall from "@app/components/IconSmall.svelte";

-
  export let baseUrl: BaseUrl;
-

  let shareIcon: "link" | "checkmark" = "link";
-
  let loading = false;

  const restoreIcon = debounce(() => {
    shareIcon = "link";
  }, 1000);

-
  $: api = new HttpdClient(baseUrl);
-

  async function copy() {
-
    if (loading) {
-
      return;
-
    }
-
    try {
-
      loading = true;
-
      const profile = await api.profile.getProfile().catch(() => undefined);
-
      const publicExplorer =
-
        profile?.config.publicExplorer ?? config.nodes.fallbackPublicExplorer;
-
      const text = new URL(publicExplorer).origin.concat(
-
        window.location.pathname,
-
      );
-
      await toClipboard(text);
-
      shareIcon = "checkmark";
-
    } finally {
-
      loading = false;
-
    }
+
    const text = new URL(config.nodes.fallbackPublicExplorer).origin.concat(
+
      window.location.pathname,
+
    );
+
    await toClipboard(text);
+
    shareIcon = "checkmark";
    restoreIcon();
  }
</script>

-
<Button
-
  variant="outline"
-
  size="regular"
-
  on:click={async () => {
-
    await copy();
-
  }}>
+
<Button variant="outline" size="regular" on:click={copy}>
  <IconSmall name={shareIcon} />
  <span class="global-hide-on-small-desktop-down">Copy link</span>
</Button>
modified src/views/projects/Source/ProjectNameHeader.svelte
@@ -82,7 +82,7 @@
      </Badge>
    {/if}
    <div style="margin-left: auto; display: flex; gap: 0.5rem;">
-
      <Share {baseUrl} />
+
      <Share />
      <div
        style:display="flex"
        style:gap="0.5rem"