Skip to content
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

Merged
merged 2 commits into from
Dec 6, 2019

Conversation

caitlanspronk
Copy link
Contributor

No description provided.

Copy link

@JackieChiles JackieChiles left a 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!

topics.map(t => {
const precombinedTopics = [];
topics.filter(t => {
if (t.indexOf('?') === -1) {

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

Copy link
Contributor Author

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 :)

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 👍

if (t.indexOf('?') === -1) {
return true;
} else {
precombinedTopics.push(t);

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

if (t.indexOf('?') === -1) {
return true;
} else {
precombinedTopics.push(t);
Copy link
Collaborator

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?

Copy link
Contributor Author

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 => {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

great work

Copy link

@JackieChiles JackieChiles left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great!

@jensengar jensengar merged commit 3ec490b into purecloudlabs:master Dec 6, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants