From 200394ec6cd21121cb14f2a334f0e8e399846f10 Mon Sep 17 00:00:00 2001 From: bordun Date: Mon, 30 Mar 2020 17:55:18 +0200 Subject: [PATCH] client: allow specifying client id via url options --- CHANGELOG.md | 4 +++- src/client/ipc/index.js | 10 +++++++++- src/client/stacktrace.js | 4 +++- 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index cefe3418..fff01498 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -32,7 +32,7 @@ - allow copying tabs (to tab containers only) - shared clipboard accross all clients - prevent interaction with widgets when `shift` or `ctrl` is held - - ensure @{} bindings are always updated upon edition + - ensure @{} bindings are always updated upon edition - widget changes @@ -101,6 +101,8 @@ - custom module - `settings.read(name)`: `name` is now the long name of command-line options (not a camelCased one) + - `receive()`: optional last argument to pass extra options such as `clientId` + - client id persist upon page refresh and can be set manually with the client url option `id` - launcher diff --git a/src/client/ipc/index.js b/src/client/ipc/index.js index 67282892..18c8fda2 100644 --- a/src/client/ipc/index.js +++ b/src/client/ipc/index.js @@ -1,8 +1,16 @@ var EventEmitter = require('../events/event-emitter'), - uuid = require('nanoid/generate')('0123456789abcdefghijklmnopqrstuvwxyABCDEFGHIJKLMNOPQRSTUVWXYZ', 10), + nanoid = require('nanoid/generate'), uuid, notifications, locales +var localUuid = ENV.id || sessionStorage.getItem('osc.uuid') +if (localUuid) { + uuid = localUuid +} else { + uuid = nanoid('0123456789abcdefghijklmnopqrstuvwxyABCDEFGHIJKLMNOPQRSTUVWXYZ', 10) + sessionStorage.setItem('osc.uuid', uuid) +} + setTimeout(()=>{ notifications = require('../ui/notifications') locales = require('../locales') diff --git a/src/client/stacktrace.js b/src/client/stacktrace.js index 86067d7d..ecc60259 100644 --- a/src/client/stacktrace.js +++ b/src/client/stacktrace.js @@ -1,8 +1,10 @@ var StackTrace = require('stacktrace-js'), - ipc = require('./ipc') + ipc window.onerror = function(msg,url,row,col, error) { + if (!ipc) ipc = require('./ipc') + StackTrace.fromError(error).then((stackframes)=>{ var stringifiedStack = stackframes.filter((sf)=>{