Skip to content

Commit

Permalink
Merge branch 'develop' into fix.download-same-filename
Browse files Browse the repository at this point in the history
  • Loading branch information
dnlsilva authored Feb 22, 2024
2 parents a017891 + 645b188 commit fb2c7c0
Show file tree
Hide file tree
Showing 114 changed files with 21,000 additions and 9,785 deletions.
44 changes: 44 additions & 0 deletions .github/workflows/organize_translations.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: organize translations

on:
push:
paths:
- 'app/i18n/locales/**.json'

jobs:
organize-and-commit:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 18

- name: Run script to organize JSON keys
run: node scripts/organize-translations.js

- name: Get changed files
id: git-check
uses: tj-actions/changed-files@v42
with:
files: |
**.json
- name: List all changed files
if: steps.git-check.outputs.any_changed == 'true'
env:
ALL_CHANGED_FILES: ${{ steps.git-check.outputs.all_changed_files }}
run: |
for file in ${ALL_CHANGED_FILES}; do
echo "$file was changed"
done
- name: Commit and push if changes
if: steps.git-check.outputs.any_changed == 'true'
uses: EndBug/add-and-commit@v9
with:
message: 'action: organized translations'

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

40 changes: 24 additions & 16 deletions app/containers/AudioPlayer/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ import styles from './styles';
import Seek from './Seek';
import PlaybackSpeed from './PlaybackSpeed';
import PlayButton from './PlayButton';
import EventEmitter from '../../lib/methods/helpers/events';
import audioPlayer, { AUDIO_FOCUSED } from '../../lib/methods/audioPlayer';
import AudioManager from '../../lib/methods/AudioManager';
import { AUDIO_PLAYBACK_SPEED, AVAILABLE_SPEEDS } from './constants';
import { TDownloadState } from '../../lib/methods/handleMediaDownload';
import { emitter } from '../../lib/methods/helpers';
import { TAudioState } from './types';
import { useUserPreferences } from '../../lib/methods';

Expand Down Expand Up @@ -86,23 +86,23 @@ const AudioPlayer = ({
};

const setPosition = async (time: number) => {
await audioPlayer.setPositionAsync(audioUri.current, time);
await AudioManager.setPositionAsync(audioUri.current, time);
};

const togglePlayPause = async () => {
try {
if (!paused) {
await audioPlayer.pauseAudio(audioUri.current);
await AudioManager.pauseAudio();
} else {
await audioPlayer.playAudio(audioUri.current);
await AudioManager.playAudio(audioUri.current);
}
} catch {
// Do nothing
}
};

useEffect(() => {
audioPlayer.setRateAsync(audioUri.current, playbackSpeed);
AudioManager.setRateAsync(audioUri.current, playbackSpeed);
}, [playbackSpeed]);

const onPress = () => {
Expand All @@ -116,11 +116,13 @@ const AudioPlayer = ({
};

useEffect(() => {
InteractionManager.runAfterInteractions(async () => {
audioUri.current = await audioPlayer.loadAudio({ msgId, rid, uri: fileUri });
audioPlayer.setOnPlaybackStatusUpdate(audioUri.current, onPlaybackStatusUpdate);
audioPlayer.setRateAsync(audioUri.current, playbackSpeed);
});
if (fileUri) {
InteractionManager.runAfterInteractions(async () => {
audioUri.current = await AudioManager.loadAudio({ msgId, rid, uri: fileUri });
AudioManager.setOnPlaybackStatusUpdate(audioUri.current, onPlaybackStatusUpdate);
AudioManager.setRateAsync(audioUri.current, playbackSpeed);
});
}
}, [fileUri]);

useEffect(() => {
Expand All @@ -133,20 +135,26 @@ const AudioPlayer = ({

useEffect(() => {
const unsubscribeFocus = navigation.addListener('focus', () => {
audioPlayer.setOnPlaybackStatusUpdate(audioUri.current, onPlaybackStatusUpdate);
AudioManager.setOnPlaybackStatusUpdate(audioUri.current, onPlaybackStatusUpdate);
AudioManager.addAudioRendered(audioUri.current);
});
const unsubscribeBlur = navigation.addListener('blur', () => {
AudioManager.removeAudioRendered(audioUri.current);
});

return () => {
unsubscribeFocus();
unsubscribeBlur();
};
}, [navigation]);

useEffect(() => {
const listener = EventEmitter.addEventListener(AUDIO_FOCUSED, ({ audioFocused }: { audioFocused: string }) => {
setFocused(audioFocused === audioUri.current);
});
const audioFocusedEventHandler = (audioFocused: string) => {
setFocused(!!audioFocused && audioFocused === audioUri.current);
};
emitter.on('audioFocused', audioFocusedEventHandler);
return () => {
EventEmitter.removeListener(AUDIO_FOCUSED, listener);
emitter.off('audioFocused', audioFocusedEventHandler);
};
}, []);

Expand Down
Loading

0 comments on commit fb2c7c0

Please sign in to comment.