122 lines
4.4 KiB
TypeScript
122 lines
4.4 KiB
TypeScript
// Metro module 13596 (f13597).
|
|
import { AppState, NativeModules } from "react-native";
|
|
import AccessibilityStore from "../../a11y/AccessibilityStore";
|
|
import SelectedChannelStore from "../../../stores/SelectedChannelStore";
|
|
import { isAndroid } from "../../../utils/PlatformUtils";
|
|
import Module13597 from "../../../_bundle/Module13597";
|
|
import LifecycleManager from "../../../lib/LifecycleManager";
|
|
import Dispatcher from "../../../Dispatcher";
|
|
import Module4587 from "../../../_bundle/Module4587";
|
|
class VoiceMessagesPlaybackManager extends LifecycleManager {
|
|
appState = AppState.currentState;
|
|
handleSetPrefersReducedMotion = (a0) => {
|
|
if (isAndroid()) {
|
|
Module4587.handleSetPrefersReducedMotion(a0.prefersReducedMotion);
|
|
} else {
|
|
NativeModules.DCDAccessibilityManager.handleSetPrefersReducedMotion(a0.prefersReducedMotion);
|
|
}
|
|
};
|
|
handleMessageDelete = (a0) => {
|
|
const id = a0.id;
|
|
if (a0.channelId === SelectedChannelStore.getCurrentlySelectedChannelId()) {
|
|
if (isAndroid()) {
|
|
Module13597.handleVoiceMessageDeleted(id);
|
|
} else {
|
|
const DCDAudioPlayerManager = NativeModules.DCDAudioPlayerManager;
|
|
if (DCDAudioPlayerManager != null) {
|
|
DCDAudioPlayerManager.handleVoiceMessageDeleted(id);
|
|
}
|
|
}
|
|
}
|
|
};
|
|
handleLogout = () => {
|
|
if (isAndroid()) {
|
|
Module13597.pauseCurrentPlayer(false);
|
|
} else {
|
|
const DCDAudioPlayerManager = NativeModules.DCDAudioPlayerManager;
|
|
if (DCDAudioPlayerManager != null) {
|
|
DCDAudioPlayerManager.pauseCurrentPlayer(false);
|
|
}
|
|
}
|
|
};
|
|
handleAppStateChanged = (a0) => {
|
|
L14: {
|
|
const state = a0.state;
|
|
if (isAndroid()) {
|
|
const appState = this.appState;
|
|
this.appState = state;
|
|
if (state === "active" && appState !== "active") {
|
|
if (isAndroid()) {
|
|
Module13597.maybePlayCurrentPlayer();
|
|
break L14;
|
|
}
|
|
const DCDAudioPlayerManager2 = NativeModules.DCDAudioPlayerManager;
|
|
if (DCDAudioPlayerManager2 == null) {
|
|
break L14;
|
|
}
|
|
DCDAudioPlayerManager2.maybePlayCurrentPlayer();
|
|
break L14;
|
|
}
|
|
if (state !== "active" && appState === "active") {
|
|
if (isAndroid()) {
|
|
Module13597.pauseCurrentPlayer(true);
|
|
} else {
|
|
const DCDAudioPlayerManager = NativeModules.DCDAudioPlayerManager;
|
|
if (DCDAudioPlayerManager != null) {
|
|
DCDAudioPlayerManager.pauseCurrentPlayer(true);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
};
|
|
_terminate() {
|
|
Dispatcher.unsubscribe("LOGOUT", this.handleLogout);
|
|
Dispatcher.unsubscribe("MESSAGE_DELETE", this.handleMessageDelete);
|
|
Dispatcher.unsubscribe("APP_STATE_UPDATE", this.handleAppStateChanged);
|
|
Dispatcher.unsubscribe("ACCESSIBILITY_SET_PREFERS_REDUCED_MOTION", this.handleSetPrefersReducedMotion);
|
|
}
|
|
_initialize() {
|
|
Dispatcher.subscribe("LOGOUT", this.handleLogout);
|
|
Dispatcher.subscribe("MESSAGE_DELETE", this.handleMessageDelete);
|
|
Dispatcher.subscribe("APP_STATE_UPDATE", this.handleAppStateChanged);
|
|
Dispatcher.subscribe("ACCESSIBILITY_SET_PREFERS_REDUCED_MOTION", this.handleSetPrefersReducedMotion);
|
|
this.handleSetPrefersReducedMotion({
|
|
type: "ACCESSIBILITY_SET_PREFERS_REDUCED_MOTION",
|
|
prefersReducedMotion: AccessibilityStore.rawPrefersReducedMotion
|
|
});
|
|
}
|
|
}
|
|
const voiceMessagesPlaybackManager = new VoiceMessagesPlaybackManager();
|
|
export default voiceMessagesPlaybackManager;
|
|
export function pauseCurrentAudioPlayer(a0) {
|
|
if (isAndroid()) {
|
|
Module13597.pauseCurrentPlayer(a0);
|
|
} else {
|
|
const DCDAudioPlayerManager = NativeModules.DCDAudioPlayerManager;
|
|
if (DCDAudioPlayerManager != null) {
|
|
DCDAudioPlayerManager.pauseCurrentPlayer(a0);
|
|
}
|
|
}
|
|
}
|
|
export function playCurrentAudioPlayer() {
|
|
if (isAndroid()) {
|
|
Module13597.maybePlayCurrentPlayer();
|
|
} else {
|
|
const DCDAudioPlayerManager = NativeModules.DCDAudioPlayerManager;
|
|
if (DCDAudioPlayerManager != null) {
|
|
DCDAudioPlayerManager.maybePlayCurrentPlayer();
|
|
}
|
|
}
|
|
}
|
|
export function handleVoiceMessageDeleted(a0) {
|
|
if (isAndroid()) {
|
|
Module13597.handleVoiceMessageDeleted(a0);
|
|
} else {
|
|
const DCDAudioPlayerManager = NativeModules.DCDAudioPlayerManager;
|
|
if (DCDAudioPlayerManager != null) {
|
|
DCDAudioPlayerManager.handleVoiceMessageDeleted(a0);
|
|
}
|
|
}
|
|
}
|