import { NetInfoStateType } from '@react-native-community/netinfo'; import { IMAGES_PREFERENCE_DOWNLOAD, AUDIO_PREFERENCE_DOWNLOAD, VIDEO_PREFERENCE_DOWNLOAD, MediaDownloadOption } 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 ); };