pause audio when unmount a RoomView and unloadAll when focusing at RoomsListView
This commit is contained in:
parent
8cab77f94e
commit
e84a5b3b4b
|
@ -102,7 +102,7 @@ import {
|
||||||
import { Services } from '../../lib/services';
|
import { Services } from '../../lib/services';
|
||||||
import { withActionSheet, IActionSheetProvider } from '../../containers/ActionSheet';
|
import { withActionSheet, IActionSheetProvider } from '../../containers/ActionSheet';
|
||||||
import { goRoom, TGoRoomItem } from '../../lib/methods/helpers/goRoom';
|
import { goRoom, TGoRoomItem } from '../../lib/methods/helpers/goRoom';
|
||||||
import handleAudioMedia from '../../lib/methods/handleAudioMedia';
|
import audioPlayer from '../../lib/methods/audioPlayer';
|
||||||
|
|
||||||
type TStateAttrsUpdate = keyof IRoomViewState;
|
type TStateAttrsUpdate = keyof IRoomViewState;
|
||||||
|
|
||||||
|
@ -429,7 +429,8 @@ class RoomView extends React.Component<IRoomViewProps, IRoomViewState> {
|
||||||
const { editing, room } = this.state;
|
const { editing, room } = this.state;
|
||||||
const db = database.active;
|
const db = database.active;
|
||||||
this.mounted = false;
|
this.mounted = false;
|
||||||
await handleAudioMedia.unloadAllAudios();
|
// TODO: Refactor when audio becomes global
|
||||||
|
await audioPlayer.pauseCurrentAudio();
|
||||||
if (!editing && this.messagebox && this.messagebox.current) {
|
if (!editing && this.messagebox && this.messagebox.current) {
|
||||||
const { text } = this.messagebox.current;
|
const { text } = this.messagebox.current;
|
||||||
let obj: TSubscriptionModel | TThreadModel | null = null;
|
let obj: TSubscriptionModel | TThreadModel | null = null;
|
||||||
|
|
|
@ -60,6 +60,7 @@ import {
|
||||||
} from '../../lib/methods/helpers';
|
} from '../../lib/methods/helpers';
|
||||||
import { E2E_BANNER_TYPE, DisplayMode, SortBy, MAX_SIDEBAR_WIDTH, themes } from '../../lib/constants';
|
import { E2E_BANNER_TYPE, DisplayMode, SortBy, MAX_SIDEBAR_WIDTH, themes } from '../../lib/constants';
|
||||||
import { Services } from '../../lib/services';
|
import { Services } from '../../lib/services';
|
||||||
|
import audioPlayer from '../../lib/methods/audioPlayer';
|
||||||
|
|
||||||
type TNavigation = CompositeNavigationProp<
|
type TNavigation = CompositeNavigationProp<
|
||||||
StackNavigationProp<ChatsStackParamList, 'RoomsListView'>,
|
StackNavigationProp<ChatsStackParamList, 'RoomsListView'>,
|
||||||
|
@ -228,6 +229,8 @@ class RoomsListView extends React.Component<IRoomsListViewProps, IRoomsListViewS
|
||||||
this.shouldUpdate = false;
|
this.shouldUpdate = false;
|
||||||
}
|
}
|
||||||
this.backHandler = BackHandler.addEventListener('hardwareBackPress', this.handleBackPress);
|
this.backHandler = BackHandler.addEventListener('hardwareBackPress', this.handleBackPress);
|
||||||
|
// TODO: Refactor when audio becomes global
|
||||||
|
audioPlayer.unloadAllAudios();
|
||||||
});
|
});
|
||||||
this.unsubscribeBlur = navigation.addListener('blur', () => {
|
this.unsubscribeBlur = navigation.addListener('blur', () => {
|
||||||
this.animated = false;
|
this.animated = false;
|
||||||
|
|
Loading…
Reference in New Issue