Browse Source

fix(grpcConnected): cant have that set to false by default

renovate/lint-staged-8.x
Jack Mallers 7 years ago
parent
commit
b95d43934c
  1. 32
      app/main.dev.js
  2. 5
      app/reducers/ipc.js
  3. 15
      app/reducers/lnd.js

32
app/main.dev.js

@ -26,6 +26,9 @@ let mainWindow = null
let didFinishLoad = false
let startedSync = false
let sentGrpcDisconnect = false
let certPath
let certInterval
@ -108,6 +111,7 @@ app.on('ready', async () => {
const menuBuilder = new MenuBuilder(mainWindow);
menuBuilder.buildMenu()
sendGrpcDisconnected()
// Check to see if and LND process is running
lookup({ command: 'lnd' }, (err, results) => {
// There was an error checking for the LND process
@ -153,7 +157,6 @@ app.on('open-url', function (event, url) {
})
// Starts the LND node
// export const startLnd = (plat, certPath, mainWindow, startGrpc, sendLndSynced) => {
export const startLnd = () => {
const lndPath = path.join(__dirname, '..', 'resources', 'bin', plat, plat === 'win32' ? 'lnd.exe' : 'lnd')
@ -220,7 +223,7 @@ const startGrpc = () => {
lndMethods(event, msg, data)
})
sendGrpcStarted()
sendGrpcConnected()
})
}
@ -230,6 +233,8 @@ const sendLndSyncing = () => {
if (didFinishLoad) {
clearInterval(sendLndSyncingInterval)
console.log('SENDING SYNCING')
startedSync = true
mainWindow.webContents.send('lndSyncing')
}
}, 1000)
@ -238,21 +243,34 @@ const sendLndSyncing = () => {
// Send the front end event letting them know LND is synced to the blockchain
const sendLndSynced = () => {
let sendLndSyncedInterval = setInterval(() => {
if (didFinishLoad) {
if (didFinishLoad && startedSync) {
clearInterval(sendLndSyncedInterval)
console.log('SENDING SYNCED')
mainWindow.webContents.send('lndSynced')
}
}, 1000)
}
// Send the front end event letting them know the gRPC connection has started
const sendGrpcStarted = () => {
let sendGrpcStartedInterval = setInterval(() => {
const sendGrpcDisconnected = () => {
let sendGrpcDisonnectedInterval = setInterval(() => {
if (didFinishLoad) {
clearInterval(sendGrpcStartedInterval)
clearInterval(sendGrpcDisonnectedInterval)
sentGrpcDisconnect = true
mainWindow.webContents.send('grpcDisconnected')
}
}, 1000)
}
// Send the front end event letting them know the gRPC connection has started
const sendGrpcConnected = () => {
let sendGrpcConnectedInterval = setInterval(() => {
if (didFinishLoad && sentGrpcDisconnect) {
clearInterval(sendGrpcConnectedInterval)
mainWindow.webContents.send('grpcStarted')
mainWindow.webContents.send('grpcConnected')
}
}, 1000)
}

5
app/reducers/ipc.js

@ -1,5 +1,5 @@
import createIpc from 'redux-electron-ipc'
import { lndSyncing, lndSynced, lndStdout, grpcStarted } from './lnd'
import { lndSyncing, lndSynced, lndStdout, grpcDisconnected, grpcConnected } from './lnd'
import { receiveInfo } from './info'
import { receiveAddress } from './address'
import { receiveCryptocurrency } from './ticker'
@ -40,7 +40,8 @@ const ipc = createIpc({
lndSyncing,
lndSynced,
lndStdout,
grpcStarted,
grpcDisconnected,
grpcConnected,
receiveInfo,

15
app/reducers/lnd.js

@ -14,7 +14,8 @@ export const RECEIVE_LINE = 'RECEIVE_LINE'
export const GET_BLOCK_HEIGHT = 'GET_BLOCK_HEIGHT'
export const RECEIVE_BLOCK_HEIGHT = 'RECEIVE_BLOCK_HEIGHT'
export const GRPC_STARTED = 'GRPC_STARTED'
export const GRPC_DISCONNECTED = 'GRPC_DISCONNECTED'
export const GRPC_CONNECTED = 'GRPC_CONNECTED'
// ------------------------------------
// Actions
@ -33,10 +34,9 @@ export const lndSynced = () => (dispatch) => {
dispatch({ type: STOP_SYNCING })
}
export const grpcStarted = () => (dispatch) => {
console.log('hello????')
dispatch({ type: GRPC_STARTED })
}
export const grpcDisconnected = () => (dispatch) => dispatch({ type: GRPC_DISCONNECTED })
export const grpcConnected = () => (dispatch) => dispatch({ type: GRPC_CONNECTED })
// Receive IPC event for LND streaming a line
export const lndStdout = (event, line) => dispatch => {
@ -89,7 +89,8 @@ const ACTION_HANDLERS = {
[GET_BLOCK_HEIGHT]: state => ({ ...state, fetchingBlockHeight: true }),
[RECEIVE_BLOCK_HEIGHT]: (state, { blockHeight }) => ({ ...state, blockHeight, fetchingBlockHeight: false }),
[GRPC_STARTED]: state => ({ ...state, grpcStarted: true })
[GRPC_DISCONNECTED]: state => ({ ...state, grpcStarted: false }),
[GRPC_CONNECTED]: state => ({ ...state, grpcStarted: true })
}
// ------------------------------------
@ -97,7 +98,7 @@ const ACTION_HANDLERS = {
// ------------------------------------
const initialState = {
syncing: false,
grpcStarted: false,
grpcStarted: true,
fetchingBlockHeight: false,
lines: [],
blockHeight: 0,

Loading…
Cancel
Save