-
Notifications
You must be signed in to change notification settings - Fork 8
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
Don't automatically combine already combined topics #43
Don't automatically combine already combined topics #43
Conversation
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.
Couple of suggestions in-line. I haven't run this yet but I can tomorrow. Thanks for the quick fix!
src/notifications.js
Outdated
topics.map(t => { | ||
const precombinedTopics = []; | ||
topics.filter(t => { | ||
if (t.indexOf('?') === -1) { |
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.
Can use !t.includes('?')
now that we don't have to support IE
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.
Okay--I since this is a public project I thought maybe we still wanted to try to be compatible, but I'm certainly happy to use includes instead :)
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.
True, though I'm willing to say dropping IE support extends to this library as well, I'm cool either way 👍
src/notifications.js
Outdated
if (t.indexOf('?') === -1) { | ||
return true; | ||
} else { | ||
precombinedTopics.push(t); |
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.
Might be good to push { id: t }
here rather than the additional map
below for consistency with the other push
call to combinedTopics
src/notifications.js
Outdated
if (t.indexOf('?') === -1) { | ||
return true; | ||
} else { | ||
precombinedTopics.push(t); |
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.
Also, this is a side-effect and should generally be avoided. By that, I mean you shouldn't do
something.filter((item) => {
if (!item.condition) {
// do something unrelated
}
return item.condition
}
I understand why you are doing this and that it saves a line or two of code, but I'd prefer either using a forEach to create 2 different arrays, or running a separate dedicated filter to find the precombinedTopics. Does that make sense what I'm saying?
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.
Yep, it does, and will do!
@@ -370,3 +370,26 @@ test('notifications | mapCompineTopics should correctly reduce topics', t => { | |||
t.is(reducedTopics[1].id, 'v2.users.testuser.thisIsAReallyLongTopicForThePurposeOfExceeding200CharsinCombinedTopicNames'); | |||
t.is(reducedTopics[2].id, 'v2.users.testuser?InRealityTheseWouldBeALotOfDisparateTopicsThatWhenJoinedExceed200Chars&athirdreallylongtopicathirdreallylongtopicathird'); | |||
}); | |||
|
|||
test('notifications | mapCompineTopics should not combine already combined topics', t => { |
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.
great work
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.
Looks great!
No description provided.