Normalizing: Natively use attachments.
This commit is contained in:
parent
bbb91d8ae3
commit
20ada31498
6 changed files with 7 additions and 23 deletions
|
@ -20,7 +20,7 @@ const Attachment = {
|
||||||
hideNsfwLocal: this.$store.getters.mergedConfig.hideNsfw,
|
hideNsfwLocal: this.$store.getters.mergedConfig.hideNsfw,
|
||||||
preloadImage: this.$store.getters.mergedConfig.preloadImage,
|
preloadImage: this.$store.getters.mergedConfig.preloadImage,
|
||||||
loading: false,
|
loading: false,
|
||||||
img: fileTypeService.fileType(this.attachment.mimetype) === 'image' && document.createElement('img'),
|
img: fileTypeService.fileType(this.attachment.pleroma.mime_type) === 'image' && document.createElement('img'),
|
||||||
modalOpen: false,
|
modalOpen: false,
|
||||||
showHidden: false
|
showHidden: false
|
||||||
}
|
}
|
||||||
|
@ -37,7 +37,7 @@ const Attachment = {
|
||||||
return this.$store.state.instance.mediaProxyAvailable ? '' : 'no-referrer'
|
return this.$store.state.instance.mediaProxyAvailable ? '' : 'no-referrer'
|
||||||
},
|
},
|
||||||
type () {
|
type () {
|
||||||
return fileTypeService.fileType(this.attachment.mimetype)
|
return fileTypeService.fileType(this.attachment.pleroma.mime_type)
|
||||||
},
|
},
|
||||||
hidden () {
|
hidden () {
|
||||||
return this.nsfw && this.hideNsfwLocal && !this.showHidden
|
return this.nsfw && this.hideNsfwLocal && !this.showHidden
|
||||||
|
|
|
@ -56,7 +56,7 @@
|
||||||
>
|
>
|
||||||
<StillImage
|
<StillImage
|
||||||
:referrerpolicy="referrerpolicy"
|
:referrerpolicy="referrerpolicy"
|
||||||
:mimetype="attachment.mimetype"
|
:mimetype="attachment.pleroma.mime_type"
|
||||||
:src="attachment.large_thumb_url || attachment.url"
|
:src="attachment.large_thumb_url || attachment.url"
|
||||||
:image-load-handler="onImageLoad"
|
:image-load-handler="onImageLoad"
|
||||||
/>
|
/>
|
||||||
|
|
|
@ -21,7 +21,7 @@ const mediaViewer = {
|
||||||
actions: {
|
actions: {
|
||||||
setMedia ({ commit }, attachments) {
|
setMedia ({ commit }, attachments) {
|
||||||
const media = attachments.filter(attachment => {
|
const media = attachments.filter(attachment => {
|
||||||
const type = fileTypeService.fileType(attachment.mimetype)
|
const type = fileTypeService.fileType(attachment.pleroma.mime_type)
|
||||||
return type === 'image' || type === 'video'
|
return type === 'image' || type === 'video'
|
||||||
})
|
})
|
||||||
commit('setMedia', media)
|
commit('setMedia', media)
|
||||||
|
|
|
@ -192,23 +192,7 @@ export const parseUser = (data) => {
|
||||||
}
|
}
|
||||||
|
|
||||||
export const parseAttachment = (data) => {
|
export const parseAttachment = (data) => {
|
||||||
const output = {}
|
return data
|
||||||
const masto = !data.hasOwnProperty('oembed')
|
|
||||||
|
|
||||||
if (masto) {
|
|
||||||
// Not exactly same...
|
|
||||||
output.mimetype = data.pleroma ? data.pleroma.mime_type : data.type
|
|
||||||
output.meta = data.meta // not present in BE yet
|
|
||||||
output.id = data.id
|
|
||||||
} else {
|
|
||||||
output.mimetype = data.mimetype
|
|
||||||
// output.meta = ??? missing
|
|
||||||
}
|
|
||||||
|
|
||||||
output.url = data.url
|
|
||||||
output.description = data.description
|
|
||||||
|
|
||||||
return output
|
|
||||||
}
|
}
|
||||||
export const addEmojis = (string, emojis) => {
|
export const addEmojis = (string, emojis) => {
|
||||||
const matchOperatorsRegex = /[|\\{}()[\]^$+*?.-]/g
|
const matchOperatorsRegex = /[|\\{}()[\]^$+*?.-]/g
|
||||||
|
|
|
@ -22,7 +22,7 @@ const fileType = mimetype => {
|
||||||
}
|
}
|
||||||
|
|
||||||
const fileMatchesSomeType = (types, file) =>
|
const fileMatchesSomeType = (types, file) =>
|
||||||
types.some(type => fileType(file.mimetype) === type)
|
types.some(type => fileType(file.pleroma.mime_type) === type)
|
||||||
|
|
||||||
const fileTypeService = {
|
const fileTypeService = {
|
||||||
fileType,
|
fileType,
|
||||||
|
|
|
@ -81,7 +81,7 @@ export const prepareNotificationObject = (notification, i18n) => {
|
||||||
|
|
||||||
// Shows first attached non-nsfw image, if any. Should add configuration for this somehow...
|
// Shows first attached non-nsfw image, if any. Should add configuration for this somehow...
|
||||||
if (status && status.attachments && status.attachments.length > 0 && !status.nsfw &&
|
if (status && status.attachments && status.attachments.length > 0 && !status.nsfw &&
|
||||||
status.attachments[0].mimetype.startsWith('image/')) {
|
status.attachments[0].pleroma.mime_type.startsWith('image/')) {
|
||||||
notifObj.image = status.attachments[0].url
|
notifObj.image = status.attachments[0].url
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue