2019-08-12 17:21:42 +02:00
|
|
|
import { createSelector } from 'reselect';
|
2020-06-08 11:46:38 +02:00
|
|
|
import getConfig from '../../../utils/getConfig';
|
2019-08-12 17:21:42 +02:00
|
|
|
|
|
|
|
const getAuthenticated = state => state.user.authenticated;
|
|
|
|
const getTotalSize = state => state.user.totalSize;
|
2020-03-24 23:07:58 +01:00
|
|
|
const getAssetsTotalSize = state => state.assets.totalSize;
|
2020-06-08 11:46:38 +02:00
|
|
|
const limit = getConfig('UPLOAD_LIMIT') || 250000000;
|
2019-08-12 17:21:42 +02: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 21:06:43 +02:00
|
|
|
if (totalSize > limit) return false;
|
2019-08-12 17:21:42 +02:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
);
|
|
|
|
|
|
|
|
export const getreachedTotalSizeLimit = createSelector(
|
|
|
|
getTotalSize,
|
2020-03-24 23:07:58 +01:00
|
|
|
getAssetsTotalSize,
|
|
|
|
(totalSize, assetsTotalSize) => {
|
|
|
|
const currentSize = totalSize || assetsTotalSize;
|
|
|
|
if (currentSize && currentSize > limit) return true;
|
2019-09-26 21:06:43 +02:00
|
|
|
// if (totalSize > 1000) return true;
|
2019-08-12 17:21:42 +02:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
);
|