Skip to content

Commit

Permalink
fix: remove plain text endpoint call and decode on frontend
Browse files Browse the repository at this point in the history
Signed-off-by: Grigory Vodyanov <[email protected]>
  • Loading branch information
GVodyanov committed Dec 16, 2024
1 parent b106db5 commit ad1bc6f
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 25 deletions.
7 changes: 4 additions & 3 deletions src/components/ThreadEnvelope.vue
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,7 @@ import { mapStores } from 'pinia'
import moment from '@nextcloud/moment'
import { translateTagDisplayName } from '../util/tag.js'
import { FOLLOW_UP_TAG_LABEL } from '../store/constants.js'
import { getPlainText } from '../service/plainTextService.js'
import { Text, toPlain } from '../util/text.js'

// Ternary loading state
const LOADING_DONE = 0
Expand Down Expand Up @@ -881,8 +881,9 @@ export default {
},
async handleHtmlBodyMessages() {
if (this.message.hasHtmlBody) {
const message = await getPlainText(this.message.databaseId)
this.plainTextBody = message.body
let text = new Text('html', this.message.body)
text = toPlain(text)
this.plainTextBody = text.value
} else {
this.plainTextBody = this.message.body
}
Expand Down
4 changes: 3 additions & 1 deletion src/components/TranslationModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,14 @@
<NcRichText class="translate-dialog__message translate-dialog__message-source"
:text="message"
:arguments="richParameters"
:use-markdown="true"
:reference-limit="0" />

<NcRichText v-if="translatedMessage"
class="translate-dialog__message translate-dialog__message-translation"
:text="translatedMessage"
:arguments="richParameters"
:use-markdown="true"
:reference-limit="0" />
</template>

Expand Down Expand Up @@ -213,7 +215,7 @@ export default {
async translateMessage(sourceLanguage = null) {
try {
this.isLoading = true
const response = await translateText(this.message, sourceLanguage, this.selectedTo?.id)
const response = await translateText(this.message.trim(), sourceLanguage, this.selectedTo?.id)
this.translatedMessage = response.data.ocs.data.text
} catch (error) {
console.error(error)
Expand Down
20 changes: 0 additions & 20 deletions src/service/plainTextService.js

This file was deleted.

2 changes: 1 addition & 1 deletion src/util/text.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { convert } from 'html-to-text'
/**
* @type {Text}
*/
class Text {
export class Text {

constructor(format, value) {
this.format = format
Expand Down

0 comments on commit ad1bc6f

Please sign in to comment.