Simplify share button link resolution

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.
This commit is contained in:
Rūdolfs Ošiņš
2024-07-17 14:13:57 +02:00
parent 87979c5feb
commit 472993c6df
7 changed files with 12 additions and 36 deletions
+1 -1
View File
@@ -64,7 +64,7 @@
<IconSmall name="chevron-left-right" />
</Button>
</Link>
<Share {baseUrl} />
<Share />
</div>
</span>
<CommitAuthorship {header}>
+1 -1
View File
@@ -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"}
+1 -1
View File
@@ -167,7 +167,7 @@
</DropdownList>
</Popover>
<Share {baseUrl} />
<Share />
</div>
<List items={allIssues}>
+1 -1
View File
@@ -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)}>
+1 -1
View File
@@ -174,7 +174,7 @@
</DropdownList>
</Popover>
<Share {baseUrl} />
<Share />
</div>
<List items={allPatches}>
+6 -30
View File
@@ -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>
@@ -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"