misc: use bindings to show updated data easily
This commit is contained in:
1 parent
4646a59ddf
commit
dca0edf0b1
8 files changed
+63
-58
No files matched your search
@@ -153,7 +153,7 @@
|
||||
{#if actions}
|
||||
<div class="flex flex-row gap-2 items-center">
|
||||
<CommentActions
|
||||
comment={node.comment_view}
|
||||
bind:comment={node.comment_view}
|
||||
bind:replying
|
||||
on:edit={() => (editing = true)}
|
||||
/>
|
||||
|
||||
@@ -78,7 +78,7 @@
|
||||
<span class="text-xs">Reply</span>
|
||||
</Button>
|
||||
{#if $profile?.user && (amMod($profile?.user, comment.community) || isAdmin($profile.user))}
|
||||
<CommentModerationMenu item={comment} />
|
||||
<CommentModerationMenu bind:item={comment} />
|
||||
{/if}
|
||||
<Menu
|
||||
let:toggleOpen
|
||||
|
||||
@@ -109,7 +109,7 @@
|
||||
op={post.creator_id == node.comment_view.creator.id}
|
||||
>
|
||||
{#if node.children?.length > 0}
|
||||
<svelte:self {post} nodes={node.children} isParent={false} />
|
||||
<svelte:self {post} bind:nodes={node.children} isParent={false} />
|
||||
{/if}
|
||||
{#if node.comment_view.counts.child_count > 0 && node.children.length == 0}
|
||||
<div
|
||||
|
||||
@@ -101,7 +101,7 @@
|
||||
class:opacity-100={loaded}
|
||||
width={512}
|
||||
height={300}
|
||||
class:blur-3xl={post.post.nsfw}
|
||||
class:blur-3xl={post.post.nsfw && $userSettings.nsfwBlur}
|
||||
on:load={() => (loaded = true)}
|
||||
/>
|
||||
</picture>
|
||||
@@ -129,11 +129,8 @@
|
||||
{/if}
|
||||
{#if actions}
|
||||
<PostActions
|
||||
{post}
|
||||
bind:post
|
||||
on:edit={(e) => {
|
||||
post.post.name = e.detail.post.name
|
||||
post.post.body = e.detail.post.body
|
||||
post.post.url = e.detail.post.url
|
||||
toast({
|
||||
content: 'The post was edited successfully.',
|
||||
type: 'success',
|
||||
|
||||
@@ -59,7 +59,7 @@
|
||||
}
|
||||
|
||||
async function save(post: PostView) {
|
||||
if (!$profile?.jwt) return
|
||||
if (!$profile?.jwt) return false
|
||||
|
||||
const saved = post.saved
|
||||
|
||||
@@ -79,6 +79,8 @@
|
||||
type: 'error',
|
||||
})
|
||||
}
|
||||
|
||||
return post.saved
|
||||
}
|
||||
|
||||
const dispatcher = createEventDispatcher<{ edit: PostView }>()
|
||||
@@ -119,7 +121,7 @@
|
||||
</Button>
|
||||
<div class="ml-auto" />
|
||||
{#if $profile?.user && (amMod($profile.user, post.community) || isAdmin($profile.user))}
|
||||
<ModerationMenu item={post} community={post.community} />
|
||||
<ModerationMenu bind:item={post} community={post.community} />
|
||||
{/if}
|
||||
<Menu alignment="bottom-right" class="overflow-auto" let:toggleOpen>
|
||||
<Button
|
||||
@@ -166,7 +168,7 @@
|
||||
Copy Link
|
||||
</MenuButton>
|
||||
{#if $profile?.jwt}
|
||||
<MenuButton on:click={() => save(post)}>
|
||||
<MenuButton on:click={async () => (post.saved = await save(post))}>
|
||||
<Icon src={post.saved ? BookmarkSlash : Bookmark} width={16} mini />
|
||||
{post.saved ? 'Unsave' : 'Save'}
|
||||
</MenuButton>
|
||||
|
||||
@@ -31,6 +31,7 @@ interface Settings {
|
||||
notifRate: number
|
||||
}
|
||||
displayNames: boolean
|
||||
nsfwBlur: boolean
|
||||
}
|
||||
|
||||
const defaultSettings: Settings = {
|
||||
@@ -61,6 +62,7 @@ const defaultSettings: Settings = {
|
||||
notifRate: 10 * 60 * 1000,
|
||||
},
|
||||
displayNames: true,
|
||||
nsfwBlur: true,
|
||||
}
|
||||
|
||||
export const userSettings = writable(defaultSettings)
|
||||
|
||||
Reference in new issue
Block a user