Skip to content
This repository has been archived by the owner on Nov 17, 2023. It is now read-only.

Commit

Permalink
fix: add intl support to system notifications
Browse files Browse the repository at this point in the history
  • Loading branch information
korhaliv committed Aug 22, 2019

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
1 parent 87711b5 commit 369188e
Showing 2 changed files with 14 additions and 10 deletions.
12 changes: 7 additions & 5 deletions renderer/reducers/neutrino.js
Original file line number Diff line number Diff line change
@@ -2,9 +2,11 @@ import { send } from 'redux-electron-ipc'
import { createSelector } from 'reselect'
import { proxyValue } from 'comlinkjs'
import { neutrino } from 'workers'
import { getIntl } from '@zap/i18n'
import { showSystemNotification } from '@zap/utils/notifications'
import { setHasSynced } from './info'
import createReducer from './utils/createReducer'
import messages from './messages'

// ------------------------------------
// Initial State
@@ -377,9 +379,7 @@ export const neutrinoRecoveryHeight = height => ({
* @returns {Function} Thunk
*/
export const neutrinoSyncStatus = status => async dispatch => {
const notifTitle = 'Lightning Node Synced'
const notifBody = "Visa who? You're your own payment processor now!"

const intl = getIntl()
switch (status) {
case 'NEUTRINO_CHAIN_SYNC_PENDING':
dispatch({ type: SET_SYNC_STATUS_PENDING })
@@ -398,9 +398,11 @@ export const neutrinoSyncStatus = status => async dispatch => {

// Persist the fact that the wallet has been synced at least once.
dispatch(setHasSynced(true))

// HTML 5 desktop notification for sync completion
showSystemNotification(notifTitle, notifBody)
showSystemNotification(
intl.formatMessage(messages.neutrtino_synced_title),
intl.formatMessage(messages.neutrtino_synced_body)
)
break
}
}
12 changes: 7 additions & 5 deletions renderer/reducers/transaction.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { createSelector } from 'reselect'
import { showSystemNotification } from '@zap/utils/notifications'
import { convert } from '@zap/utils/btc'
import { getIntl } from '@zap/i18n'
import delay from '@zap/utils/delay'
import errorToUserFriendly from '@zap/utils/userFriendlyErrors'
import { grpc } from 'workers'
@@ -9,6 +10,7 @@ import { fetchBalance } from './balance'
import { fetchChannels, channelsSelectors, getChannelData } from './channels'
import { settingsSelectors } from './settings'
import createReducer from './utils/createReducer'
import messages from './messages'

// ------------------------------------
// Initial State
@@ -227,18 +229,18 @@ export const receiveTransactionData = transaction => (dispatch, getState) => {

// fetch updated channels
dispatch(fetchChannels())

const intl = getIntl()
// HTML 5 desktop notification for the new transaction
if (transaction.received) {
showSystemNotification(
'On-chain Transaction Received!',
"Lucky you, you just received a new on-chain transaction. I'm jealous."
intl.formatMessage(messages.transaction_received_title),
intl.formatMessage(messages.transaction_received_body)
)
dispatch(newAddress(settingsSelectors.currentConfig(state).address)) // Generate a new address
} else {
showSystemNotification(
'On-chain Transaction Sent!',
"Hate to see 'em go but love to watch 'em leave. Your on-chain transaction successfully sent."
intl.formatMessage(messages.transaction_sent_title),
intl.formatMessage(messages.transaction_sent_body)
)
}
}

0 comments on commit 369188e

Please sign in to comment.