Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
async onResize(event){
console.log("eve",event)
if(!event.old_w && !this.w){
let maxBounds
if(ipc.sendSync){
maxBounds = JSON.parse(ipc.sendSync('get-sync-main-state','maxState'))
}
else{
maxBounds = await new Promise(r=>{
const key = Math.random().toString()
ipc.send('get-sync-main-states',['maxState'],key)
ipc.once(`get-sync-main-states-reply_${key}`, (e,result) => r(result[0]))
})
}
event.old_w = maxBounds.maximize ? maxBounds.maxWidth : maxBounds.width
event.old_h = maxBounds.maximize ? maxBounds.maxHeight : maxBounds.height
}
if (this.props.allowResize) {
const rect = this.splitPane.getBoundingClientRect()
const wh = {width:rect.width, height:rect.height}
console.log(event,this.state.size,wh)
// if(wh.width == this.state.width && wh.height == this.state.height) return
import ua from 'universal-analytics';
import uuid from 'uuid/v4';
const { ipcRenderer, remote } = require('electron');
const { app } = remote;
const appVersion = app.getVersion();
const appName = app.getName();
const log = require('electron-log');
const ua_ID = 'UA-104941988-1';
// get this from saved data or create if it doesn't exist and save it.
let userUuid = ipcRenderer.sendSync('getFromStore', 'uuid');
if (userUuid.length < 10) {
userUuid = uuid();
ipcRenderer.sendSync('setToStore', 'uuid', userUuid);
}
const visitor = ua(ua_ID, userUuid);
function errorHandler(err) {
if (err) {
log.error(`Error with google analytics: ${err}`);
}
}
// support disabling analytics
export const screenview = screenName => {
if (ipcRenderer.sendSync('getFromStore', 'gaEnabled')) {
visitor.screenview(screenName, appName, appVersion, errorHandler).send();
link(context);
}
};
}
return debuglog(name);
};
systemVariables = _.keys(context);
if(process.platform !== 'win32' && context.process.env.PATH.indexOf() == -1) {
context.process.env.PATH += ':/usr/local/bin';
}
// Auto complete issue because when useGlobal is set to false
let {ipcRenderer} = require('electron');
const globalNames = ipcRenderer.sendSync('application:global-context-names');
missingGlobals = globalNames.filter(n => !context[n]);
systemVariables = systemVariables.concat(missingGlobals);
// TODO: revisit
// commented because of #101 issue
// try {
// let code =`
// (() => {
// var poly = require('core-js/shim');
// Object.getOwnPropertyNames(poly).forEach(function(obj) {
// if(!this[obj]) { this[obj] = poly[obj]; }
// else {
// Object.getOwnPropertyNames(poly[obj]).forEach(function(p) {
// if(poly[obj][p] && !this[obj][p]) {
ipcRenderer.sendSync('saveDXData', username, password, port, rpcIP);
}
}
ipcRenderer.sendSync('saveSelected', [...selected]);
} else {
saveConfs(filtered);
}
}
if(!addingWallets && !updatingWallets) {
const block = filtered
.find(w => w.abbr === 'BLOCK');
const { username, password } = block;
const port = state.get('rpcPort');
const rpcIP = state.get('rpcIP');
ipcRenderer.sendSync('saveDXData', username, password, port, rpcIP);
ipcRenderer.sendSync('saveSelected', [...selectedWallets]);
}
}
}
router.goTo(route.CONFIGURATION_COMPLETE);
} catch(err) {
console.error(err);
}
});
}
_ensureConnected () {
if (!this[privConnected]) {
ipcRenderer.send(WB_POWER_MONITOR_CONNECT_EVENTS)
ipcRenderer.on(WB_POWER_MONITOR_EVENT, this._handlePowerMonitorEvent)
this[privState] = ipcRenderer.sendSync(WB_GET_POWER_MONITOR_STATE_SYNC)
this[privConnected] = true
}
return this
}
var getData = function () {
var data = {}
data.path = ipc.sendSync('getUserDataPath', null)
data.contents = JSON.parse(fs.readFileSync(data.path))
return data
}
$('#js-continueBtn').on('click', async function(e) {
try {
e.preventDefault();
const wallets = state.get('wallets');
const configurationType = state.get('configurationType');
const addingWallets = configurationType === configurationTypes.ADD_NEW_WALLETS;
const updatingWallets = configurationType === configurationTypes.UPDATE_WALLETS;
if(configurationType === configurationTypes.UPDATE_RPC_SETTINGS) {
const port = state.get('rpcPort');
const rpcIP = state.get('rpcIP');
const username = state.get('username');
const password = state.get('password');
ipcRenderer.sendSync('saveDXData', username, password, port, rpcIP);
} else {
if(state.get('quickSetup')) {
const addAbbrToVersion = state.get('addAbbrToVersion');
const updateAbbrToVersion = state.get('updateAbbrToVersion');
let selectedWallets = state.get('selectedWallets');
const skipList = state.get('skipList');
const filtered = wallets
.filter(w => addingWallets ? addAbbrToVersion.has(w.abbr) : updatingWallets ? updateAbbrToVersion.has(w.abbr) : !skipList.has(w.abbr))
.filter(w => addingWallets ? w.versions.includes(addAbbrToVersion.get(w.abbr)) : updatingWallets ? w.versions.includes(updateAbbrToVersion.get(w.abbr)) : selectedWallets.has(w.versionId))
.map(w => {
if(updatingWallets && w.abbr === 'BLOCK') {
return w.set({
username: ipcRenderer.sendSync('getUser'),
password: ipcRenderer.sendSync('getPassword')
});
install: () => {},
},
app: {
isInstalled: false,
getIsInstalled: () => {
return false;
},
getDetails: () => {},
installState: () => {},
},
};
})();
const setImmediateTemp: any = setImmediate;
const extensions: { [key: string]: IpcExtension } = ipcRenderer.sendSync(
`get-extensions-${sessionId}`,
);
process.once('loaded', () => {
global.setImmediate = setImmediateTemp;
if (blackList.find(x => window.location.href.startsWith(x))) return;
Object.keys(extensions).forEach(key => {
const extension = extensions[key];
if (!extension.contentScripts) return;
extension.contentScripts.forEach(script => {
injectContentScript(script, extension, sessionId);
});
componentWillReceiveProps(nextProps) {
if (this.props.item && nextProps.item && this.props.item.id == nextProps.item.id) return;
clearInterval(this.state.intervalId);
this.client = new NicoliveAPI(`user_session=${ipcRenderer.sendSync('RequestGetCookie')}`);
const {webview} = this.refs;
webview.innerHTML = ''
const wv = webview.querySelector('webview');
wv.src = nextProps.item ? nextProps.item.url : '';
wv.plugins = true;
wv.addEventListener('did-start-loading', () => {
if (process.env.NODE_ENV === 'development') wv.openDevTools();
});
wv.addEventListener('did-finish-load', () => {
this.client.getPlayerStatus(nextProps.item.id)
.then(status => {
this.setState({intervalId: setInterval(() => this.checkLiveStatus(nextProps.item.id), 3 * 60 * 1000)})
AppLocator.context.useCase(UpdateLiveUseCase.create()).execute(nextProps.item.id, status)
})
.catch(err => {
const promptSubmit = () => {
const dataEl = document.getElementById('data');
let data = null;
if(promptOptions.type === 'input') {
data = dataEl.value
} else if(promptOptions.type === 'select') {
if(promptOptions.selectMultiple) {
data = dataEl.querySelectorAll('option[selected]').map((o) => o.getAttribute('value'));
} else {
data = dataEl.value;
}
}
ipcRenderer.sendSync('prompt-post-data:'+promptId, data);
}