flotilla/src/routes/settings/+page.svelte

40 lines
1.3 KiB
Svelte
Raw Normal View History

2024-10-03 21:32:55 +00:00
<script lang="ts">
2024-10-09 23:15:09 +00:00
import {ctx} from "@welshman/lib"
2024-10-08 22:30:18 +00:00
import {getListTags, createEvent, getPubkeyTagValues, MUTES} from "@welshman/util"
import {userMutes, tagPubkey, publishThunk} from "@welshman/app"
2024-10-08 18:39:16 +00:00
import Field from "@lib/components/Field.svelte"
import Button from "@lib/components/Button.svelte"
import ProfileMultiSelect from "@app/components/ProfileMultiSelect.svelte"
import {pushToast} from "@app/toast"
2024-10-03 21:32:55 +00:00
2024-10-08 18:39:16 +00:00
let mutedPubkeys = getPubkeyTagValues(getListTags($userMutes))
2024-10-03 21:32:55 +00:00
const reset = () => {
2024-10-08 18:39:16 +00:00
mutedPubkeys = getPubkeyTagValues(getListTags($userMutes))
2024-10-03 21:32:55 +00:00
}
const onSubmit = async () => {
2024-10-08 22:30:18 +00:00
publishThunk({
event: createEvent(MUTES, {tags: mutedPubkeys.map(tagPubkey)}),
relays: ctx.app.router.WriteRelays().getUrls(),
})
2024-10-03 21:32:55 +00:00
pushToast({message: "Your settings have been saved!"})
}
</script>
<form class="content column gap-4" on:submit|preventDefault={onSubmit}>
<div class="card2 bg-alt shadow-xl">
<Field>
<p slot="label">Muted Accounts</p>
2024-10-03 22:28:06 +00:00
<div slot="input">
<ProfileMultiSelect bind:value={mutedPubkeys} />
2024-10-03 21:32:55 +00:00
</div>
</Field>
2024-10-08 18:39:16 +00:00
<div class="mt-4 flex flex-row items-center justify-between gap-4">
<Button class="btn btn-neutral" on:click={reset}>Discard Changes</Button>
<Button type="submit" class="btn btn-primary">Save Changes</Button>
2024-10-03 21:32:55 +00:00
</div>
</div>
</form>