diff --git a/package.json b/package.json
index 103aa55a..309a59a6 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "photon-lemmy",
- "version": "0.9.10",
+ "version": "0.9.11",
"private": true,
"scripts": {
"dev": "vite dev",
diff --git a/src/lib/components/lemmy/post/PostActions.svelte b/src/lib/components/lemmy/post/PostActions.svelte
index 30735d8f..e77cdb6d 100644
--- a/src/lib/components/lemmy/post/PostActions.svelte
+++ b/src/lib/components/lemmy/post/PostActions.svelte
@@ -7,6 +7,8 @@
BookmarkSlash,
ChatBubbleOvalLeftEllipsis,
EllipsisHorizontal,
+ Eye,
+ EyeSlash,
Flag,
Icon,
Newspaper,
@@ -31,7 +33,7 @@
import ModerationMenu from '$lib/components/lemmy/moderation/ModerationMenu.svelte'
import { profile } from '$lib/auth.js'
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
@@ -149,7 +151,15 @@
Edit
- {/if}
+ {/if} {
+ if ($profile?.jwt)
+ post.read = await markAsRead(post.post, !post.read, $profile.jwt)
+ }}
+ >
+
+ Mark as {post.read ? 'Unread' : 'Read'}
+
navigator.clipboard.writeText(
diff --git a/src/lib/lemmy/contentview.ts b/src/lib/lemmy/contentview.ts
index 447b67ab..2090983d 100644
--- a/src/lib/lemmy/contentview.ts
+++ b/src/lib/lemmy/contentview.ts
@@ -140,3 +140,22 @@ export async function vote(
}
return 0
}
+
+export async function markAsRead(
+ item: ContentView | Submission,
+ read: boolean,
+ jwt: string
+): Promise {
+ 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
+}