improve unknown attachment handling

This commit is contained in:
Henry Jameson 2022-02-10 15:42:28 +02:00
parent d1f02221cb
commit befd4d5fc7
3 changed files with 28 additions and 6 deletions

View file

@ -79,7 +79,7 @@ const Attachment = {
] ]
}, },
usePlaceholder () { usePlaceholder () {
return this.size === 'hide' || this.type === 'unknown' return this.size === 'hide'
}, },
useContainFit () { useContainFit () {
return this.$store.getters.mergedConfig.useContainFit return this.$store.getters.mergedConfig.useContainFit
@ -106,7 +106,7 @@ const Attachment = {
return this.nsfw && this.hideNsfwLocal && !this.showHidden return this.nsfw && this.hideNsfwLocal && !this.showHidden
}, },
isEmpty () { isEmpty () {
return (this.type === 'html' && !this.attachment.oembed) || this.type === 'unknown' return (this.type === 'html' && !this.attachment.oembed)
}, },
useModal () { useModal () {
let modalTypes = [] let modalTypes = []
@ -143,6 +143,8 @@ const Attachment = {
if (this.useModal) { if (this.useModal) {
this.$emit('setMedia') this.$emit('setMedia')
this.$store.dispatch('setCurrentMedia', this.attachment) this.$store.dispatch('setCurrentMedia', this.attachment)
} else if (this.type === 'unknown') {
window.open(this.attachment.url)
} }
}, },
openModalForce (event) { openModalForce (event) {
@ -150,7 +152,6 @@ const Attachment = {
this.$store.dispatch('setCurrentMedia', this.attachment) this.$store.dispatch('setCurrentMedia', this.attachment)
}, },
onEdit (event) { onEdit (event) {
console.log('ONEDIT', event)
this.edit && this.edit(this.attachment, event) this.edit && this.edit(this.attachment, event)
}, },
onRemove () { onRemove () {

View file

@ -54,6 +54,7 @@
min-width: 0; min-width: 0;
} }
& .placeholder-container,
& .image-container, & .image-container,
& .audio-container, & .audio-container,
& .video-container, & .video-container,
@ -93,6 +94,15 @@
} }
} }
.placeholder-container {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
padding-top: 0.5em;
}
.play-icon { .play-icon {
position: absolute; position: absolute;
font-size: 64px; font-size: 64px;

View file

@ -12,7 +12,6 @@
:href="attachment.url" :href="attachment.url"
:alt="attachment.description" :alt="attachment.description"
:title="attachment.description" :title="attachment.description"
@click.prevent=""
> >
<FAIcon :icon="placeholderIconClass" /> <FAIcon :icon="placeholderIconClass" />
<b>{{ nsfw ? "NSFW / " : "" }}</b>{{ edit ? '' : placeholderName }} <b>{{ nsfw ? "NSFW / " : "" }}</b>{{ edit ? '' : placeholderName }}
@ -88,7 +87,7 @@
<FAIcon icon="stop" /> <FAIcon icon="stop" />
</button> </button>
<button <button
v-if="attachment.description && size !== 'small' && !edit" v-if="attachment.description && size !== 'small' && !edit && type !== 'unknown'"
class="button-unstyled attachment-button" class="button-unstyled attachment-button"
@click.prevent="toggleDescription" @click.prevent="toggleDescription"
:title="$t('status.show_attachment_description')" :title="$t('status.show_attachment_description')"
@ -96,7 +95,7 @@
<FAIcon icon="align-right" /> <FAIcon icon="align-right" />
</button> </button>
<button <button
v-if="!useModal" v-if="!useModal && type !== 'unknown'"
class="button-unstyled attachment-button" class="button-unstyled attachment-button"
@click.prevent="openModalForce" @click.prevent="openModalForce"
:title="$t('status.show_attachment_in_modal')" :title="$t('status.show_attachment_in_modal')"
@ -155,6 +154,18 @@
/> />
</a> </a>
<a
v-if="type === 'unknown' && !hidden"
class="placeholder-container"
:href="attachment.url"
target="_blank"
>
<FAIcon size="5x" :icon="placeholderIconClass" />
<p>
{{ localDescription }}
</p>
</a>
<component <component
:is="videoTag" :is="videoTag"
v-if="type === 'video' && !hidden" v-if="type === 'video' && !hidden"