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

View File

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

View File

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