feat: add ability to mark individual posts as read, close #114
This commit is contained in:
1 parent
0be27d8eee
commit
79221e2e53
3 files changed
+32
-3
No files matched your search
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "photon-lemmy",
|
"name": "photon-lemmy",
|
||||||
"version": "0.9.10",
|
"version": "0.9.11",
|
||||||
"private": true,
|
"private": true,
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "vite dev",
|
"dev": "vite dev",
|
||||||
|
|||||||
@@ -7,6 +7,8 @@
|
|||||||
BookmarkSlash,
|
BookmarkSlash,
|
||||||
ChatBubbleOvalLeftEllipsis,
|
ChatBubbleOvalLeftEllipsis,
|
||||||
EllipsisHorizontal,
|
EllipsisHorizontal,
|
||||||
|
Eye,
|
||||||
|
EyeSlash,
|
||||||
Flag,
|
Flag,
|
||||||
Icon,
|
Icon,
|
||||||
Newspaper,
|
Newspaper,
|
||||||
@@ -31,7 +33,7 @@
|
|||||||
import ModerationMenu from '$lib/components/lemmy/moderation/ModerationMenu.svelte'
|
import ModerationMenu from '$lib/components/lemmy/moderation/ModerationMenu.svelte'
|
||||||
import { profile } from '$lib/auth.js'
|
import { profile } from '$lib/auth.js'
|
||||||
import Spinner from '$lib/components/ui/loader/Spinner.svelte'
|
import Spinner from '$lib/components/ui/loader/Spinner.svelte'
|
||||||
import { deleteItem, save } from '$lib/lemmy/contentview.js'
|
import { deleteItem, markAsRead, save } from '$lib/lemmy/contentview.js'
|
||||||
|
|
||||||
export let post: PostView
|
export let post: PostView
|
||||||
|
|
||||||
@@ -149,7 +151,15 @@
|
|||||||
<Icon src={PencilSquare} width={16} mini />
|
<Icon src={PencilSquare} width={16} mini />
|
||||||
Edit
|
Edit
|
||||||
</MenuButton>
|
</MenuButton>
|
||||||
{/if}
|
{/if}<MenuButton
|
||||||
|
on:click={async () => {
|
||||||
|
if ($profile?.jwt)
|
||||||
|
post.read = await markAsRead(post.post, !post.read, $profile.jwt)
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<Icon src={post.read ? EyeSlash : Eye} width={16} mini />
|
||||||
|
Mark as {post.read ? 'Unread' : 'Read'}
|
||||||
|
</MenuButton>
|
||||||
<MenuButton
|
<MenuButton
|
||||||
on:click={() =>
|
on:click={() =>
|
||||||
navigator.clipboard.writeText(
|
navigator.clipboard.writeText(
|
||||||
|
|||||||
@@ -140,3 +140,22 @@ export async function vote(
|
|||||||
}
|
}
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export async function markAsRead(
|
||||||
|
item: ContentView | Submission,
|
||||||
|
read: boolean,
|
||||||
|
jwt: string
|
||||||
|
): Promise<boolean> {
|
||||||
|
if (isSubmission(item)) item = contentItem(item)
|
||||||
|
|
||||||
|
if (item.type == 'post') {
|
||||||
|
return (
|
||||||
|
await getClient().markPostAsRead({
|
||||||
|
auth: jwt,
|
||||||
|
post_id: item.id,
|
||||||
|
read: read,
|
||||||
|
})
|
||||||
|
).post_view.read
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
Reference in new issue
Block a user