mirror of
https://github.com/Ocelot-Social-Community/Ocelot-Social.git
synced 2026-04-06 01:25:38 +00:00
same durations
This commit is contained in:
parent
d379e49e51
commit
bda23a840e
@ -2,6 +2,7 @@ export default {
|
||||
url: { primary: true, type: 'string', uri: { allowRelative: true } },
|
||||
name: { type: 'string' },
|
||||
type: { type: 'string' },
|
||||
duration: { type: 'number', allow: [null] },
|
||||
createdAt: { type: 'string', isoDate: true, default: () => new Date().toISOString() },
|
||||
updatedAt: { type: 'string', isoDate: true, default: () => new Date().toISOString() },
|
||||
}
|
||||
|
||||
@ -29,12 +29,14 @@ export interface FileInput {
|
||||
upload?: Promise<FileUpload>
|
||||
name: string
|
||||
type: string
|
||||
duration?: number | null
|
||||
}
|
||||
|
||||
export interface File {
|
||||
url: string
|
||||
name: string
|
||||
type: string
|
||||
duration?: number | null
|
||||
}
|
||||
|
||||
export interface Attachments {
|
||||
@ -143,8 +145,8 @@ export const attachments = (config: S3Config) => {
|
||||
uniqueFilename,
|
||||
})
|
||||
|
||||
const { name, type } = fileInput
|
||||
const file = { url, name, type, ...fileAttributes }
|
||||
const { name, type, duration } = fileInput
|
||||
const file = { url, name, type, ...(duration != null && { duration }), ...fileAttributes }
|
||||
// const mimeType = uploadFile.mimetype.split('/')[0]
|
||||
// const nodeType = `Mime${mimeType.replace(/^./, mimeType[0].toUpperCase())}`
|
||||
// CREATE (file:${['File', nodeType].filter(Boolean).join(':')})
|
||||
|
||||
@ -2,9 +2,9 @@ type File {
|
||||
url: ID!
|
||||
name: String
|
||||
type: String
|
||||
duration: Float
|
||||
# size: Int
|
||||
# audio: Boolean
|
||||
# duration: Float
|
||||
# preview: String
|
||||
# progress: Int
|
||||
}
|
||||
@ -13,4 +13,5 @@ input FileInput {
|
||||
upload: Upload
|
||||
name: String
|
||||
type: String
|
||||
duration: Float
|
||||
}
|
||||
|
||||
@ -314,6 +314,17 @@ export default {
|
||||
commitUnreadRoomCount: 'chat/UPDATE_ROOM_COUNT',
|
||||
}),
|
||||
|
||||
lastMessageFiles(files) {
|
||||
if (!files?.length) return undefined
|
||||
return files.map((f) => {
|
||||
if (f.extension) return f
|
||||
const dotIndex = f.name?.lastIndexOf('.')
|
||||
const ext = dotIndex > 0 ? f.name.substring(dotIndex + 1) : f.type?.split('/').pop()
|
||||
const name = dotIndex > 0 ? f.name.substring(0, dotIndex) : f.name
|
||||
return { ...f, name, extension: ext }
|
||||
})
|
||||
},
|
||||
|
||||
markAsSeen(messageIds) {
|
||||
if (!messageIds.length || !this.selectedRoom) return
|
||||
const room = this.selectedRoom
|
||||
@ -635,6 +646,7 @@ export default {
|
||||
changedRoom.lastMessage = {
|
||||
...msg,
|
||||
content: (msg.content || '').trim().substring(0, 30),
|
||||
files: this.lastMessageFiles(msg.files),
|
||||
}
|
||||
changedRoom.lastMessageAt = msg.date
|
||||
changedRoom.index = new Date().toISOString()
|
||||
@ -713,6 +725,7 @@ export default {
|
||||
),
|
||||
name: file.name,
|
||||
type: file.type,
|
||||
...(file.duration != null && { duration: file.duration }),
|
||||
}))
|
||||
: null
|
||||
|
||||
@ -742,6 +755,7 @@ export default {
|
||||
if (roomIndex !== -1) {
|
||||
const changedRoom = { ...this.rooms[roomIndex] }
|
||||
changedRoom.lastMessage.content = (content || '').trim().substring(0, 30)
|
||||
changedRoom.lastMessage.files = this.lastMessageFiles(files)
|
||||
changedRoom.index = new Date().toISOString()
|
||||
this.rooms = [changedRoom, ...this.rooms.filter((r) => r.id !== roomId)]
|
||||
this.$nextTick(() => {
|
||||
@ -827,6 +841,7 @@ export default {
|
||||
? {
|
||||
...room.lastMessage,
|
||||
content: (room.lastMessage?.content || '').trim().substring(0, 30),
|
||||
files: this.lastMessageFiles(room.lastMessage?.files),
|
||||
}
|
||||
: { content: '' },
|
||||
users: room.users.map((u) => {
|
||||
|
||||
@ -26,6 +26,7 @@ export const createMessageMutation = () => {
|
||||
name
|
||||
#size
|
||||
type
|
||||
duration
|
||||
#preview
|
||||
}
|
||||
}
|
||||
@ -66,7 +67,7 @@ export const messageQuery = () => {
|
||||
#size
|
||||
type
|
||||
#audio
|
||||
#duration
|
||||
duration
|
||||
#preview
|
||||
}
|
||||
}
|
||||
@ -101,7 +102,7 @@ export const chatMessageAdded = () => {
|
||||
#size
|
||||
type
|
||||
#audio
|
||||
#duration
|
||||
duration
|
||||
#preview
|
||||
}
|
||||
}
|
||||
|
||||
@ -66,6 +66,12 @@ export const roomQuery = () => gql`
|
||||
saved
|
||||
distributed
|
||||
seen
|
||||
files {
|
||||
url
|
||||
name
|
||||
type
|
||||
duration
|
||||
}
|
||||
}
|
||||
users {
|
||||
_id
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user