2026-01-16 21:49:35 +00:00
|
|
|
<script lang="ts">
|
2026-09-07 21:39:01 +00:00
|
|
|
import {publish} from "@welshman/app"
|
2026-03-11 22:48:36 +00:00
|
|
|
import ShieldMinimalistic from "@assets/icons/shield-minimalistic.svg?dataurl"
|
2026-09-07 21:39:01 +00:00
|
|
|
import ForbiddenCircle from "@assets/icons/forbidden-circle.svg?dataurl"
|
2026-01-16 21:49:35 +00:00
|
|
|
import {preventDefault} from "@lib/html"
|
2026-04-17 21:58:52 +00:00
|
|
|
import FieldInline from "@lib/components/FieldInline.svelte"
|
2026-07-15 16:30:17 +00:00
|
|
|
import ToggleInput from "@lib/components/ToggleInput.svelte"
|
2026-03-11 22:48:36 +00:00
|
|
|
import Icon from "@lib/components/Icon.svelte"
|
2026-06-24 20:56:53 +00:00
|
|
|
import Card from "@lib/components/Card.svelte"
|
|
|
|
|
import PageContent from "@lib/components/PageContent.svelte"
|
2026-01-16 21:49:35 +00:00
|
|
|
import Button from "@lib/components/Button.svelte"
|
2026-08-13 19:57:42 +00:00
|
|
|
import Spinner from "@lib/components/Spinner.svelte"
|
2026-09-07 21:39:01 +00:00
|
|
|
import RelayList from "@app/components/RelayList.svelte"
|
|
|
|
|
import {blockedRelayLists, user} from "@app/core"
|
|
|
|
|
import {pushModal} from "@app/modal"
|
2026-06-08 21:14:40 +00:00
|
|
|
import {pushToast} from "@app/toast"
|
2026-06-08 22:33:38 +00:00
|
|
|
import {PLATFORM_NAME} from "@app/env"
|
2026-08-13 19:57:42 +00:00
|
|
|
import {sendLogs} from "@app/logger"
|
2026-08-22 20:12:11 +00:00
|
|
|
import {
|
|
|
|
|
RelayAuthMode,
|
|
|
|
|
userSettingsValues,
|
|
|
|
|
publishSettings,
|
|
|
|
|
createSettingsForm,
|
|
|
|
|
} from "@app/settings"
|
2026-01-16 21:49:35 +00:00
|
|
|
|
|
|
|
|
const reset = () => {
|
2026-08-22 20:12:11 +00:00
|
|
|
settings.set({...$userSettingsValues})
|
2026-01-16 21:49:35 +00:00
|
|
|
}
|
|
|
|
|
|
2026-08-13 19:57:42 +00:00
|
|
|
const send = async () => {
|
2026-08-31 23:03:20 +00:00
|
|
|
sendingLogs = true
|
2026-08-13 19:57:42 +00:00
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
const thunk = await sendLogs()
|
|
|
|
|
const error = await thunk.waitForError()
|
|
|
|
|
|
|
|
|
|
if (error) {
|
|
|
|
|
pushToast({theme: "error", message: error})
|
|
|
|
|
} else {
|
|
|
|
|
pushToast({message: "Your logs have been sent. Thank you!"})
|
|
|
|
|
}
|
|
|
|
|
} finally {
|
2026-08-31 23:03:20 +00:00
|
|
|
sendingLogs = false
|
2026-08-13 19:57:42 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2026-07-15 16:30:17 +00:00
|
|
|
const onAuthModeChange = (checked: boolean) => {
|
2026-08-22 20:12:11 +00:00
|
|
|
$settings.relay_auth = checked ? RelayAuthMode.Aggressive : RelayAuthMode.Conservative
|
2026-01-16 21:49:35 +00:00
|
|
|
}
|
|
|
|
|
|
2026-09-07 21:39:01 +00:00
|
|
|
const showBlockedRelays = () =>
|
|
|
|
|
pushModal(RelayList, {
|
|
|
|
|
title: "Blocked Relays",
|
|
|
|
|
subtitle: "These relays won't be used unless explicitly requested.",
|
|
|
|
|
relays: blockedRelayUrls,
|
|
|
|
|
addRelay: (url: string) => $blockedRelayLists.addUrl(url).then(publish),
|
|
|
|
|
removeRelay: (url: string) => $blockedRelayLists.removeUrl(url).then(publish),
|
|
|
|
|
})
|
|
|
|
|
|
2026-01-16 21:49:35 +00:00
|
|
|
const onsubmit = preventDefault(async () => {
|
2026-08-31 23:03:20 +00:00
|
|
|
loading = true
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
await publishSettings($settings)
|
2026-01-16 21:49:35 +00:00
|
|
|
|
2026-08-31 23:03:20 +00:00
|
|
|
pushToast({message: "Your settings have been saved!"})
|
|
|
|
|
} finally {
|
|
|
|
|
loading = false
|
|
|
|
|
}
|
2026-01-16 21:49:35 +00:00
|
|
|
})
|
|
|
|
|
|
2026-08-22 20:12:11 +00:00
|
|
|
const settings = createSettingsForm()
|
2026-09-07 21:39:01 +00:00
|
|
|
const blockedRelayUrls = $blockedRelayLists.urls($user.pubkey).$
|
|
|
|
|
|
2026-08-13 19:57:42 +00:00
|
|
|
let loading = $state(false)
|
2026-08-31 23:03:20 +00:00
|
|
|
let sendingLogs = $state(false)
|
2026-01-16 21:49:35 +00:00
|
|
|
</script>
|
|
|
|
|
|
2026-06-24 20:56:53 +00:00
|
|
|
<form {onsubmit}>
|
|
|
|
|
<PageContent>
|
|
|
|
|
<Card class="flex flex-col gap-4">
|
|
|
|
|
<strong class="flex items-center gap-3 text-lg">
|
|
|
|
|
<Icon icon={ShieldMinimalistic} />
|
|
|
|
|
Privacy Settings
|
|
|
|
|
</strong>
|
|
|
|
|
<FieldInline>
|
|
|
|
|
{#snippet label()}
|
|
|
|
|
<p>Authenticate with unknown relays?</p>
|
|
|
|
|
{/snippet}
|
|
|
|
|
{#snippet input()}
|
2026-07-15 16:30:17 +00:00
|
|
|
<ToggleInput
|
2026-08-22 20:12:11 +00:00
|
|
|
checked={$settings.relay_auth === RelayAuthMode.Aggressive}
|
2026-07-15 16:30:17 +00:00
|
|
|
onchange={onAuthModeChange} />
|
2026-06-24 20:56:53 +00:00
|
|
|
{/snippet}
|
|
|
|
|
{#snippet info()}
|
|
|
|
|
<p>Controls whether {PLATFORM_NAME} will identify you to relays not in your lists.</p>
|
|
|
|
|
{/snippet}
|
|
|
|
|
</FieldInline>
|
2026-09-07 21:39:01 +00:00
|
|
|
<FieldInline>
|
|
|
|
|
{#snippet label()}
|
|
|
|
|
<p>Blocked relays</p>
|
|
|
|
|
{/snippet}
|
|
|
|
|
{#snippet input()}
|
|
|
|
|
<Button class="button button-neutral" onclick={showBlockedRelays}>
|
|
|
|
|
<Icon icon={ForbiddenCircle} />
|
|
|
|
|
{$blockedRelayUrls.length} Blocked
|
|
|
|
|
</Button>
|
|
|
|
|
{/snippet}
|
|
|
|
|
{#snippet info()}
|
|
|
|
|
<p>These relays won't be used unless explicitly requested.</p>
|
|
|
|
|
{/snippet}
|
|
|
|
|
</FieldInline>
|
2026-06-24 20:56:53 +00:00
|
|
|
<FieldInline>
|
|
|
|
|
{#snippet label()}
|
2026-08-13 19:57:42 +00:00
|
|
|
<p>Report usage?</p>
|
2026-06-24 20:56:53 +00:00
|
|
|
{/snippet}
|
|
|
|
|
{#snippet input()}
|
2026-08-22 20:12:11 +00:00
|
|
|
<ToggleInput bind:checked={$settings.report_usage} />
|
2026-06-24 20:56:53 +00:00
|
|
|
{/snippet}
|
|
|
|
|
{#snippet info()}
|
2026-08-13 19:57:42 +00:00
|
|
|
<p>Allow {PLATFORM_NAME} to collect anonymous usage data.</p>
|
2026-06-24 20:56:53 +00:00
|
|
|
{/snippet}
|
|
|
|
|
</FieldInline>
|
|
|
|
|
<FieldInline>
|
|
|
|
|
{#snippet label()}
|
2026-08-13 19:57:42 +00:00
|
|
|
<p>Something went wrong?</p>
|
2026-06-24 20:56:53 +00:00
|
|
|
{/snippet}
|
|
|
|
|
{#snippet input()}
|
2026-08-31 23:03:20 +00:00
|
|
|
<Button class="button button-neutral" onclick={send} disabled={sendingLogs}>
|
|
|
|
|
<Spinner loading={sendingLogs}>Send Logs</Spinner>
|
2026-08-13 19:57:42 +00:00
|
|
|
</Button>
|
2026-06-24 20:56:53 +00:00
|
|
|
{/snippet}
|
|
|
|
|
{#snippet info()}
|
2026-08-13 19:57:42 +00:00
|
|
|
<p>
|
|
|
|
|
Send a record of recent app activity to the {PLATFORM_NAME} team as a direct message.
|
|
|
|
|
</p>
|
2026-06-24 20:56:53 +00:00
|
|
|
{/snippet}
|
|
|
|
|
</FieldInline>
|
|
|
|
|
</Card>
|
|
|
|
|
<Card class="sticky -bottom-3 shadow-md flex flex-row items-center justify-between gap-4">
|
2026-08-31 23:03:20 +00:00
|
|
|
<Button class="button button-neutral" onclick={reset} disabled={loading}
|
|
|
|
|
>Discard Changes</Button>
|
|
|
|
|
<Button class="button button-primary" type="submit" disabled={loading}>
|
|
|
|
|
<Spinner {loading}>Save Changes</Spinner>
|
|
|
|
|
</Button>
|
2026-06-24 20:56:53 +00:00
|
|
|
</Card>
|
|
|
|
|
</PageContent>
|
2026-01-16 21:49:35 +00:00
|
|
|
</form>
|