use akkoma-specific source for MFM unless asked not to #132

Merged
floatingghost merged 4 commits from use-akkoma-source-for-mfm into develop 2022-08-17 09:34:50 +00:00
5 changed files with 22 additions and 3 deletions

View file

@ -124,6 +124,11 @@ const setSettings = async ({ apiConfig, staticConfig, store }) => {
copyInstanceOption('hideBotIndication') copyInstanceOption('hideBotIndication')
copyInstanceOption('hideUserStats') copyInstanceOption('hideUserStats')
copyInstanceOption('hideFilteredStatuses') copyInstanceOption('hideFilteredStatuses')
copyInstanceOption('hideSiteName')
copyInstanceOption('hideSiteFavicon')
copyInstanceOption('showWiderShortcuts')
copyInstanceOption('showNavShortcuts')
copyInstanceOption('showPanelNavShortcuts')
copyInstanceOption('logo') copyInstanceOption('logo')
store.dispatch('setInstanceOption', { store.dispatch('setInstanceOption', {
@ -154,6 +159,7 @@ const setSettings = async ({ apiConfig, staticConfig, store }) => {
copyInstanceOption('alwaysShowSubjectInput') copyInstanceOption('alwaysShowSubjectInput')
copyInstanceOption('showFeaturesPanel') copyInstanceOption('showFeaturesPanel')
copyInstanceOption('hideSitename') copyInstanceOption('hideSitename')
copyInstanceOption('renderMisskeyMarkdown')
copyInstanceOption('sidebarRight') copyInstanceOption('sidebarRight')
return store.dispatch('setTheme', config['theme']) return store.dispatch('setTheme', config['theme'])

View file

@ -10,6 +10,11 @@ import HashtagLink from 'src/components/hashtag_link/hashtag_link.vue'
import './rich_content.scss' import './rich_content.scss'
const selectContent = (html, sourceContent, mfm) => {
if (!mfm) return html
return sourceContent === '' ? html : sourceContent
}
/** /**
* RichContent, The Über-powered component for rendering Post HTML. * RichContent, The Über-powered component for rendering Post HTML.
* *
@ -66,6 +71,11 @@ export default {
required: false, required: false,
type: Boolean, type: Boolean,
default: false default: false
},
sourceContent: {
required: false,
type: String,
default: ''
} }
}, },
// NEVER EVER TOUCH DATA INSIDE RENDER // NEVER EVER TOUCH DATA INSIDE RENDER
@ -74,7 +84,8 @@ export default {
const greentext = this.mfm ? false : this.greentext const greentext = this.mfm ? false : this.greentext
// Pre-process HTML // Pre-process HTML
const { newHtml: html } = preProcessPerLine(this.html, greentext) const useContent = selectContent(this.html, this.sourceContent, this.mfm)
const { newHtml: html } = preProcessPerLine(useContent, greentext)
let currentMentions = null // Current chain of mentions, we group all mentions together let currentMentions = null // Current chain of mentions, we group all mentions together
// This is used to recover spacing removed when parsing mentions // This is used to recover spacing removed when parsing mentions
let lastSpacing = '' let lastSpacing = ''
@ -169,7 +180,7 @@ export default {
} }
// Processor to use with html_tree_converter // Processor to use with html_tree_converter
const processItem = (item, index, array, what) => { const processItem = (item, index, array) => {
// Handle text nodes - just add emoji // Handle text nodes - just add emoji
if (typeof item === 'string') { if (typeof item === 'string') {
const emptyText = item.trim() === '' const emptyText = item.trim() === ''

View file

@ -52,6 +52,7 @@
:emoji="status.emojis" :emoji="status.emojis"
:handle-links="true" :handle-links="true"
:mfm="renderMisskeyMarkdown && (status.media_type === 'text/x.misskeymarkdown')" :mfm="renderMisskeyMarkdown && (status.media_type === 'text/x.misskeymarkdown')"
:sourceContent="status.source_content"
:greentext="mergedConfig.greentext" :greentext="mergedConfig.greentext"
:attentions="status.attentions" :attentions="status.attentions"
@parseReady="onParseReady" @parseReady="onParseReady"

View file

@ -589,7 +589,7 @@ const users = {
const response = data.error const response = data.error
// Authentication failed // Authentication failed
commit('endLogin') commit('endLogin')
if (response.status === 401) { if (response.status === 401 || response.status === 403) {
reject(new Error('Wrong username or password')) reject(new Error('Wrong username or password'))
} else { } else {
reject(new Error('An error occurred, please try again')) reject(new Error('An error occurred, please try again'))

View file

@ -282,6 +282,7 @@ export const parseStatus = (data) => {
const { akkoma } = data const { akkoma } = data
if (akkoma && akkoma.source) { if (akkoma && akkoma.source) {
output.media_type = akkoma.source.mediaType output.media_type = akkoma.source.mediaType
output.source_content = akkoma.source.content
} }
} }