mirror of
https://github.com/m1k1o/neko.git
synced 2024-07-24 14:40:50 +12:00
add upload drop events.
This commit is contained in:
parent
aab2f389eb
commit
dc5699e425
@ -9,6 +9,9 @@ import NekoState from '../types/state'
|
||||
export interface NekoEvents {
|
||||
['internal.websocket']: (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
|
||||
['member.created']: (id: string) => void
|
||||
['member.deleted']: (id: string) => void
|
||||
|
@ -235,8 +235,20 @@
|
||||
return this.api.members
|
||||
}
|
||||
|
||||
uploadDrop({ x, y, files }: { x: number; y: number; files: Array<Blob> }) {
|
||||
this.api.room.uploadDrop(x, y, files)
|
||||
async uploadDrop({ x, y, files }: { x: number; y: number; files: Array<Blob> }) {
|
||||
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)
|
||||
}
|
||||
}
|
||||
|
||||
/////////////////////////////
|
||||
|
Loading…
Reference in New Issue
Block a user