Rocket.Chat.ReactNative/app/lib/methods/autoDownloadPreference.ts

23 lines
799 B
TypeScript
Raw Normal View History

import { NetInfoStateType } from '@react-native-community/netinfo';
import {
IMAGES_PREFERENCE_DOWNLOAD,
AUDIO_PREFERENCE_DOWNLOAD,
VIDEO_PREFERENCE_DOWNLOAD,
MediaDownloadOption
2023-05-30 14:07:34 +00:00
} from '../constants';
import userPreferences from './userPreferences';
import { store } from '../store/auxStore';
type TMediaType = typeof IMAGES_PREFERENCE_DOWNLOAD | typeof AUDIO_PREFERENCE_DOWNLOAD | typeof VIDEO_PREFERENCE_DOWNLOAD;
export const fetchAutoDownloadEnabled = (mediaType: TMediaType) => {
const { internetType } = store.getState().app;
const mediaDownloadPreference = userPreferences.getString(mediaType);
return (
(mediaDownloadPreference === MediaDownloadOption.WIFI && internetType === NetInfoStateType.wifi) ||
mediaDownloadPreference === MediaDownloadOption.WIFI_MOBILE_DATA
);
};