wf_akkoma-fe/patches/pr416_05_post-form-default-to-parent-lang.patch

120 lines
4.9 KiB
Diff
Raw Normal View History

2024-10-03 17:09:28 +00:00
From 8f06566ddd504a9c5d712e64b945ddb74090d1eb Mon Sep 17 00:00:00 2001
From: novenary <novenary@kwak.zip>
Date: Tue, 17 Sep 2024 12:27:56 +0300
Subject: [PATCH] post_status_form: inherit language from parent
If I'm replying to a post in Klingon, chances are I'm going to write in
Klingon. This reduces friction for properly marking post language in a
conversation.
---
.../post_status_form/post_status_form.js | 20 +++++++++++++------
src/components/status/status.vue | 2 ++
.../entity_normalizer.service.js | 1 +
3 files changed, 17 insertions(+), 6 deletions(-)
diff --git a/src/components/post_status_form/post_status_form.js b/src/components/post_status_form/post_status_form.js
index ac3e7b23..cad8d3c2 100644
--- a/src/components/post_status_form/post_status_form.js
+++ b/src/components/post_status_form/post_status_form.js
@@ -85,6 +85,7 @@ const PostStatusForm = {
'quoteId',
'repliedUser',
'attentions',
+ 'copyMessageLanguage',
'copyMessageScope',
'subject',
'disableSubject',
@@ -153,8 +154,7 @@ const PostStatusForm = {
statusText = buildMentionsString({ user: this.repliedUser, attentions: this.attentions }, currentUser)
}
- const { postContentType: contentType, postLanguage: defaultPostLanguage, sensitiveByDefault, sensitiveIfSubject, interfaceLanguage, alwaysShowSubjectInput } = this.$store.getters.mergedConfig
- const postLanguage = defaultPostLanguage || interfaceToISOLanguage(interfaceLanguage)
+ const { postContentType: contentType, sensitiveByDefault, sensitiveIfSubject, alwaysShowSubjectInput } = this.$store.getters.mergedConfig
let statusParams = {
spoilerText: this.subject || '',
@@ -165,7 +165,7 @@ const PostStatusForm = {
poll: {},
mediaDescriptions: {},
visibility: this.suggestedVisibility(),
- language: postLanguage,
+ language: this.suggestedLanguage(),
contentType
}
@@ -180,7 +180,7 @@ const PostStatusForm = {
poll: this.statusPoll || {},
mediaDescriptions: this.statusMediaDescriptions || {},
visibility: this.statusScope || this.suggestedVisibility(),
- language: this.statusLanguage || postLanguage,
+ language: this.statusLanguage || this.suggestedLanguage(),
contentType: statusContentType
}
}
@@ -342,7 +342,6 @@ const PostStatusForm = {
},
clearStatus () {
const config = this.$store.getters.mergedConfig
- const postLanguage = config.postLanguage || interfaceToISOLanguage(config.interfaceLanguage)
this.newStatus = {
status: '',
spoilerText: '',
@@ -350,7 +349,7 @@ const PostStatusForm = {
nsfw: !!config.sensitiveByDefault,
visibility: this.suggestedVisibility(),
contentType: config.postContentType,
- language: postLanguage,
+ language: this.suggestedLanguage(),
poll: {},
mediaDescriptions: {}
}
@@ -766,6 +765,15 @@ const PostStatusForm = {
openProfileTab () {
this.$store.dispatch('openSettingsModalTab', 'profile')
},
+ suggestedLanguage () {
+ // Make sure the inherited language is actually valid
+ if (this.postLanguageOptions.find(o => o.value === this.copyMessageLanguage)) {
+ return this.copyMessageLanguage
+ }
+ const { postLanguage: defaultPostLanguage, interfaceLanguage } = this.$store.getters.mergedConfig
+ const postLanguage = defaultPostLanguage || interfaceToISOLanguage(interfaceLanguage)
+ return postLanguage
+ },
suggestedVisibility () {
if (this.copyMessageScope) {
if (this.copyMessageScope === 'direct') {
diff --git a/src/components/status/status.vue b/src/components/status/status.vue
index f51462bb..dc6491cc 100644
--- a/src/components/status/status.vue
+++ b/src/components/status/status.vue
@@ -519,6 +519,7 @@
:reply-to="status.id"
:attentions="status.attentions"
:replied-user="status.user"
+ :copy-message-language="status.language"
:copy-message-scope="status.visibility"
:subject="replySubject"
@posted="toggleReplying"
@@ -533,6 +534,7 @@
:quote-id="status.id"
:attentions="[status.user]"
:replied-user="status.user"
+ :copy-message-language="status.language"
:copy-message-scope="status.visibility"
:subject="replySubject"
@posted="toggleQuoting"
diff --git a/src/services/entity_normalizer/entity_normalizer.service.js b/src/services/entity_normalizer/entity_normalizer.service.js
index b7f382d8..7bf8c33d 100644
--- a/src/services/entity_normalizer/entity_normalizer.service.js
+++ b/src/services/entity_normalizer/entity_normalizer.service.js
@@ -326,6 +326,7 @@ export const parseStatus = (data) => {
}
output.pinned = data.pinned
output.muted = data.muted
+ output.language = data.language
} else {
output.favorited = data.favorited
output.fave_num = data.fave_num