diff --git a/app/soapbox/actions/media.js b/app/soapbox/actions/media.js index daf31c019..1d5a540ce 100644 --- a/app/soapbox/actions/media.js +++ b/app/soapbox/actions/media.js @@ -1,11 +1,34 @@ import api from '../api'; +import { getFeatures } from 'soapbox/utils/features'; const noOp = () => {}; -export function uploadMedia(data, onUploadProgress = noOp) { - return function(dispatch, getState) { +export function uploadMediaV1(data, onUploadProgress = noOp) { + return (dispatch, getState) => { return api(getState).post('/api/v1/media', data, { onUploadProgress: onUploadProgress, }); }; } + +export function uploadMediaV2(data, onUploadProgress = noOp) { + return (dispatch, getState) => { + return api(getState).post('/api/v2/media', data, { + onUploadProgress: onUploadProgress, + }); + }; +} + +export function uploadMedia(data, onUploadProgress = noOp) { + return (dispatch, getState) => { + const state = getState(); + const instance = state.get('instance'); + const features = getFeatures(instance); + + if (features.mediaV2) { + return dispatch(uploadMediaV2(data, onUploadProgress)); + } else { + return dispatch(uploadMediaV1(data, onUploadProgress)); + } + }; +} diff --git a/app/soapbox/components/icon_button.js b/app/soapbox/components/icon_button.js index e892903d7..d7c036f12 100644 --- a/app/soapbox/components/icon_button.js +++ b/app/soapbox/components/icon_button.js @@ -140,7 +140,7 @@ export default class IconButton extends React.PureComponent { ?
: } - {text && {text}} + {text && {text}} ); } @@ -169,7 +169,7 @@ export default class IconButton extends React.PureComponent { ? : } - {text && {text}} + {text && {text}} )} diff --git a/app/soapbox/features/compose/components/upload.js b/app/soapbox/features/compose/components/upload.js index 4e03d1268..d0d150ca7 100644 --- a/app/soapbox/features/compose/components/upload.js +++ b/app/soapbox/features/compose/components/upload.js @@ -7,6 +7,7 @@ import ImmutablePureComponent from 'react-immutable-pure-component'; import { defineMessages, injectIntl, FormattedMessage } from 'react-intl'; import classNames from 'classnames'; import Icon from 'soapbox/components/icon'; +import IconButton from 'soapbox/components/icon_button'; import Blurhash from 'soapbox/components/blurhash'; const MIMETYPE_ICONS = { @@ -153,8 +154,20 @@ class Upload extends ImmutablePureComponent { backgroundPosition: `${x}% ${y}%` }} >