Add user settings

This commit is contained in:
Jon Staab
2024-10-17 15:46:26 -07:00
parent defb16aa1c
commit b4baef215a
4 changed files with 70 additions and 8 deletions
+15 -5
View File
@@ -1,20 +1,27 @@
<script lang="ts">
import {ctx} from "@welshman/lib"
import {getListTags, createEvent, getPubkeyTagValues, MUTES} from "@welshman/util"
import {userMutes, tagPubkey, publishThunk} from "@welshman/app"
import {getListTags, createEvent, getPubkeyTagValues, MUTES, APP_DATA} from "@welshman/util"
import {pubkey, signer, userMutes, tagPubkey, publishThunk} from "@welshman/app"
import Field from "@lib/components/Field.svelte"
import FieldInline from "@lib/components/FieldInline.svelte"
import Button from "@lib/components/Button.svelte"
import ProfileMultiSelect from "@app/components/ProfileMultiSelect.svelte"
import {pushToast} from "@app/toast"
let mutedPubkeys = getPubkeyTagValues(getListTags($userMutes))
import {SETTINGS, userSettings} from "@app/state"
const reset = () => {
mutedPubkeys = getPubkeyTagValues(getListTags($userMutes))
}
const onSubmit = async () => {
publishThunk({
event: createEvent(APP_DATA, {
content: await $signer!.nip04.encrypt($pubkey!, JSON.stringify(settings)),
tags: [["d", SETTINGS]]
}),
relays: ctx.app.router.WriteRelays().getUrls(),
})
publishThunk({
event: createEvent(MUTES, {tags: mutedPubkeys.map(tagPubkey)}),
relays: ctx.app.router.WriteRelays().getUrls(),
@@ -22,6 +29,9 @@
pushToast({message: "Your settings have been saved!"})
}
let settings = {...$userSettings?.values}
let mutedPubkeys = getPubkeyTagValues(getListTags($userMutes))
</script>
<form class="content column gap-4" on:submit|preventDefault={onSubmit}>
@@ -34,7 +44,7 @@
</Field>
<FieldInline>
<p slot="label">Hide sensitive content?</p>
<input slot="input" type="checkbox" class="toggle toggle-primary" checked="checked" />
<input slot="input" type="checkbox" class="toggle toggle-primary" bind:checked={settings.hide_sensitive} />
<p slot="info">If content is marked by the author as sensitive, flotilla will hide it by default.</p>
</FieldInline>
<div class="mt-4 flex flex-row items-center justify-between gap-4">