-
Notifications
You must be signed in to change notification settings - Fork 339
React liveness/provide default device info #6633
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
Open
riasatali42
wants to merge
26
commits into
aws-amplify:main
Choose a base branch
from
SmarterServices:react-liveness/provide-default-device-info
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+1,287
−21
Open
Changes from 25 commits
Commits
Show all changes
26 commits
Select commit
Hold shift + click to select a range
58d9ba1
feat: add ability to pass device in and out of liveness check
jasonfill f00e7fd
chore: clean up some formatting issues
jasonfill 16f1c07
chore: fix additional formatting issues
jasonfill 1216c8f
chore: fix more formatting
jasonfill 54d64f3
chore: fix some formatting items
jasonfill afd93c1
chore: additional formatting changes
jasonfill e8a5653
chore: some resolutions were removed, replaced them
jasonfill b11b3ce
chore: formatting
jasonfill 85f47e0
chore: remove duplicate items in package
jasonfill 8ca425d
chore: formatting
jasonfill 933013b
chore: add ability to provide default device label to select that dev…
riasatali42 afb5077
chore: added callback method for camera changed and if not default ca…
riasatali42 8c9f3e9
chore: added selectableDevices array check
riasatali42 a89ff4d
chore: added default device info in machine tests for unit testing
riasatali42 8905251
chore: default device info for unit testing default device pass in
riasatali42 36e0fd3
chore: unit tests added for default device not found and camera switc…
riasatali42 497bfb0
chore: added device selection priority unit tests
riasatali42 f0f7923
docs: added changeset for minor changes
riasatali42 3c75e1d
fix: resolved merge conflicts
riasatali42 0a3ad1b
fix: fixed mock device info after resolving merge conflicts
riasatali42 724dca3
chore: added updated unit tests for passed in device label, callCamer…
riasatali42 7a701c1
Merge branch 'main' into react-liveness/provide-default-device-info
riasatali42 d1bede1
fix: fixed ESlint issue on livenesscameramodule
riasatali42 af9b3bf
fix: fixed eslint issue on adding type on error and replaced operator
riasatali42 bfd66d5
Merge branch 'react-liveness/provide-default-device-info' of https://…
riasatali42 3662944
fix: resolved PR feedback, added console error, removed device info f…
riasatali42 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'@aws-amplify/ui-react-liveness': minor | ||
--- | ||
|
||
Pass default device info using ID and label; prioritize label over ID. Emit detailed device info on camera selection/change. Add warnings for default device not found and camera change events. |
This file contains hidden or 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 |
---|---|---|
|
@@ -145,6 +145,40 @@ export const LivenessCameraModule = ( | |
recording: 'flashFreshnessColors', | ||
}); | ||
|
||
// Update the device if the selectedDeviceId changes | ||
React.useEffect(() => { | ||
if ( | ||
selectedDeviceId && | ||
Array.isArray(selectableDevices) && | ||
selectableDevices.length > 0 | ||
) { | ||
const device = selectableDevices.find( | ||
(d) => d.deviceId === selectedDeviceId | ||
); | ||
if (device) { | ||
// Update the device in the state machine | ||
const changeCamera = async () => { | ||
try { | ||
const newStream = await navigator.mediaDevices.getUserMedia({ | ||
video: { | ||
...videoConstraints, | ||
deviceId: { exact: selectedDeviceId }, | ||
}, | ||
audio: false, | ||
}); | ||
send({ | ||
type: 'UPDATE_DEVICE_AND_STREAM', | ||
data: { newDeviceId: selectedDeviceId, newStream }, | ||
}); | ||
} catch (error: any) { | ||
throw new Error('Error updating device:'); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Let's include the original error message. ex:
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Resolved. |
||
} | ||
}; | ||
changeCamera(); | ||
} | ||
} | ||
}, [selectedDeviceId, selectableDevices, send, videoConstraints]); | ||
|
||
// Android/Firefox and iOS flip the values of width/height returned from | ||
// getUserMedia, so we'll reset these in useLayoutEffect with the videoRef | ||
// element's intrinsic videoWidth and videoHeight attributes | ||
|
This file contains hidden or 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
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Why do we need to create a new effect here instead of reusing the existing onCameraChange callback?
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 think we can discard that as the onCameraChange is already handling everything. So, I discarded.