Minor fixes based on lgtm.com alerts (#6819)

* Remove a couple of superfluous trailing arguments

* Simplify assignment logic in a couple of places

* Modify some potentially inconsistent setState calls to use the function form

* Fix eslint errors
Этот коммит содержится в:
Alex Ford
2017-07-07 18:29:32 +01:00
коммит произвёл Joram Wilander
родитель e6ca2974cd
Коммит b03b9d7362
8 изменённых файлов: 20 добавлений и 17 удалений

Просмотреть файл

@@ -38,8 +38,8 @@ export default class ManageTeamsDropdown extends React.Component {
}
toggleDropdown() {
this.setState({
show: !this.state.show
this.setState((prevState) => {
return {show: !prevState.show};
});
}

Просмотреть файл

@@ -79,8 +79,6 @@ export default class PushSettings extends AdminSettings {
agree = true;
} else if (config.EmailSettings.PushNotificationServer === Constants.MTPNS) {
pushNotificationServerType = PUSH_NOTIFICATIONS_MTPNS;
} else {
pushNotificationServerType = PUSH_NOTIFICATIONS_CUSTOM;
}
let pushNotificationServer = config.EmailSettings.PushNotificationServer;

Просмотреть файл

@@ -55,10 +55,11 @@ export default class PostAttachment extends React.PureComponent {
toggleCollapseState(e) {
e.preventDefault();
this.setState({
text: this.state.collapsed ? this.state.uncollapsedText : this.state.collapsedText,
collapsed: !this.state.collapsed
this.setState((prevState) => {
return {
text: prevState.collapsed ? prevState.uncollapsedText : prevState.collapsedText,
collapsed: !prevState.collapsed
};
});
}

Просмотреть файл

@@ -62,7 +62,9 @@ export default class PostBodyAdditionalContent extends React.PureComponent {
}
toggleEmbedVisibility() {
this.setState({embedVisible: !this.state.embedVisible});
this.setState((prevState) => {
return {embedVisible: !prevState.embedVisible};
});
}
getSlackAttachment() {

Просмотреть файл

@@ -309,14 +309,13 @@ export default class Sidebar extends React.Component {
curIndex = i;
}
}
let nextChannel = allChannels[curIndex];
let nextIndex = curIndex;
if (e.keyCode === Constants.KeyCodes.DOWN) {
nextIndex = curIndex + 1;
} else if (e.keyCode === Constants.KeyCodes.UP) {
nextIndex = curIndex - 1;
}
nextChannel = allChannels[Utils.mod(nextIndex, allChannels.length)];
const nextChannel = allChannels[Utils.mod(nextIndex, allChannels.length)];
ChannelActions.goToChannel(nextChannel);
this.updateScrollbarOnChannelChange(nextChannel);
this.isSwitchingChannel = false;
@@ -342,7 +341,6 @@ export default class Sidebar extends React.Component {
curIndex = i;
}
}
let nextChannel = allChannels[curIndex];
let nextIndex = curIndex;
let count = 0;
let increment = 0;
@@ -359,7 +357,7 @@ export default class Sidebar extends React.Component {
unreadCounts = ChannelStore.getUnreadCount(allChannels[nextIndex].id);
}
if (unreadCounts.msgs !== 0 || unreadCounts.mentions !== 0) {
nextChannel = allChannels[nextIndex];
const nextChannel = allChannels[nextIndex];
ChannelActions.goToChannel(nextChannel);
this.updateScrollbarOnChannelChange(nextChannel);
}

Просмотреть файл

@@ -157,7 +157,9 @@ export default class Textbox extends React.Component {
showPreview(e) {
e.preventDefault();
e.target.blur();
this.setState({preview: !this.state.preview});
this.setState((prevState) => {
return {preview: prevState.preview};
});
}
hidePreview() {

Просмотреть файл

@@ -76,7 +76,9 @@ export default class SidebarRight extends React.Component {
if (e) {
e.preventDefault();
}
this.setState({expanded: !this.state.expanded});
this.setState((prevState) => {
return {expanded: !prevState.expanded};
});
}
onInitializeVideoCall(userId, isCaller) {