Merge pull request #4020 from thelounge/xpaw/obj

Use lodash where possible
This commit is contained in:
Pavel Djundik 2020-08-10 15:57:12 +03:00 committed by GitHub
commit b6782da837
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 16 additions and 16 deletions

View File

@ -82,7 +82,7 @@ function loadFromLocalStorage() {
} }
// Older The Lounge versions converted highlights to an array, turn it back into a string // Older The Lounge versions converted highlights to an array, turn it back into a string
if (typeof storedSettings.highlights === "object") { if (storedSettings.highlights !== null && typeof storedSettings.highlights === "object") {
storedSettings.highlights = storedSettings.highlights.join(", "); storedSettings.highlights = storedSettings.highlights.join(", ");
} }

View File

@ -83,15 +83,15 @@ function Client(manager, name, config = {}) {
} }
} }
if (typeof client.config.sessions !== "object") { if (!_.isPlainObject(client.config.sessions)) {
client.config.sessions = {}; client.config.sessions = {};
} }
if (typeof client.config.clientSettings !== "object") { if (!_.isPlainObject(client.config.clientSettings)) {
client.config.clientSettings = {}; client.config.clientSettings = {};
} }
if (typeof client.config.browser !== "object") { if (!_.isPlainObject(client.config.browser)) {
client.config.browser = {}; client.config.browser = {};
} }

View File

@ -363,13 +363,13 @@ function initializeClient(socket, client, token, lastMessage, openChannel) {
}); });
socket.on("input", (data) => { socket.on("input", (data) => {
if (typeof data === "object") { if (_.isPlainObject(data)) {
client.input(data); client.input(data);
} }
}); });
socket.on("more", (data) => { socket.on("more", (data) => {
if (typeof data === "object") { if (_.isPlainObject(data)) {
const history = client.more(data); const history = client.more(data);
if (history !== null) { if (history !== null) {
@ -379,7 +379,7 @@ function initializeClient(socket, client, token, lastMessage, openChannel) {
}); });
socket.on("network:new", (data) => { socket.on("network:new", (data) => {
if (typeof data === "object") { if (_.isPlainObject(data)) {
// prevent people from overriding webirc settings // prevent people from overriding webirc settings
data.uuid = null; data.uuid = null;
data.commands = null; data.commands = null;
@ -404,7 +404,7 @@ function initializeClient(socket, client, token, lastMessage, openChannel) {
}); });
socket.on("network:edit", (data) => { socket.on("network:edit", (data) => {
if (typeof data !== "object") { if (!_.isPlainObject(data)) {
return; return;
} }
@ -418,14 +418,14 @@ function initializeClient(socket, client, token, lastMessage, openChannel) {
}); });
socket.on("history:clear", (data) => { socket.on("history:clear", (data) => {
if (typeof data === "object") { if (_.isPlainObject(data)) {
client.clearHistory(data); client.clearHistory(data);
} }
}); });
if (!Helper.config.public && !Helper.config.ldap.enable) { if (!Helper.config.public && !Helper.config.ldap.enable) {
socket.on("change-password", (data) => { socket.on("change-password", (data) => {
if (typeof data === "object") { if (_.isPlainObject(data)) {
const old = data.old_password; const old = data.old_password;
const p1 = data.new_password; const p1 = data.new_password;
const p2 = data.verify_password; const p2 = data.verify_password;
@ -475,13 +475,13 @@ function initializeClient(socket, client, token, lastMessage, openChannel) {
}); });
socket.on("sort", (data) => { socket.on("sort", (data) => {
if (typeof data === "object") { if (_.isPlainObject(data)) {
client.sort(data); client.sort(data);
} }
}); });
socket.on("names", (data) => { socket.on("names", (data) => {
if (typeof data === "object") { if (_.isPlainObject(data)) {
client.names(data); client.names(data);
} }
}); });
@ -496,7 +496,7 @@ function initializeClient(socket, client, token, lastMessage, openChannel) {
}); });
socket.on("msg:preview:toggle", (data) => { socket.on("msg:preview:toggle", (data) => {
if (typeof data !== "object") { if (!_.isPlainObject(data)) {
return; return;
} }
@ -597,7 +597,7 @@ function initializeClient(socket, client, token, lastMessage, openChannel) {
if (!Helper.config.public) { if (!Helper.config.public) {
socket.on("setting:set", (newSetting) => { socket.on("setting:set", (newSetting) => {
if (!newSetting || typeof newSetting !== "object") { if (!_.isPlainObject(newSetting)) {
return; return;
} }
@ -646,7 +646,7 @@ function initializeClient(socket, client, token, lastMessage, openChannel) {
socket.on("sign-out", (tokenToSignOut) => { socket.on("sign-out", (tokenToSignOut) => {
// If no token provided, sign same client out // If no token provided, sign same client out
if (!tokenToSignOut) { if (!tokenToSignOut || typeof tokenToSignOut !== "string") {
tokenToSignOut = token; tokenToSignOut = token;
} }
@ -752,7 +752,7 @@ function getServerConfiguration() {
} }
function performAuthentication(data) { function performAuthentication(data) {
if (typeof data !== "object") { if (!_.isPlainObject(data)) {
return; return;
} }