2019-08-12 15:21:42 +00:00
|
|
|
import { createSelector } from 'reselect';
|
|
|
|
|
2019-09-26 19:06:43 +00:00
|
|
|
const __process = (typeof global !== 'undefined' ? global : window).process;
|
2019-08-12 15:21:42 +00:00
|
|
|
const getAuthenticated = state => state.user.authenticated;
|
|
|
|
const getTotalSize = state => state.user.totalSize;
|
2019-09-26 19:06:43 +00:00
|
|
|
const limit = __process.env.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,
|
|
|
|
(totalSize) => {
|
2019-09-26 19:06:43 +00:00
|
|
|
if (totalSize > limit) return true;
|
|
|
|
// if (totalSize > 1000) return true;
|
2019-08-12 15:21:42 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
);
|