Skip to content

Commit

Permalink
chore: use fs platform specific code separation
Browse files Browse the repository at this point in the history
  • Loading branch information
kirillzyusko committed Feb 1, 2024
1 parent 2224618 commit 2447423
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 7 deletions.
3 changes: 3 additions & 0 deletions src/libs/Sound/config/index.native.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
const config = {prefix: ''};

export default config;
3 changes: 3 additions & 0 deletions src/libs/Sound/config/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
const config = {prefix: '/sounds/'};

export default config;
9 changes: 2 additions & 7 deletions src/libs/Sound/index.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,7 @@
import {Platform} from 'react-native';
import Onyx from 'react-native-onyx';
import Sound from 'react-native-sound';
import ONYXKEYS from '@src/ONYXKEYS';

const prefix = Platform.select({
web: '/sounds/',
default: '',
});
import config from './config';

let isMuted = false;

Expand Down Expand Up @@ -55,7 +50,7 @@ function withMinimalExecutionTime<F extends (...args: Parameters<F>) => ReturnTy
}

const playSound = (soundFile: string) => {
const sound = new Sound(`${prefix}${soundFile}.mp3`, Sound.MAIN_BUNDLE, (error) => {
const sound = new Sound(`${config.prefix}${soundFile}.mp3`, Sound.MAIN_BUNDLE, (error) => {
if (error || isMuted) {
return;
}
Expand Down

0 comments on commit 2447423

Please sign in to comment.