mirror of
https://seed.radicle.dev/rad:z4V1sjrXqjvFdnCUbxPFqd5p4DtH5.git
synced 2026-10-18 19:30:27 +08:00
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:
@@ -64,7 +64,7 @@
|
||||
<IconSmall name="chevron-left-right" />
|
||||
</Button>
|
||||
</Link>
|
||||
<Share {baseUrl} />
|
||||
<Share />
|
||||
</div>
|
||||
</span>
|
||||
<CommitAuthorship {header}>
|
||||
|
||||
@@ -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"}
|
||||
|
||||
@@ -167,7 +167,7 @@
|
||||
</DropdownList>
|
||||
</Popover>
|
||||
|
||||
<Share {baseUrl} />
|
||||
<Share />
|
||||
</div>
|
||||
|
||||
<List items={allIssues}>
|
||||
|
||||
@@ -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)}>
|
||||
|
||||
@@ -174,7 +174,7 @@
|
||||
</DropdownList>
|
||||
</Popover>
|
||||
|
||||
<Share {baseUrl} />
|
||||
<Share />
|
||||
</div>
|
||||
|
||||
<List items={allPatches}>
|
||||
|
||||
@@ -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"
|
||||
|
||||
Reference in New Issue
Block a user