Skip to content

Commit

Permalink
attachment data in contracts needs size field
Browse files Browse the repository at this point in the history
  • Loading branch information
SebinSong committed Nov 27, 2024
1 parent fac9a1b commit 6a7cd96
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 4 deletions.
4 changes: 3 additions & 1 deletion frontend/model/contracts/shared/types.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import {
objectOf, objectMaybeOf, arrayOf, unionOf, boolean,
object, string, stringMax, optional, number, mapOf, literalOf
object, string, stringMax, optional, number, mapOf, literalOf, numberRange
} from '~/frontend/model/contracts/misc/flowTyper.js'
import {
CHATROOM_TYPES,
Expand All @@ -19,6 +19,7 @@ import {
CHATROOM_NAME_LIMITS_IN_CHARS,
CHATROOM_DESCRIPTION_LIMITS_IN_CHARS
} from './constants.js'
import { CHAT_ATTACHMENT_SIZE_LIMIT } from '~/frontend/utils/constants.js'

// group.js related

Expand Down Expand Up @@ -67,6 +68,7 @@ export const messageType: any = objectMaybeOf({
attachments: arrayOf(objectOf({
name: string,
mimeType: string,
size: optional(numberRange(1, CHAT_ATTACHMENT_SIZE_LIMIT)),
dimension: optional(objectOf({
width: number,
height: number
Expand Down
1 change: 1 addition & 0 deletions frontend/views/containers/chatroom/SendArea.vue
Original file line number Diff line number Diff line change
Expand Up @@ -748,6 +748,7 @@ export default ({
url: fileUrl,
name: file.name,
mimeType: file.type || '',
size: fileSize,
downloadData: null // NOTE: we can tell if the attachment has been uploaded by seeing if this field is non-null.
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@

.c-non-image-file-info
.c-file-name.has-ellipsis {{ entry.name }}
.c-file-ext {{ fileExt(entry) }}
.c-file-ext-and-size
.c-file-ext {{ fileExt(entry) }}
.c-file-size(v-if='entry.size') {{ fileSize(entry) }}

.c-preview-img(v-else)
img(
Expand Down Expand Up @@ -154,6 +156,9 @@ export default {
fileExt ({ name }) {
return getFileExtension(name, true)
},
fileSize ({ size }) {
return size ? `${size} bytes` : ''
},
fileType ({ mimeType }) {
return getFileType(mimeType)
},
Expand Down Expand Up @@ -267,8 +272,16 @@ export default {
&.is-for-download {
padding: 0;
.c-preview-non-image .c-non-image-file-info {
width: calc(100% - 4rem);
.c-preview-non-image {
.c-non-image-file-info {
width: calc(100% - 4rem);
}
.c-file-ext-and-size {
display: flex;
flex-direction: row;
column-gap: 0.25rem;
}
}
.c-attachment-actions-wrapper {
Expand Down

0 comments on commit 6a7cd96

Please sign in to comment.