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