Correctly track user toggle of previews
This commit is contained in:
parent
769585e72d
commit
d2932ccea8
@ -231,19 +231,20 @@ export default {
|
|||||||
});
|
});
|
||||||
},
|
},
|
||||||
updateShownState() {
|
updateShownState() {
|
||||||
let defaultState = true;
|
// User has manually toggled the preview, do not apply default
|
||||||
|
if (this.link.shown !== null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
let defaultState = false;
|
||||||
|
|
||||||
switch (this.link.type) {
|
switch (this.link.type) {
|
||||||
case "error":
|
case "error":
|
||||||
// Collapse all errors by default unless its a message about image being too big
|
// Collapse all errors by default unless its a message about image being too big
|
||||||
defaultState =
|
if (this.link.error === "image-too-big") {
|
||||||
this.link.error === "image-too-big"
|
defaultState = this.$store.state.settings.media;
|
||||||
? this.$store.state.settings.media
|
}
|
||||||
: false;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case "loading":
|
|
||||||
defaultState = false;
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case "link":
|
case "link":
|
||||||
@ -254,7 +255,7 @@ export default {
|
|||||||
defaultState = this.$store.state.settings.media;
|
defaultState = this.$store.state.settings.media;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.link.shown = this.link.shown && defaultState;
|
this.link.shown = defaultState;
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
@ -45,7 +45,7 @@ module.exports = function(client, chan, msg) {
|
|||||||
thumb: "",
|
thumb: "",
|
||||||
size: -1,
|
size: -1,
|
||||||
link: link.link, // Send original matched link to the client
|
link: link.link, // Send original matched link to the client
|
||||||
shown: true,
|
shown: null,
|
||||||
};
|
};
|
||||||
|
|
||||||
cleanLinks.push(preview);
|
cleanLinks.push(preview);
|
||||||
@ -58,7 +58,6 @@ module.exports = function(client, chan, msg) {
|
|||||||
parse(msg, chan, preview, res, client);
|
parse(msg, chan, preview, res, client);
|
||||||
})
|
})
|
||||||
.catch((err) => {
|
.catch((err) => {
|
||||||
preview.shown = false;
|
|
||||||
preview.type = "error";
|
preview.type = "error";
|
||||||
preview.error = "message";
|
preview.error = "message";
|
||||||
preview.message = err.message;
|
preview.message = err.message;
|
||||||
|
@ -59,7 +59,7 @@ Vivamus bibendum vulputate tincidunt. Sed vitae ligula felis.`;
|
|||||||
thumb: "",
|
thumb: "",
|
||||||
size: -1,
|
size: -1,
|
||||||
type: "loading",
|
type: "loading",
|
||||||
shown: true,
|
shown: null,
|
||||||
},
|
},
|
||||||
]);
|
]);
|
||||||
|
|
||||||
@ -96,7 +96,7 @@ Vivamus bibendum vulputate tincidunt. Sed vitae ligula felis.`;
|
|||||||
thumb: "",
|
thumb: "",
|
||||||
size: -1,
|
size: -1,
|
||||||
type: "loading",
|
type: "loading",
|
||||||
shown: true,
|
shown: null,
|
||||||
},
|
},
|
||||||
]);
|
]);
|
||||||
|
|
||||||
@ -394,7 +394,7 @@ Vivamus bibendum vulputate tincidunt. Sed vitae ligula felis.`;
|
|||||||
thumb: "",
|
thumb: "",
|
||||||
size: -1,
|
size: -1,
|
||||||
type: "loading",
|
type: "loading",
|
||||||
shown: true,
|
shown: null,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
body: "",
|
body: "",
|
||||||
@ -403,7 +403,7 @@ Vivamus bibendum vulputate tincidunt. Sed vitae ligula felis.`;
|
|||||||
thumb: "",
|
thumb: "",
|
||||||
size: -1,
|
size: -1,
|
||||||
type: "loading",
|
type: "loading",
|
||||||
shown: true,
|
shown: null,
|
||||||
},
|
},
|
||||||
]);
|
]);
|
||||||
|
|
||||||
@ -570,7 +570,6 @@ Vivamus bibendum vulputate tincidunt. Sed vitae ligula felis.`;
|
|||||||
this.irc.once("msg:preview", function(data) {
|
this.irc.once("msg:preview", function(data) {
|
||||||
expect(data.preview.link).to.equal("http://localhost:" + port + "");
|
expect(data.preview.link).to.equal("http://localhost:" + port + "");
|
||||||
expect(data.preview.type).to.equal("error");
|
expect(data.preview.type).to.equal("error");
|
||||||
expect(data.preview.shown).to.equal(false);
|
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@ -598,14 +597,13 @@ Vivamus bibendum vulputate tincidunt. Sed vitae ligula felis.`;
|
|||||||
thumb: "",
|
thumb: "",
|
||||||
size: -1,
|
size: -1,
|
||||||
link: "http://localhost:" + port + "",
|
link: "http://localhost:" + port + "",
|
||||||
shown: true,
|
shown: null,
|
||||||
},
|
},
|
||||||
]);
|
]);
|
||||||
|
|
||||||
this.irc.once("msg:preview", function(data) {
|
this.irc.once("msg:preview", function(data) {
|
||||||
expect(data.preview.link).to.equal("http://localhost:" + port + "");
|
expect(data.preview.link).to.equal("http://localhost:" + port + "");
|
||||||
expect(data.preview.type).to.equal("error");
|
expect(data.preview.type).to.equal("error");
|
||||||
expect(data.preview.shown).to.equal(false);
|
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user