add upload drop events.

This commit is contained in:
Miroslav Šedivý 2021-01-08 21:36:59 +01:00
parent aab2f389eb
commit dc5699e425
2 changed files with 17 additions and 2 deletions

View File

@ -9,6 +9,9 @@ import NekoState from '../types/state'
export interface NekoEvents { export interface NekoEvents {
['internal.websocket']: (state: 'connected' | 'connecting' | 'disconnected') => void ['internal.websocket']: (state: 'connected' | 'connecting' | 'disconnected') => void
['internal.webrtc']: (state: 'connected' | 'connecting' | 'disconnected') => void ['internal.webrtc']: (state: 'connected' | 'connecting' | 'disconnected') => void
['upload.drop.started']: () => void
['upload.drop.progress']: (progressEvent: ProgressEvent) => void
['upload.drop.finished']: (error: Error | null) => void
['system.disconnect']: (message: string) => void ['system.disconnect']: (message: string) => void
['member.created']: (id: string) => void ['member.created']: (id: string) => void
['member.deleted']: (id: string) => void ['member.deleted']: (id: string) => void

View File

@ -235,8 +235,20 @@
return this.api.members return this.api.members
} }
uploadDrop({ x, y, files }: { x: number; y: number; files: Array<Blob> }) { async uploadDrop({ x, y, files }: { x: number; y: number; files: Array<Blob> }) {
this.api.room.uploadDrop(x, y, files) try {
this.events.emit('upload.drop.started')
await this.api.room.uploadDrop(x, y, files, {
onUploadProgress: (progressEvent: ProgressEvent) => {
this.events.emit('upload.drop.progress', progressEvent)
},
})
this.events.emit('upload.drop.finished', null)
} catch (err) {
this.events.emit('upload.drop.finished', err)
}
} }
///////////////////////////// /////////////////////////////