From b7277bc291cc6161dbdc9ac3953e230fcab150ad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miroslav=20=C5=A0ediv=C3=BD?= Date: Tue, 3 May 2022 21:56:21 +0200 Subject: [PATCH] catch client clipboard errors. --- src/component/internal/messages.ts | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/component/internal/messages.ts b/src/component/internal/messages.ts index 3806498d..9c5c2da9 100644 --- a/src/component/internal/messages.ts +++ b/src/component/internal/messages.ts @@ -269,7 +269,18 @@ export class NekoMessages extends EventEmitter { protected [EVENT.CLIPBOARD_UPDATED]({ text }: message.ClipboardData) { this._localLog.debug(`EVENT.CLIPBOARD_UPDATED`) 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) }