New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Bug1413156 - lodash to ES6: replace _.without _.values _.last usage #3338
Conversation
Many thanks for the PRs! I've requested review from Cameron :-) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a few syntactic things to fix up here. Nice work! Thanks for the PR. :)
ui/job-view/PushList.jsx
Outdated
@@ -165,7 +165,7 @@ export default class PushList extends React.Component { | |||
// since we fetched more pushes, we need to persist the | |||
// push state in the URL. | |||
const rsArray = this.ThResultSetStore.getPushArray(); | |||
const updatedLastRevision = _.last(rsArray).revision; | |||
const updatedLastRevision = rsArray.slice(-1)[0].revision; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would prefer to just use ``rsArray[rsArray.length -1] for this
ui/js/controllers/main.js
Outdated
@@ -212,7 +212,9 @@ treeherderApp.controller('MainCtrl', [ | |||
*/ | |||
|
|||
$scope.isSingleTierSelected = function () { | |||
return _.without(_.values($scope.tiers), false).length === 1; | |||
return Object.values($scope.tiers).filter(function (value) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let's use the more terse ES6 syntax like:
return Object.values($scope.tiers).filter(value => (value !== false)).length === 1;
ui/js/models/repository.js
Outdated
@@ -278,7 +278,7 @@ treeherder.factory('ThRepositoryModel', [ | |||
|
|||
// To get the current repo to display first, we must | |||
// ensure it's added to the array last, as per normal user interaction | |||
storedWatched = _.without(storedWatched, options.name); | |||
storedWatched = storedWatched.filter(function (value) { return value !== options.name; }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Again, this could be:
storedWatched.filter(value => (value !== options.name));
ui/js/models/resultsets_store.js
Outdated
@@ -364,7 +364,7 @@ treeherder.factory('ThResultSetStore', [ | |||
} | |||
|
|||
repoData.pushes.sort(rsCompare); | |||
repoData.rsMapOldestTimestamp = _.last(repoData.pushes).push_timestamp; | |||
repoData.rsMapOldestTimestamp = repoData.pushes.slice(-1)[0].push_timestamp; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let's use repoData.pushes.length - 1
again here as above.
ui/js/services/jobfilters.js
Outdated
@@ -296,7 +296,9 @@ treeherder.factory('thJobFilters', [ | |||
if (value) { | |||
const oldQsVal = _getFiltersOrDefaults(field); | |||
if (oldQsVal && oldQsVal.length) { | |||
newQsVal = _.without(oldQsVal, value); | |||
newQsVal = oldQsVal.filter(function (filterValue) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let's use ES6 syntax here again, as above
Bug1413156 - lodash to ES6: replace _.without _.values _.last usage Bug1413156 - lodash to ES6: replace _.without _.values _.last usage
b6e26c3
to
8bacd73
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome! Thanks for the changes!
Bug1413156 - lodash to ES6: replace _.without _.values _.last usage