From 15a233ab2da41b9a22b79ad93403f121940448fe Mon Sep 17 00:00:00 2001 From: silverpill Date: Sun, 16 Apr 2023 21:38:47 +0000 Subject: [PATCH] Add content warnings --- CHANGELOG.md | 1 + src/api/posts.ts | 8 +++-- src/assets/tabler/alert-triangle.svg | 2 ++ src/components/Post.vue | 2 ++ src/components/PostAttachment.vue | 53 +++++++++++++++++++++++++--- src/components/PostEditor.vue | 14 +++++++- 6 files changed, 72 insertions(+), 8 deletions(-) create mode 100644 src/assets/tabler/alert-triangle.svg diff --git a/CHANGELOG.md b/CHANGELOG.md index 29e24a5..edaf3c3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). - Detect preferred color scheme. - Show loading indicator while attachment is being uploaded. +- Content warnings. ### Fixed diff --git a/src/api/posts.ts b/src/api/posts.ts index 34aa8f7..011f29a 100644 --- a/src/api/posts.ts +++ b/src/api/posts.ts @@ -60,6 +60,7 @@ export interface Post { in_reply_to_id: string | null; reblog: Post | null; visibility: Visibility; + sensitive: boolean; replies_count: number; favourites_count: number; reblogs_count: number; @@ -176,6 +177,7 @@ export async function previewPost( in_reply_to_id: null, reblog: null, visibility: Visibility.Public, + sensitive: false, replies_count: 0, favourites_count: 0, reblogs_count: 0, @@ -194,8 +196,9 @@ export async function previewPost( export interface PostData { content: string; - in_reply_to_id: string | null; + inReplyToId: string | null; visibility: string; + isSensitive: boolean; mentions: string[]; attachments: Attachment[]; } @@ -210,8 +213,9 @@ export async function createPost( status: postData.content, content_type: "text/markdown", "media_ids[]": postData.attachments.map((attachment) => attachment.id), - in_reply_to_id: postData.in_reply_to_id, + in_reply_to_id: postData.inReplyToId, visibility: postData.visibility, + sensitive: postData.isSensitive, mentions: postData.mentions, } const response = await http(url, { diff --git a/src/assets/tabler/alert-triangle.svg b/src/assets/tabler/alert-triangle.svg new file mode 100644 index 0000000..1d745b4 --- /dev/null +++ b/src/assets/tabler/alert-triangle.svg @@ -0,0 +1,2 @@ + + diff --git a/src/components/Post.vue b/src/components/Post.vue index 0e7d799..a002162 100644 --- a/src/components/Post.vue +++ b/src/components/Post.vue @@ -68,6 +68,7 @@ @@ -91,6 +92,7 @@ diff --git a/src/components/PostAttachment.vue b/src/components/PostAttachment.vue index fe93871..161f9d6 100644 --- a/src/components/PostAttachment.vue +++ b/src/components/PostAttachment.vue @@ -1,5 +1,15 @@