Skip to content

Commit 87c0ff0

Browse files
committed
chore: code review
1 parent 3dabff7 commit 87c0ff0

File tree

1 file changed

+7
-15
lines changed

1 file changed

+7
-15
lines changed

example/src/App.tsx

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ import stylesheet from './styles';
4141
import { Colors } from './theme';
4242
import FastImage from 'react-native-fast-image';
4343

44-
let currentPlayingRef: React.RefObject<IWaveformRef> | null = null;
44+
let currentPlayingRef: React.RefObject<IWaveformRef> | undefined;
4545
const RenderListItem = React.memo(
4646
({
4747
item,
@@ -60,8 +60,6 @@ const RenderListItem = React.memo(
6060
const [isLoading, setIsLoading] = useState(true);
6161

6262
const handlePlayStopAction = async () => {
63-
console.log('currentPlayingRef', currentPlayingRef);
64-
6563
let currentPlayer = currentPlayingRef?.current;
6664

6765
// If no player or if current player is stopped just start it!
@@ -79,7 +77,7 @@ const RenderListItem = React.memo(
7977
await currentPlayingRef?.current?.stopPlayer();
8078
}
8179

82-
// Start player only when it is a different one!
80+
// Start player when it is a different one!
8381
if (currentPlayer.playerKey() !== ref?.current?.playerKey()) {
8482
currentPlayingRef = ref;
8583
await currentPlayingRef.current?.startPlayer({
@@ -123,21 +121,15 @@ const RenderListItem = React.memo(
123121
scrubColor={Colors.white}
124122
waveColor={Colors.lightWhite}
125123
candleHeightScale={4}
126-
onPlayerStateChange={state => {
127-
setPlayerState(state);
128-
console.log(`state changed ${state}`);
129-
}}
124+
onPlayerStateChange={setPlayerState}
130125
onPanStateChange={onPanStateChange}
131126
onError={error => {
132127
console.log(error, 'we are in example');
133128
}}
134129
onCurrentProgressChange={(currentProgress, songDuration) => {
135-
// console.log(
136-
// 'currentProgress ',
137-
// currentProgress,
138-
// 'songDuration ',
139-
// songDuration
140-
// );
130+
console.log(
131+
`currentProgress ${currentProgress}, songDuration ${songDuration}`
132+
);
141133
}}
142134
onChangeWaveformLoadState={state => {
143135
setIsLoading(state);
@@ -204,7 +196,7 @@ const LivePlayerComponent = ({
204196
ref.current?.stopRecord().then(path => {
205197
setList(prev => [...prev, { fromCurrentUser: true, path }]);
206198
});
207-
currentPlayingRef = null;
199+
currentPlayingRef = undefined;
208200
}
209201
};
210202

0 commit comments

Comments
 (0)