From 13b3b1049b2fb16f07cc9e293ab5d916ce3cc53d Mon Sep 17 00:00:00 2001 From: TheGoddessInari Date: Sat, 21 Jul 2018 23:14:53 -0700 Subject: [PATCH] Please don't abuse ternary operator for operations without a value. It makes the linters angry. --- app.js | 14 +++++++++++--- app/Application.js | 6 +++++- app/store/Services.js | 6 +++++- app/ux/WebView.js | 8 +++++++- app/view/add/Add.js | 18 +++++++++++++++--- 5 files changed, 43 insertions(+), 9 deletions(-) diff --git a/app.js b/app.js index 920844bd..7dea5c7f 100644 --- a/app.js +++ b/app.js @@ -19,10 +19,14 @@ const ipc = require('electron').ipcRenderer; require('electron-context-menu')(); ipc.on('showAbout', function(event, message) { - !Ext.cq1('about') ? Ext.create('Rambox.view.main.About') : ''; + if(!Ext.cq1('about')) { + Ext.create('Rambox.view.main.About'); + } }); ipc.on('showPreferences', function(event, message) { - !Ext.cq1('preferences') ? Ext.create('Rambox.view.preferences.Preferences').show() : ''; + if (!Ext.cq1('preferences')) { + Ext.create('Rambox.view.preferences.Preferences').show(); + } }); ipc.on('autoUpdater:check-update', function() { Rambox.app.checkUpdate(); @@ -135,7 +139,11 @@ ipc.on('toggleStatusBar', function() { var tab = Ext.cq1('app-main').getActiveTab(); if ( tab.id !== 'ramboxTab' ) { - tab.down('statusbar').closed ? tab.setStatusBar(tab.record.get('statusbar')) : tab.closeStatusBar(); + if (tab.down('statusbar').closed) { + tab.setStatusBar(tab.record.get('statusbar')); + } else { + tab.closeStatusBar(); + } } }); // Focus the current service when Alt + Tab or click in webviews textfields diff --git a/app/Application.js b/app/Application.js index 5039e032..41fb940b 100644 --- a/app/Application.js +++ b/app/Application.js @@ -123,7 +123,11 @@ Ext.define('Rambox.Application', { var tabPanel = Ext.cq1('app-main'); if ( tabPanel.items.indexOf(tabPanel.getActiveTab()) === 0 ) return false; - key === Ext.event.Event.NUM_PLUS || key === 187 ? tabPanel.getActiveTab().zoomIn() : tabPanel.getActiveTab().zoomOut(); + if (key === Ext.event.Event.NUM_PLUS || key === 187) { + tabPanel.getActiveTab().zoomIn(); + } else { + tabPanel.getActiveTab().zoomOut(); + } } } ,{ diff --git a/app/store/Services.js b/app/store/Services.js index 506f9a4b..d20af23a 100644 --- a/app/store/Services.js +++ b/app/store/Services.js @@ -46,7 +46,11 @@ Ext.define('Rambox.store.Services', { } }; - service.get('align') === 'left' ? servicesLeft.push(cfg) : servicesRight.push(cfg); + if (service.get('align') === 'left') { + servicesLeft.push(cfg); + } else { + servicesRight.push(cfg); + } }); if ( !Ext.isEmpty(servicesLeft) ) Ext.cq1('app-main').insert(1, servicesLeft); diff --git a/app/ux/WebView.js b/app/ux/WebView.js index 51af59cf..f7e165c0 100644 --- a/app/ux/WebView.js +++ b/app/ux/WebView.js @@ -598,7 +598,13 @@ Ext.define('Rambox.ux.WebView',{ var me = this; var webview = me.down('component').el.dom; - if ( me.record.get('enabled') ) webview.isDevToolsOpened() ? webview.closeDevTools() : webview.openDevTools(); + if ( me.record.get('enabled')) { + if (webview.isDevToolsOpened()) { + webview.closeDevTools(); + } else { + webview.openDevTools(); + } + } } ,setURL: function(url) { diff --git a/app/view/add/Add.js b/app/view/add/Add.js index 9c9730cc..a0f13ad0 100644 --- a/app/view/add/Add.js +++ b/app/view/add/Add.js @@ -104,11 +104,23 @@ Ext.define('Rambox.view.add.Add',{ cycleBtn.previousSibling().reset(); if ( me.edit && cycleBtn.nextSibling().originalValue !== '2' ) { - me.service.get('custom_domain') && !activeItem.custom ? cycleBtn.previousSibling().reset() : cycleBtn.previousSibling().setValue(''); + if (me.service.get('custom_domain') && !activeItem.custom) { + cycleBtn.previousSibling().reset(); + } else { + cycleBtn.previousSibling().setValue(''); + } } else if ( me.edit && cycleBtn.nextSibling().originalValue === '2' ) { - me.service.get('custom_domain') && !activeItem.custom ? cycleBtn.previousSibling().setValue( me.service.get('url').indexOf('___') === -1 && me.service.get('custom_domain') ? me.service.get('url') : '') : cycleBtn.previousSibling().reset(); + if (me.service.get('custom_domain') && !activeItem.custom) { + cycleBtn.previousSibling().setValue( me.service.get('url').indexOf('___') === -1 && me.service.get('custom_domain') ? me.service.get('url') : ''); + } else { + cycleBtn.previousSibling().reset(); + } } else if ( !me.edit && cycleBtn.nextSibling().originalValue === '1' ) { - activeItem.custom ? cycleBtn.previousSibling().setValue('') : cycleBtn.previousSibling().reset(); + if (activeItem.custom) { + cycleBtn.previousSibling().setValue(''); + } else { + cycleBtn.previousSibling().reset(); + } } cycleBtn.previousSibling().previousSibling().setHidden(activeItem.custom ? true : me.edit ? me.service.get('url').indexOf('___') === -1 ? true : me.service.get('type') === 'custom' || me.service.get('url') === '___' : me.record.get('url').indexOf('___') === -1 ? true : me.record.get('type') === 'custom' || me.record.get('url') === '___');