From 4f8d476a2b5ff9bb75f8300665e2c18aa96fecfd Mon Sep 17 00:00:00 2001 From: dtluna Date: Fri, 25 Nov 2016 20:21:25 +0300 Subject: Add fileTypeService --- src/components/attachment/attachment.js | 17 ++--------------- src/components/post_status_form/post_status_form.js | 4 ++++ src/components/post_status_form/post_status_form.vue | 2 +- 3 files changed, 7 insertions(+), 16 deletions(-) (limited to 'src/components') diff --git a/src/components/attachment/attachment.js b/src/components/attachment/attachment.js index 99958589..fa43c12f 100644 --- a/src/components/attachment/attachment.js +++ b/src/components/attachment/attachment.js @@ -1,4 +1,5 @@ import nsfwImage from '../../assets/nsfw.jpg' +import fileTypeService from '../../services/file_type/file_type.service.js' const Attachment = { props: [ @@ -9,21 +10,7 @@ const Attachment = { data: () => ({ nsfwImage }), computed: { type () { - let type = 'unknown' - - if (this.attachment.mimetype.match(/text\/html/)) { - type = 'html' - } - - if (this.attachment.mimetype.match(/image/)) { - type = 'image' - } - - if (this.attachment.mimetype.match(/video\/(webm|mp4)/)) { - type = 'video' - }; - - return type + return fileTypeService.fileType(this.attachment.mimetype) } }, methods: { diff --git a/src/components/post_status_form/post_status_form.js b/src/components/post_status_form/post_status_form.js index 58c11fb9..60698e6e 100644 --- a/src/components/post_status_form/post_status_form.js +++ b/src/components/post_status_form/post_status_form.js @@ -1,5 +1,6 @@ import statusPoster from '../../services/status_poster/status_poster.service.js' import MediaUpload from '../media_upload/media_upload.vue' +import fileTypeService from '../../services/file_type/file_type.service.js' import { reject, map, uniqBy } from 'lodash' @@ -67,6 +68,9 @@ const PostStatusForm = { }, enableSubmit () { this.submitDisabled = false + }, + type (fileInfo) { + return fileTypeService.fileType(fileInfo.mimetype) } } } diff --git a/src/components/post_status_form/post_status_form.vue b/src/components/post_status_form/post_status_form.vue index 3709a6f6..a935a984 100644 --- a/src/components/post_status_form/post_status_form.vue +++ b/src/components/post_status_form/post_status_form.vue @@ -6,7 +6,7 @@
- +
-- cgit v1.2.3-70-g09d2