Preserve visibility settings when replying to post

This commit is contained in:
silverpill 2022-01-09 12:09:52 +00:00
parent f9f2e40ad0
commit 89cdcba68b
2 changed files with 10 additions and 4 deletions

View file

@ -166,7 +166,7 @@
</div> </div>
<post-editor <post-editor
v-if="commentFormVisible" v-if="commentFormVisible"
:in-reply-to="post.id" :in-reply-to="post"
@post-created="onCommentCreated" @post-created="onCommentCreated"
> >
</post-editor> </post-editor>

View file

@ -88,7 +88,7 @@
import { Options, Vue, setup } from "vue-class-component" import { Options, Vue, setup } from "vue-class-component"
import { Prop } from "vue-property-decorator" import { Prop } from "vue-property-decorator"
import { createPost, Attachment, uploadAttachment } from "@/api/posts" import { Post, createPost, Attachment, uploadAttachment } from "@/api/posts"
import { User } from "@/api/users" import { User } from "@/api/users"
import Avatar from "@/components/Avatar.vue" import Avatar from "@/components/Avatar.vue"
import VisibilityIcon from "@/components/VisibilityIcon.vue" import VisibilityIcon from "@/components/VisibilityIcon.vue"
@ -108,7 +108,7 @@ const POST_CHARACTER_LIMIT = 1000
export default class PostEditor extends Vue { export default class PostEditor extends Vue {
@Prop() @Prop()
inReplyTo: string | null = null inReplyTo: Post | null = null
content = "" content = ""
visibility = "public" visibility = "public"
@ -131,6 +131,12 @@ export default class PostEditor extends Vue {
return this.store.currentUser return this.store.currentUser
} }
created() {
if (this.inReplyTo) {
this.visibility = this.inReplyTo.visibility
}
}
mounted() { mounted() {
setupAutoResize(this.$refs.postFormContent) setupAutoResize(this.$refs.postFormContent)
} }
@ -164,7 +170,7 @@ export default class PostEditor extends Vue {
const content = renderMarkdownLite(this.content) const content = renderMarkdownLite(this.content)
const postData = { const postData = {
content, content,
in_reply_to_id: this.inReplyTo, in_reply_to_id: this.inReplyTo ? this.inReplyTo.id : null,
visibility: this.visibility, visibility: this.visibility,
} }
let post let post