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

fix: Fix playing Shutter Sound in Scan Receipt #39400

Merged
merged 11 commits into from
Apr 4, 2024
16 changes: 11 additions & 5 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@ GEM
specs:
CFPropertyList (3.0.6)
rexml
activesupport (7.0.8)
activesupport (6.1.7.7)
concurrent-ruby (~> 1.0, >= 1.0.2)
i18n (>= 1.6, < 2)
minitest (>= 5.1)
tzinfo (~> 2.0)
zeitwerk (~> 2.3)
addressable (2.8.6)
public_suffix (>= 2.0.2, < 6.0)
algoliasearch (1.27.5)
Expand Down Expand Up @@ -80,7 +81,8 @@ GEM
declarative (0.0.20)
digest-crc (0.6.5)
rake (>= 12.0.0, < 14.0.0)
domain_name (0.6.20240107)
domain_name (0.5.20190701)
unf (>= 0.0.5, < 1.0.0)
dotenv (2.8.1)
emoji_regex (3.2.3)
escape (0.0.4)
Expand Down Expand Up @@ -187,11 +189,11 @@ GEM
google-cloud-env (1.6.0)
faraday (>= 0.17.3, < 3.0)
google-cloud-errors (1.3.1)
google-cloud-storage (1.47.0)
google-cloud-storage (1.37.0)
addressable (~> 2.8)
digest-crc (~> 0.4)
google-apis-iamcredentials_v1 (~> 0.1)
google-apis-storage_v1 (~> 0.31.0)
google-apis-storage_v1 (~> 0.1)
google-cloud-core (~> 1.6)
googleauth (>= 0.16.2, < 2.a)
mini_mime (~> 1.0)
Expand Down Expand Up @@ -260,6 +262,9 @@ GEM
tzinfo (2.0.6)
concurrent-ruby (~> 1.0)
uber (0.1.0)
unf (0.1.4)
unf_ext
unf_ext (0.0.9.1)
unicode-display_width (2.5.0)
word_wrap (1.0.0)
xcodeproj (1.23.0)
Expand All @@ -273,6 +278,7 @@ GEM
rouge (~> 2.0.7)
xcpretty-travis-formatter (1.0.1)
xcpretty (~> 0.2, >= 0.0.7)
zeitwerk (2.6.13)

PLATFORMS
arm64-darwin-21
Expand All @@ -292,4 +298,4 @@ RUBY VERSION
ruby 2.6.10p210

BUNDLED WITH
2.4.19
2.3.22
4 changes: 2 additions & 2 deletions ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1415,7 +1415,7 @@ PODS:
- SDWebImage/Core (~> 5.17)
- SocketRocket (0.6.1)
- Turf (2.7.0)
- VisionCamera (4.0.0-beta.11):
- VisionCamera (4.0.0-beta.12):
- React
- React-callinvoker
- React-Core
Expand Down Expand Up @@ -1920,7 +1920,7 @@ SPEC CHECKSUMS:
SDWebImageWebPCoder: af09429398d99d524cae2fe00f6f0f6e491ed102
SocketRocket: f32cd54efbe0f095c4d7594881e52619cfe80b17
Turf: 13d1a92d969ca0311bbc26e8356cca178ce95da2
VisionCamera: b6b6f46949eae83b71429c971162af337ef34fa3
VisionCamera: 2b580d4ce87bd152f00986096afb590764ebf30e
Yoga: e64aa65de36c0832d04e8c7bd614396c77a80047

PODFILE CHECKSUM: a431c146e1501391834a2f299a74093bac53b530
Expand Down
8 changes: 4 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@
"react-native-tab-view": "^3.5.2",
"react-native-url-polyfill": "^2.0.0",
"react-native-view-shot": "3.8.0",
"react-native-vision-camera": "^4.0.0-beta.11",
"react-native-vision-camera": "^4.0.0-beta.12",
"react-native-web": "^0.19.9",
"react-native-web-linear-gradient": "^1.1.2",
"react-native-web-sound": "^0.1.3",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {useFocusEffect} from '@react-navigation/core';
import lodashGet from 'lodash/get';
import React, {useCallback, useRef, useState} from 'react';
import React, {useCallback, useEffect, useRef, useState} from 'react';

Check failure on line 3 in src/pages/iou/request/step/IOURequestStepScan/index.native.js

View workflow job for this annotation

GitHub Actions / Run ESLint

'useEffect' is defined but never used
import {ActivityIndicator, Alert, AppState, InteractionManager, View} from 'react-native';
import {Gesture, GestureDetector} from 'react-native-gesture-handler';
import {RESULTS} from 'react-native-permissions';
Expand Down Expand Up @@ -31,6 +31,8 @@
import * as IOU from '@userActions/IOU';
import CONST from '@src/CONST';
import ROUTES from '@src/ROUTES';
import Onyx, {useOnyx} from 'react-native-onyx';

Check failure on line 34 in src/pages/iou/request/step/IOURequestStepScan/index.native.js

View workflow job for this annotation

GitHub Actions / Run ESLint

'Onyx' is defined but never used
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
import Onyx, {useOnyx} from 'react-native-onyx';
import {withOnyx} from 'react-native-onyx';

import ONYXKEYS from '@src/ONYXKEYS';
import * as CameraPermission from './CameraPermission';
import NavigationAwareCamera from './NavigationAwareCamera';

Expand Down Expand Up @@ -63,6 +65,7 @@
const device = useCameraDevice('back', {
physicalDevices: ['wide-angle-camera'],
});
const [user] = useOnyx(ONYXKEYS.USER)
Copy link
Member Author

Choose a reason for hiding this comment

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

should I use a selector for only isMutedAllSounds here, or is this fine?

Copy link
Contributor

Choose a reason for hiding this comment

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

I dont think we can use useOnyx yet, please use selector

Copy link
Member Author

Choose a reason for hiding this comment

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

How would that look like then? Onyx.connect(...)?

Copy link
Contributor

Choose a reason for hiding this comment

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

@mountiny what is the reason we shouldn't use `useOnyx yet?

Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
const [user] = useOnyx(ONYXKEYS.USER)


const hasFlash = device != null && device.hasFlash;
const camera = useRef(null);
Expand Down Expand Up @@ -239,6 +242,7 @@
return camera.current
.takePhoto({
flash: flash && hasFlash ? 'on' : 'off',
enableShutterSound: !user.isMutedAllSounds
})
.then((photo) => {
// Store the receipt on the transaction object in Onyx
Expand All @@ -258,7 +262,7 @@
showCameraAlert();
Log.warn('Error taking photo', error);
});
}, [flash, hasFlash, action, translate, transactionID, updateScanAndNavigate, navigateToConfirmationStep, cameraPermissionStatus]);
}, [cameraPermissionStatus, flash, hasFlash, user.isMutedAllSounds, translate, transactionID, action, navigateToConfirmationStep, updateScanAndNavigate]);

// Wait for camera permission status to render
if (cameraPermissionStatus == null) {
Expand Down
Loading