catch client clipboard errors.

This commit is contained in:
Miroslav Šedivý 2022-05-03 21:56:21 +02:00
parent 63cad4df72
commit b7277bc291

View File

@ -269,7 +269,18 @@ export class NekoMessages extends EventEmitter<NekoEvents> {
protected [EVENT.CLIPBOARD_UPDATED]({ text }: message.ClipboardData) { protected [EVENT.CLIPBOARD_UPDATED]({ text }: message.ClipboardData) {
this._localLog.debug(`EVENT.CLIPBOARD_UPDATED`) this._localLog.debug(`EVENT.CLIPBOARD_UPDATED`)
Vue.set(this._state.control, 'clipboard', { text }) Vue.set(this._state.control, 'clipboard', { text })
navigator.clipboard.writeText(text) // sync user's clipboard
try {
navigator.clipboard.writeText(text) // sync user's clipboard
} catch (error: any) {
this._remoteLog.warn(`unable to write text to client's clipboard`, {
error,
// works only for HTTPs
protocol: location.protocol,
clipboard: typeof navigator.clipboard,
})
}
this.emit('room.clipboard.updated', text) this.emit('room.clipboard.updated', text)
} }