-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: surveyingUser failsafe storing all valid values
- Loading branch information
1 parent
07c61c1
commit e6e6a3b
Showing
5 changed files
with
15 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,10 @@ | ||
import { getData } from '../../../../modules/async-storage'; | ||
|
||
const surveyingUserFailsafe = async () => { | ||
const surveyingUserFailsafe = async (defautValue, validationFail) => { | ||
const user = await getData('currentUser'); | ||
return user.username || user.email || user.id || user.firstname || user.lastname; | ||
const userChecks = [defautValue, user.username, user.email, user.id, user.firstname, user.lastname, 'N/A']; | ||
const validIdentifiers = userChecks.filter((uniqueId) => validationFail(uniqueId) === false); | ||
return validIdentifiers[0]; | ||
}; | ||
|
||
export default surveyingUserFailsafe; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
const generateRandomID = () => Math.random().toString(20).substr(2, 12); | ||
const isEmpty = (str) => (!str || str.length === 0); | ||
const isEmpty = (str) => (!str || str === undefined || str.length === 0 || !/\S/.test(str)); | ||
|
||
export { isEmpty, generateRandomID }; |