mirror of
https://github.com/quine-global/hyper.git
synced 2026-01-12 20:18:41 -09:00
🔥 Use uuid (#393)
This commit is contained in:
parent
cb84548623
commit
c88c93a622
3 changed files with 16 additions and 18 deletions
|
|
@ -1,7 +1,7 @@
|
|||
const { app, BrowserWindow, shell, Menu } = require('electron');
|
||||
const createRPC = require('./rpc');
|
||||
const createMenu = require('./menu');
|
||||
const genUid = require('uid2');
|
||||
const uuid = require('uuid');
|
||||
const { resolve } = require('path');
|
||||
const isDev = require('electron-is-dev');
|
||||
const AutoUpdater = require('./auto-updater');
|
||||
|
|
@ -251,8 +251,5 @@ app.on('ready', () => {
|
|||
});
|
||||
|
||||
function initSession (opts, fn) {
|
||||
genUid(20, (err, uid) => {
|
||||
if (err) throw err;
|
||||
fn(uid, new Session(opts));
|
||||
});
|
||||
fn(uuid.v4(), new Session(opts));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@
|
|||
"mkdirp": "0.5.1",
|
||||
"ms": "0.7.1",
|
||||
"shell-env": "0.1.2",
|
||||
"uid2": "0.0.3"
|
||||
"uuid": "^2.0.2"
|
||||
},
|
||||
"eslintConfig": {
|
||||
"extends": "standard",
|
||||
|
|
|
|||
25
app/rpc.js
25
app/rpc.js
|
|
@ -1,6 +1,6 @@
|
|||
const { EventEmitter } = require('events');
|
||||
const { ipcMain } = require('electron');
|
||||
const genUid = require('uid2');
|
||||
const uuid = require('uuid');
|
||||
|
||||
class Server {
|
||||
|
||||
|
|
@ -8,18 +8,19 @@ class Server {
|
|||
this.win = win;
|
||||
this.ipcListener = this.ipcListener.bind(this);
|
||||
this.emitter = new EventEmitter();
|
||||
genUid(10, (err, uid) => {
|
||||
if (this.destroyed) return;
|
||||
if (err) return this.emitter.emit('error', err);
|
||||
this.id = uid;
|
||||
ipcMain.on(uid, this.ipcListener);
|
||||
|
||||
// we intentionally subscribe to `on` instead of `once`
|
||||
// to support reloading the window and re-initializing
|
||||
// the channel
|
||||
this.wc.on('did-finish-load', () => {
|
||||
this.wc.send('init', uid);
|
||||
});
|
||||
if (this.destroyed) return;
|
||||
|
||||
const uid = uuid.v4();
|
||||
this.id = uid;
|
||||
|
||||
ipcMain.on(uid, this.ipcListener);
|
||||
|
||||
// we intentionally subscribe to `on` instead of `once`
|
||||
// to support reloading the window and re-initializing
|
||||
// the channel
|
||||
this.wc.on('did-finish-load', () => {
|
||||
this.wc.send('init', uid);
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue