Fix link expand buttons not showing if auto-expand option is off

This commit is contained in:
Pavel Djundik 2018-09-24 13:39:02 +03:00
parent 7d7005c8af
commit 05303e4cf1
3 changed files with 5 additions and 8 deletions

View File

@ -141,6 +141,10 @@ export default {
this.onPreviewUpdate(); this.onPreviewUpdate();
}, },
}, },
created() {
const shouldOpenByDefault = this.link.type === "link" ? this.$root.settings.links : this.$root.settings.media;
this.link.shown = this.link.shown && shouldOpenByDefault;
},
mounted() { mounted() {
// Don't display previews while they are loading on the server // Don't display previews while they are loading on the server
if (this.link.type === "loading") { if (this.link.type === "loading") {
@ -172,8 +176,7 @@ export default {
} }
}, },
onPreviewReady() { onPreviewReady() {
const options = require("../js/options"); this.$set(this.link, "canDisplay", true);
this.$set(this.link, "canDisplay", options.shouldOpenMessagePreview(this.link.type));
this.keepScrollPosition(); this.keepScrollPosition();

View File

@ -1,6 +1,5 @@
<template> <template>
<button <button
v-if="link.canDisplay"
:class="['toggle-button', 'toggle-preview', { opened: link.shown }]" :class="['toggle-button', 'toggle-preview', { opened: link.shown }]"
@click="onClick" /> @click="onClick" />
</template> </template>

View File

@ -64,16 +64,11 @@ module.exports = {
initialized: false, initialized: false,
highlightsRE: null, highlightsRE: null,
settings, settings,
shouldOpenMessagePreview,
syncAllSettings, syncAllSettings,
processSetting, processSetting,
initialize, initialize,
}; };
function shouldOpenMessagePreview(type) {
return type === "link" ? settings.links : settings.media;
}
// Updates the checkbox and warning in settings. // Updates the checkbox and warning in settings.
// When notifications are not supported, this is never called (because // When notifications are not supported, this is never called (because
// checkbox state can not be changed). // checkbox state can not be changed).