audio auto download when the user who sent the audio is the same logged on mobile
This commit is contained in:
parent
f5d6fce6de
commit
b73cf46829
|
@ -54,7 +54,7 @@ const AttachedActions = ({ attachment, getCustomEmoji }: { attachment: IAttachme
|
||||||
};
|
};
|
||||||
|
|
||||||
const Attachments: React.FC<IMessageAttachments> = React.memo(
|
const Attachments: React.FC<IMessageAttachments> = React.memo(
|
||||||
({ attachments, timeFormat, showAttachment, style, getCustomEmoji, isReply, id }: IMessageAttachments) => {
|
({ attachments, timeFormat, showAttachment, style, getCustomEmoji, isReply, id, author }: IMessageAttachments) => {
|
||||||
const { theme } = useTheme();
|
const { theme } = useTheme();
|
||||||
|
|
||||||
if (!attachments || attachments.length === 0) {
|
if (!attachments || attachments.length === 0) {
|
||||||
|
@ -85,6 +85,7 @@ const Attachments: React.FC<IMessageAttachments> = React.memo(
|
||||||
style={style}
|
style={style}
|
||||||
theme={theme}
|
theme={theme}
|
||||||
messageId={id}
|
messageId={id}
|
||||||
|
author={author}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,7 +18,7 @@ import MessageContext from './Context';
|
||||||
import ActivityIndicator from '../ActivityIndicator';
|
import ActivityIndicator from '../ActivityIndicator';
|
||||||
import { withDimensions } from '../../dimensions';
|
import { withDimensions } from '../../dimensions';
|
||||||
import { TGetCustomEmoji } from '../../definitions/IEmoji';
|
import { TGetCustomEmoji } from '../../definitions/IEmoji';
|
||||||
import { IAttachment } from '../../definitions';
|
import { IAttachment, IUserMessage } from '../../definitions';
|
||||||
import { TSupportedThemes } from '../../theme';
|
import { TSupportedThemes } from '../../theme';
|
||||||
import { downloadAudioFile, searchAudioFileAsync } from '../../lib/methods/audioFile';
|
import { downloadAudioFile, searchAudioFileAsync } from '../../lib/methods/audioFile';
|
||||||
import EventEmitter from '../../lib/methods/helpers/events';
|
import EventEmitter from '../../lib/methods/helpers/events';
|
||||||
|
@ -42,6 +42,7 @@ interface IMessageAudioProps {
|
||||||
getCustomEmoji: TGetCustomEmoji;
|
getCustomEmoji: TGetCustomEmoji;
|
||||||
scale?: number;
|
scale?: number;
|
||||||
messageId: string;
|
messageId: string;
|
||||||
|
author?: IUserMessage;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface IMessageAudioState {
|
interface IMessageAudioState {
|
||||||
|
@ -161,7 +162,8 @@ class MessageAudio extends React.Component<IMessageAudioProps, IMessageAudioStat
|
||||||
};
|
};
|
||||||
|
|
||||||
handleAutoDownload = async () => {
|
handleAutoDownload = async () => {
|
||||||
const { messageId } = this.props;
|
const { messageId, author } = this.props;
|
||||||
|
const { user } = this.context;
|
||||||
const url = this.getUrl();
|
const url = this.getUrl();
|
||||||
try {
|
try {
|
||||||
if (url) {
|
if (url) {
|
||||||
|
@ -175,7 +177,8 @@ class MessageAudio extends React.Component<IMessageAudioProps, IMessageAudioStat
|
||||||
const netInfoState = await NetInfo.fetch();
|
const netInfoState = await NetInfo.fetch();
|
||||||
const autoDownload =
|
const autoDownload =
|
||||||
(audioDownloadPreference === MediaDownloadOption.WIFI && netInfoState.type === NetInfoStateType.wifi) ||
|
(audioDownloadPreference === MediaDownloadOption.WIFI && netInfoState.type === NetInfoStateType.wifi) ||
|
||||||
audioDownloadPreference === MediaDownloadOption.WIFI_MOBILE_DATA;
|
audioDownloadPreference === MediaDownloadOption.WIFI_MOBILE_DATA ||
|
||||||
|
author?._id === user.id;
|
||||||
|
|
||||||
if (autoDownload) {
|
if (autoDownload) {
|
||||||
await this.startDownload();
|
await this.startDownload();
|
||||||
|
|
|
@ -15,6 +15,7 @@ export interface IMessageAttachments {
|
||||||
showAttachment?: (file: IAttachment) => void;
|
showAttachment?: (file: IAttachment) => void;
|
||||||
getCustomEmoji: TGetCustomEmoji;
|
getCustomEmoji: TGetCustomEmoji;
|
||||||
id: string;
|
id: string;
|
||||||
|
author?: IUserMessage;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface IMessageAvatar {
|
export interface IMessageAvatar {
|
||||||
|
|
Loading…
Reference in New Issue