2019-08-12 15:21:42 +00:00
|
|
|
import { createSelector } from 'reselect';
|
2020-06-08 09:46:38 +00:00
|
|
|
import getConfig from '../../../utils/getConfig';
|
2019-08-12 15:21:42 +00:00
|
|
|
|
|
|
|
const getAuthenticated = state => state.user.authenticated;
|
|
|
|
const getTotalSize = state => state.user.totalSize;
|
2020-03-24 22:07:58 +00:00
|
|
|
const getAssetsTotalSize = state => state.assets.totalSize;
|
2020-06-08 09:46:38 +00:00
|
|
|
const limit = getConfig('UPLOAD_LIMIT') || 250000000;
|
2019-08-12 15:21:42 +00:00
|
|
|
|
|
|
|
export const getCanUploadMedia = createSelector(
|
|
|
|
getAuthenticated,
|
|
|
|
getTotalSize,
|
|
|
|
(authenticated, totalSize) => {
|
|
|
|
if (!authenticated) return false;
|
|
|
|
// eventually do the same thing for verified when
|
|
|
|
// email verification actually works
|
2019-09-26 19:06:43 +00:00
|
|
|
if (totalSize > limit) return false;
|
2019-08-12 15:21:42 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
);
|
|
|
|
|
|
|
|
export const getreachedTotalSizeLimit = createSelector(
|
|
|
|
getTotalSize,
|
2020-03-24 22:07:58 +00:00
|
|
|
getAssetsTotalSize,
|
|
|
|
(totalSize, assetsTotalSize) => {
|
|
|
|
const currentSize = totalSize || assetsTotalSize;
|
|
|
|
if (currentSize && currentSize > limit) return true;
|
2019-09-26 19:06:43 +00:00
|
|
|
// if (totalSize > 1000) return true;
|
2019-08-12 15:21:42 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
);
|