From 224a84d08250932fda1d2688392fceacca2c8ae0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miroslav=20=C5=A0ediv=C3=BD?= Date: Wed, 20 Jan 2021 23:59:32 +0100 Subject: [PATCH] add file chooser upload. --- src/component/internal/messages.ts | 22 ++++++++++++++++++++++ src/component/types/events.ts | 3 +++ 2 files changed, 25 insertions(+) diff --git a/src/component/internal/messages.ts b/src/component/internal/messages.ts index 1da36bd0..7200fe10 100644 --- a/src/component/internal/messages.ts +++ b/src/component/internal/messages.ts @@ -22,6 +22,9 @@ export interface NekoEvents { ['screen.updated']: (width: number, height: number, rate: number) => void ['clipboard.updated']: (text: string) => void ['broadcast.status']: (isActive: boolean, url: string | undefined) => void + ['file_chooser_dialog.requested']: () => void + ['file_chooser_dialog.overlay']: (id: string) => void + ['file_chooser_dialog.closed']: () => void } export class NekoMessages extends EventEmitter { @@ -173,4 +176,23 @@ export class NekoMessages extends EventEmitter { // TODO: Handle. this.emit('broadcast.status', is_active, url) } + + ///////////////////////////// + // FileChooserDialog Events + ///////////////////////////// + + protected [EVENT.FILE_CHOOSER_DIALOG_OPENED]({ id }: message.MemberID) { + this._log.debug('EVENT.FILE_CHOOSER_DIALOG_OPENED') + + if (id == this.state.member_id) { + this.emit('file_chooser_dialog.requested') + } else { + this.emit('file_chooser_dialog.overlay', id) + } + } + + protected [EVENT.FILE_CHOOSER_DIALOG_CLOSED]({ id }: message.MemberID) { + this._log.debug('EVENT.FILE_CHOOSER_DIALOG_CLOSED') + this.emit('file_chooser_dialog.closed') + } } diff --git a/src/component/types/events.ts b/src/component/types/events.ts index 3655e673..098a6210 100644 --- a/src/component/types/events.ts +++ b/src/component/types/events.ts @@ -31,3 +31,6 @@ export const KEYBOARD_MAP = 'keyboard/map' export const CURSOR_IMAGE = 'cursor/image' export const BORADCAST_STATUS = 'broadcast/status' + +export const FILE_CHOOSER_DIALOG_OPENED = 'file_chooser_dialog/opened' +export const FILE_CHOOSER_DIALOG_CLOSED = 'file_chooser_dialog/closed'