Skip to content
This repository has been archived by the owner on Dec 27, 2022. It is now read-only.

Take result of find and make boolean #4

Merged
merged 1 commit into from
May 5, 2018

Conversation

paul90
Copy link
Contributor

@paul90 paul90 commented May 5, 2018

Take the result of find and make it true/false rather than the found value or undefined if there isn't a match.

Provides a fix for beakerbrowser/fritter#17

@paul90
Copy link
Contributor Author

paul90 commented May 5, 2018

What was happening is that the find record.mentions.find(x => { return x.url == inst.userUrl }) is either giving us the firstx where the test x.url == inst.userUrl is true, or the find is giving us an undefined.

This means that the result of calling isAMentionOfUser(record) is:

  • false - if record does not contain mentions
  • undefined - if record contains mentions but not for the user
  • an object the matching element from the the mentions list - if the record contains mentions and it is for the user

The fix is to not a test on if the find is undefined, giving us true if there is a mention of the user, and false if there isn't.

@pfrazee
Copy link
Member

pfrazee commented May 5, 2018

Good catch. It might not be an issue except that the usage is checking explicitly for false: if (isAMentionOfUser(record) === false) return.

@pfrazee pfrazee merged commit 1f74a74 into beakerbrowser:master May 5, 2018
@pfrazee
Copy link
Member

pfrazee commented May 5, 2018

Published 2.2.1

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants