Skip to content

Commit 593f043

Browse files
committed
(fix) heavy files are not displayed immediatly
1 parent c608c17 commit 593f043

File tree

5 files changed

+35
-9
lines changed

5 files changed

+35
-9
lines changed

src/lib/Message/MessageFiles/MessageFile/MessageFile.scss

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,6 @@
66
cursor: pointer;
77
}
88

9-
.vac-image-loading {
10-
filter: blur(3px);
11-
}
12-
139
.vac-image-buttons {
1410
position: absolute;
1511
width: 100%;

src/lib/Message/MessageFiles/MessageFile/MessageFile.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
<div
2626
class="vac-message-image"
2727
:class="{
28-
'vac-image-loading':
28+
'vac-blur-loading':
2929
isImageLoading && message.senderId === currentUserId
3030
}"
3131
:style="{

src/lib/Room/Room.vue

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1137,17 +1137,26 @@ export default {
11371137
11381138
Array.from(files).forEach(async file => {
11391139
const fileURL = URL.createObjectURL(file)
1140-
const blobFile = await fetch(fileURL).then(res => res.blob())
11411140
const typeIndex = file.name.lastIndexOf('.')
11421141
11431142
this.files.push({
1144-
blob: blobFile,
1143+
loading: true,
11451144
name: file.name.substring(0, typeIndex),
11461145
size: file.size,
11471146
type: file.type,
11481147
extension: file.name.substring(typeIndex + 1),
11491148
localUrl: fileURL
11501149
})
1150+
1151+
const blobFile = await fetch(fileURL).then(res => res.blob())
1152+
1153+
let loadedFile = this.files.find(file => file.localUrl === fileURL)
1154+
1155+
if (loadedFile) {
1156+
loadedFile.blob = blobFile
1157+
loadedFile.loading = false
1158+
delete loadedFile.loading
1159+
}
11511160
})
11521161
11531162
setTimeout(() => (this.fileDialog = false), 500)

src/lib/Room/RoomFiles/RoomFile/RoomFile.vue

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
<template>
22
<div class="vac-room-file-container">
3+
<loader :show="file.loading">
4+
<template v-for="(idx, name) in $scopedSlots" #[name]="data">
5+
<slot :name="name" v-bind="data" />
6+
</template>
7+
</loader>
8+
39
<div
410
class="vac-svg-button vac-icon-remove"
511
@click="$emit('remove-file', index)"
@@ -12,16 +18,25 @@
1218
<div
1319
v-if="isImage"
1420
class="vac-message-image"
21+
:class="{ 'vac-blur-loading': file.loading }"
1522
:style="{
1623
'background-image': `url('${file.localUrl || file.url}')`
1724
}"
1825
/>
1926

20-
<video v-else-if="isVideo" controls>
27+
<video
28+
v-else-if="isVideo"
29+
controls
30+
:class="{ 'vac-blur-loading': file.loading }"
31+
>
2132
<source :src="file.localUrl || file.url" />
2233
</video>
2334

24-
<div v-else class="vac-file-container">
35+
<div
36+
v-else
37+
class="vac-file-container"
38+
:class="{ 'vac-blur-loading': file.loading }"
39+
>
2540
<div>
2641
<slot name="file-icon">
2742
<svg-icon name="file" />
@@ -38,13 +53,15 @@
3853
</template>
3954

4055
<script>
56+
import Loader from '../../../../components/Loader/Loader'
4157
import SvgIcon from '../../../../components/SvgIcon/SvgIcon'
4258
4359
const { isImageFile, isVideoFile } = require('../../../../utils/media-file')
4460
4561
export default {
4662
name: 'RoomFiles',
4763
components: {
64+
Loader,
4865
SvgIcon
4966
},
5067

src/styles/helper.scss

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,10 @@
6060
border-radius: 50%;
6161
}
6262

63+
.vac-blur-loading {
64+
filter: blur(3px);
65+
}
66+
6367
.vac-badge-counter {
6468
height: 13px;
6569
width: auto;

0 commit comments

Comments
 (0)