From f3b383ce633d991c319ebb7f9ca64549715fc27b Mon Sep 17 00:00:00 2001 From: Pavel Djundik Date: Tue, 17 Dec 2019 12:48:12 +0200 Subject: [PATCH] Use Set() for condensed types --- client/components/MessageList.vue | 4 ++-- client/js/constants.js | 4 +--- test/client/js/constantsTest.js | 2 +- 3 files changed, 4 insertions(+), 6 deletions(-) diff --git a/client/components/MessageList.vue b/client/components/MessageList.vue index 7f3db237..9c8fec3e 100644 --- a/client/components/MessageList.vue +++ b/client/components/MessageList.vue @@ -83,7 +83,7 @@ export default { // If actions are hidden, just return a message list with them excluded if (this.$store.state.settings.statusMessages === "hidden") { return this.channel.messages.filter( - (message) => !constants.condensedTypes.includes(message.type) + (message) => !constants.condensedTypes.has(message.type) ); } @@ -101,7 +101,7 @@ export default { if ( message.self || message.highlight || - !constants.condensedTypes.includes(message.type) + !constants.condensedTypes.has(message.type) ) { lastCondensedContainer = null; diff --git a/client/js/constants.js b/client/js/constants.js index 4ff328ec..f5508dfe 100644 --- a/client/js/constants.js +++ b/client/js/constants.js @@ -19,8 +19,7 @@ const colorCodeMap = [ ["15", "Light Grey"], ]; -const condensedTypes = ["chghost", "join", "part", "quit", "nick", "kick", "mode"]; -const condensedTypesQuery = "." + condensedTypes.join(", ."); +const condensedTypes = new Set(["chghost", "join", "part", "quit", "nick", "kick", "mode"]); const timeFormats = { msgDefault: "HH:mm", @@ -33,7 +32,6 @@ export default { colorCodeMap, commands: [], condensedTypes, - condensedTypesQuery, timeFormats, sizeUnits, // Same value as media query in CSS that forces sidebars to become overlays diff --git a/test/client/js/constantsTest.js b/test/client/js/constantsTest.js index dd1f01ce..05e8713a 100644 --- a/test/client/js/constantsTest.js +++ b/test/client/js/constantsTest.js @@ -23,7 +23,7 @@ describe("client-side constants", function() { describe(".condensedTypes", function() { it("should be a non-empty array", function() { - expect(constants.condensedTypes).to.be.an("array").that.is.not.empty; + expect(constants.condensedTypes).to.be.an.instanceof(Set).that.is.not.empty; }); it("should only contain ASCII strings", function() {