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

5
app/reducers/ipc.js

@ -1,5 +1,5 @@
import createIpc from 'redux-electron-ipc' 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 { receiveInfo } from './info'
import { receiveAddress } from './address' import { receiveAddress } from './address'
import { receiveCryptocurrency } from './ticker' import { receiveCryptocurrency } from './ticker'
@ -40,7 +40,8 @@ const ipc = createIpc({
lndSyncing, lndSyncing,
lndSynced, lndSynced,
lndStdout, lndStdout,
grpcStarted, grpcDisconnected,
grpcConnected,
receiveInfo, 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 GET_BLOCK_HEIGHT = 'GET_BLOCK_HEIGHT'
export const RECEIVE_BLOCK_HEIGHT = 'RECEIVE_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 // Actions
@ -33,10 +34,9 @@ export const lndSynced = () => (dispatch) => {
dispatch({ type: STOP_SYNCING }) dispatch({ type: STOP_SYNCING })
} }
export const grpcStarted = () => (dispatch) => { export const grpcDisconnected = () => (dispatch) => dispatch({ type: GRPC_DISCONNECTED })
console.log('hello????')
dispatch({ type: GRPC_STARTED }) export const grpcConnected = () => (dispatch) => dispatch({ type: GRPC_CONNECTED })
}
// Receive IPC event for LND streaming a line // Receive IPC event for LND streaming a line
export const lndStdout = (event, line) => dispatch => { export const lndStdout = (event, line) => dispatch => {
@ -89,7 +89,8 @@ const ACTION_HANDLERS = {
[GET_BLOCK_HEIGHT]: state => ({ ...state, fetchingBlockHeight: true }), [GET_BLOCK_HEIGHT]: state => ({ ...state, fetchingBlockHeight: true }),
[RECEIVE_BLOCK_HEIGHT]: (state, { blockHeight }) => ({ ...state, blockHeight, fetchingBlockHeight: false }), [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 = { const initialState = {
syncing: false, syncing: false,
grpcStarted: false, grpcStarted: true,
fetchingBlockHeight: false, fetchingBlockHeight: false,
lines: [], lines: [],
blockHeight: 0, blockHeight: 0,

Loading…
Cancel
Save