2023-06-07 15:09:43 +00:00
|
|
|
import { NetInfoStateType } from '@react-native-community/netinfo';
|
2023-05-11 23:20:48 +00:00
|
|
|
|
|
|
|
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';
|
2023-06-07 15:09:43 +00:00
|
|
|
import { store } from '../store/auxStore';
|
2023-05-11 23:20:48 +00:00
|
|
|
|
|
|
|
type TMediaType = typeof IMAGES_PREFERENCE_DOWNLOAD | typeof AUDIO_PREFERENCE_DOWNLOAD | typeof VIDEO_PREFERENCE_DOWNLOAD;
|
|
|
|
|
2023-06-07 15:09:43 +00:00
|
|
|
export const fetchAutoDownloadEnabled = (mediaType: TMediaType) => {
|
|
|
|
const { internetType } = store.getState().app;
|
2023-05-11 23:20:48 +00:00
|
|
|
const mediaDownloadPreference = userPreferences.getString(mediaType);
|
|
|
|
|
|
|
|
return (
|
2023-06-07 15:09:43 +00:00
|
|
|
(mediaDownloadPreference === MediaDownloadOption.WIFI && internetType === NetInfoStateType.wifi) ||
|
|
|
|
mediaDownloadPreference === MediaDownloadOption.WIFI_MOBILE_DATA
|
2023-05-11 23:20:48 +00:00
|
|
|
);
|
|
|
|
};
|