diff --git a/app/soapbox/features/compose/components/upload_button.js b/app/soapbox/features/compose/components/upload_button.js
index 52125db83..811b7d9a4 100644
--- a/app/soapbox/features/compose/components/upload_button.js
+++ b/app/soapbox/features/compose/components/upload_button.js
@@ -10,9 +10,13 @@ const messages = defineMessages({
upload: { id: 'upload_button.label', defaultMessage: 'Add media attachment' },
});
+const onlyImages = types => {
+ return Boolean(types && types.every(type => type.startsWith('image/')));
+};
+
const makeMapStateToProps = () => {
const mapStateToProps = state => ({
- acceptContentTypes: state.getIn(['media_attachments', 'accept_content_types']),
+ attachmentTypes: state.getIn(['instance', 'configuration', 'media_attachments', 'supported_mime_types']),
});
return mapStateToProps;
@@ -28,7 +32,7 @@ class UploadButton extends ImmutablePureComponent {
onSelectFile: PropTypes.func.isRequired,
style: PropTypes.object,
resetFileKey: PropTypes.number,
- acceptContentTypes: ImmutablePropTypes.listOf(PropTypes.string).isRequired,
+ attachmentTypes: ImmutablePropTypes.listOf(PropTypes.string),
intl: PropTypes.object.isRequired,
};
@@ -47,17 +51,21 @@ class UploadButton extends ImmutablePureComponent {
}
render() {
- const { intl, resetFileKey, unavailable, disabled } = this.props;
+ const { intl, resetFileKey, attachmentTypes, unavailable, disabled } = this.props;
if (unavailable) {
return null;
}
+ const src = onlyImages(attachmentTypes)
+ ? require('@tabler/icons/icons/photo.svg')
+ : require('@tabler/icons/icons/paperclip.svg');
+
return (
{
- it('should return the initial state', () => {
- expect(reducer(undefined, {})).toEqual(ImmutableMap({
- accept_content_types: ImmutableList([
- '.jpg',
- '.jpeg',
- '.png',
- '.gif',
- '.webp',
- '.webm',
- '.mp4',
- '.m4v',
- '.mov',
- '.mp3',
- '.ogg',
- '.wav',
- 'image/jpeg',
- 'image/png',
- 'image/gif',
- 'image/webp',
- 'video/webm',
- 'video/mp4',
- 'video/quicktime',
- 'audio/mp3',
- 'audio/mpeg',
- 'audio/ogg',
- 'audio/wav',
- ]),
- }));
- });
-});
diff --git a/app/soapbox/reducers/index.js b/app/soapbox/reducers/index.js
index d2c4b36ff..d438b32eb 100644
--- a/app/soapbox/reducers/index.js
+++ b/app/soapbox/reducers/index.js
@@ -20,7 +20,6 @@ import reports from './reports';
import contexts from './contexts';
import compose from './compose';
import search from './search';
-import media_attachments from './media_attachments';
import notifications from './notifications';
import height_cache from './height_cache';
import custom_emojis from './custom_emojis';
@@ -76,7 +75,6 @@ const appReducer = combineReducers({
contexts,
compose,
search,
- media_attachments,
notifications,
height_cache,
custom_emojis,
diff --git a/app/soapbox/reducers/media_attachments.js b/app/soapbox/reducers/media_attachments.js
deleted file mode 100644
index 19400705a..000000000
--- a/app/soapbox/reducers/media_attachments.js
+++ /dev/null
@@ -1,40 +0,0 @@
-import {
- Map as ImmutableMap,
- List as ImmutableList,
-} from 'immutable';
-
-const initialState = ImmutableMap({
- // FIXME: Leave this empty and pull from backend
- accept_content_types: ImmutableList([
- '.jpg',
- '.jpeg',
- '.png',
- '.gif',
- '.webp',
- '.webm',
- '.mp4',
- '.m4v',
- '.mov',
- '.mp3',
- '.ogg',
- '.wav',
- 'image/jpeg',
- 'image/png',
- 'image/gif',
- 'image/webp',
- 'video/webm',
- 'video/mp4',
- 'video/quicktime',
- 'audio/mp3',
- 'audio/mpeg',
- 'audio/ogg',
- 'audio/wav',
- ]),
-});
-
-export default function meta(state = initialState, action) {
- switch(action.type) {
- default:
- return state;
- }
-}