Skip to content

Commit da9a2f5

Browse files
committed
(refacto) add VIDEO_TYPES constant
1 parent d6b505d commit da9a2f5

File tree

4 files changed

+6
-9
lines changed

4 files changed

+6
-9
lines changed

src/ChatWindow/FormatMessage.vue

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,11 +104,10 @@ export default {
104104
const slashIndex = message.value.lastIndexOf('/')
105105
if (slashIndex > index) index = -1
106106
107-
const imageTypes = IMAGE_TYPES
108107
const type = message.value.substring(index + 1, message.value.length)
109108
110109
const isMedia =
111-
index > 0 && imageTypes.some(t => type.toLowerCase().includes(t))
110+
index > 0 && IMAGE_TYPES.some(t => type.toLowerCase().includes(t))
112111
113112
if (isMedia) this.setImageSize(message)
114113

src/ChatWindow/Message.vue

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -492,9 +492,8 @@ export default {
492492
},
493493
checkImageType(file) {
494494
if (!file) return
495-
const imageTypes = IMAGE_TYPES
496495
const { type } = file
497-
return imageTypes.some(t => type.toLowerCase().includes(t))
496+
return IMAGE_TYPES.some(t => type.toLowerCase().includes(t))
498497
},
499498
checkImgLoad() {
500499
if (!this.checkImageFile()) return

src/ChatWindow/Room.vue

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -401,7 +401,7 @@ const { messagesValid } = require('../utils/roomValidation')
401401
const { detectMobile, iOSDevice } = require('../utils/mobileDetection')
402402
import filteredUsers from '../utils/filterItems'
403403
import typingText from '../utils/typingText'
404-
import { IMAGE_TYPES } from '../utils/constants'
404+
import { IMAGE_TYPES, VIDEO_TYPES } from '../utils/constants'
405405
406406
export default {
407407
name: 'room',
@@ -974,15 +974,13 @@ export default {
974974
},
975975
isImageCheck(file) {
976976
if (!file) return
977-
const imageTypes = IMAGE_TYPES
978977
const { type } = file
979-
return imageTypes.some(t => type.toLowerCase().includes(t))
978+
return IMAGE_TYPES.some(t => type.toLowerCase().includes(t))
980979
},
981980
isVideoCheck(file) {
982981
if (!file) return
983-
const videoTypes = ['video/mp4', 'video/ogg', 'video/webm']
984982
const { type } = file
985-
return videoTypes.some(t => type.toLowerCase().includes(t))
983+
return VIDEO_TYPES.some(t => type.toLowerCase().includes(t))
986984
},
987985
openFile({ message, action }) {
988986
this.$emit('open-file', { message, action })

src/utils/constants.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
export const IMAGE_TYPES = ['png', 'jpg', 'jpeg', 'svg', 'gif']
2+
export const VIDEO_TYPES = ['video/mp4', 'video/ogg', 'video/webm']

0 commit comments

Comments
 (0)