Skip to content

Commit

Permalink
Clipboard: Don't throw exception on a duplicated command from user.
Browse files Browse the repository at this point in the history
Or it falls into catch block and disables the navigatorClipboardWrite.

Signed-off-by: Gökay Şatır <gokaysatir@collabora.com>
Change-Id: I9617ad2f28401f197ed7c32f4c0eeb1822d632ad
  • Loading branch information
gokaysatir committed Nov 22, 2024
1 parent 21b132f commit d09dee6
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions browser/src/map/Clipboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -827,12 +827,13 @@ L.Clipboard = L.Class.extend({

_sendCommandAndWaitForCompletion: function(command) {
if (command !== '.uno:Copy' && command !== '.uno:Cut') {
throw `_sendCommandAndWaitForCompletion was called with '${command}', but anything except Copy or Cut will never complete`;
console.error(`_sendCommandAndWaitForCompletion was called with '${command}', but anything except Copy or Cut will never complete`);
return null;
}

if (this._commandCompletion.length > 0) {
throw 'Already have ' + this._commandCompletion.length +
' pending clipboard command(s)';
console.warn('Already have ' + this._commandCompletion.length + ' pending clipboard command(s)');
return null;
}

app.socket.sendMessage('uno ' + command);
Expand Down Expand Up @@ -870,7 +871,10 @@ L.Clipboard = L.Class.extend({

_asyncAttemptNavigatorClipboardWrite: async function() {
const command = this._unoCommandForCopyCutPaste;
await this._sendCommandAndWaitForCompletion(command);
const check_ = await this._sendCommandAndWaitForCompletion(command);

if (check_ === null)
return; // Either wrong command or a pending event.

// This is sent down the websocket URL which can race with the
// web fetch - so first step is to wait for the result of
Expand Down

0 comments on commit d09dee6

Please sign in to comment.