-
Notifications
You must be signed in to change notification settings - Fork 167
LG-6777 capture native camera after failed twice #6727
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
Changes from all commits
0c3bbfb
3e6ae99
4d3a8f9
1d51da5
5a4cfe6
a06e5d2
88a6a1e
bfe3064
143086e
89ae00f
1b78fed
102b543
cc442ac
887c011
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -18,7 +18,9 @@ import useCounter from '../hooks/use-counter'; | |
| * attempt, to increment attempts. | ||
| * @prop {() => void} onResetFailedCaptureAttempts Callback to trigger a reset of attempts. | ||
| * @prop {number} maxFailedAttemptsBeforeTips Number of failed attempts before showing tips. | ||
| * @prop {number} maxAttemptsBeforeNativeCamera Number of attempts before forcing the use of the native camera (if available) | ||
| * @prop {CaptureAttemptMetadata} lastAttemptMetadata Metadata about the last attempt. | ||
| * @prop {boolean} forceNativeCamera Whether or not to force use of the native camera. Is set to true if the number of failedCaptureAttempts is equal to or greater than maxAttemptsBeforeNativeCamera | ||
| */ | ||
|
|
||
| /** @type {CaptureAttemptMetadata} */ | ||
|
|
@@ -32,8 +34,10 @@ const FailedCaptureAttemptsContext = createContext( | |
| failedCaptureAttempts: 0, | ||
| onFailedCaptureAttempt: () => {}, | ||
| onResetFailedCaptureAttempts: () => {}, | ||
| maxAttemptsBeforeNativeCamera: Infinity, | ||
| maxFailedAttemptsBeforeTips: Infinity, | ||
| lastAttemptMetadata: DEFAULT_LAST_ATTEMPT_METADATA, | ||
| forceNativeCamera: false, | ||
| }), | ||
| ); | ||
|
|
||
|
|
@@ -44,18 +48,25 @@ FailedCaptureAttemptsContext.displayName = 'FailedCaptureAttemptsContext'; | |
| * | ||
| * @prop {ReactNode} children | ||
| * @prop {number} maxFailedAttemptsBeforeTips | ||
| * @prop {number} maxAttemptsBeforeNativeCamera | ||
|
Comment on lines
50
to
+51
Contributor
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. Will a user ever see these tips anymore? If not, is this a feature we'd want to remove?
Contributor
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. @aduth good catch -- we are currently all discussing this and will get back to you / push changes if needed.
Contributor
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. Ok. We have decided to open a separate ticket for dealing with the tips issue. It's going to take us a bit more time to sort that all out. As it stands with this branch, the tips should never be triggered (the default is 3 failed attempts vs our 2). |
||
| */ | ||
|
|
||
| /** | ||
| * @param {FailedCaptureAttemptsContextProviderProps} props | ||
| */ | ||
| function FailedCaptureAttemptsContextProvider({ children, maxFailedAttemptsBeforeTips }) { | ||
| function FailedCaptureAttemptsContextProvider({ | ||
| children, | ||
| maxFailedAttemptsBeforeTips, | ||
| maxAttemptsBeforeNativeCamera, | ||
| }) { | ||
| const [lastAttemptMetadata, setLastAttemptMetadata] = useState( | ||
| /** @type {CaptureAttemptMetadata} */ (DEFAULT_LAST_ATTEMPT_METADATA), | ||
| ); | ||
| const [failedCaptureAttempts, incrementFailedCaptureAttempts, onResetFailedCaptureAttempts] = | ||
| useCounter(); | ||
|
|
||
| const forceNativeCamera = failedCaptureAttempts >= maxAttemptsBeforeNativeCamera; | ||
|
|
||
| /** | ||
| * @param {CaptureAttemptMetadata} metadata | ||
| */ | ||
|
|
@@ -70,8 +81,10 @@ function FailedCaptureAttemptsContextProvider({ children, maxFailedAttemptsBefor | |
| failedCaptureAttempts, | ||
| onFailedCaptureAttempt, | ||
| onResetFailedCaptureAttempts, | ||
| maxAttemptsBeforeNativeCamera, | ||
| maxFailedAttemptsBeforeTips, | ||
| lastAttemptMetadata, | ||
| forceNativeCamera, | ||
| }} | ||
| > | ||
| {children} | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.