diff --git a/client/components/LinkPreview.vue b/client/components/LinkPreview.vue index 41692ae9..6680c2f1 100644 --- a/client/components/LinkPreview.vue +++ b/client/components/LinkPreview.vue @@ -235,10 +235,11 @@ export default { switch (this.link.type) { case "error": + // Collapse all errors by default unless its a message about image being too big defaultState = this.link.error === "image-too-big" ? this.$store.state.settings.media - : this.$store.state.settings.links; + : false; break; case "loading": diff --git a/src/plugins/irc-events/link.js b/src/plugins/irc-events/link.js index 9c782e7e..ee2c4096 100644 --- a/src/plugins/irc-events/link.js +++ b/src/plugins/irc-events/link.js @@ -58,6 +58,7 @@ module.exports = function(client, chan, msg) { parse(msg, chan, preview, res, client); }) .catch((err) => { + preview.shown = false; preview.type = "error"; preview.error = "message"; preview.message = err.message; diff --git a/test/plugins/link.js b/test/plugins/link.js index 8d49ddcd..a46b7290 100644 --- a/test/plugins/link.js +++ b/test/plugins/link.js @@ -569,6 +569,8 @@ Vivamus bibendum vulputate tincidunt. Sed vitae ligula felis.`; this.irc.once("msg:preview", function(data) { expect(data.preview.link).to.equal("http://localhost:" + port + ""); + expect(data.preview.type).to.equal("error"); + expect(data.preview.shown).to.equal(false); done(); }); }); @@ -602,6 +604,8 @@ Vivamus bibendum vulputate tincidunt. Sed vitae ligula felis.`; this.irc.once("msg:preview", function(data) { expect(data.preview.link).to.equal("http://localhost:" + port + ""); + expect(data.preview.type).to.equal("error"); + expect(data.preview.shown).to.equal(false); done(); }); });