Skip to content
This repository has been archived by the owner on Dec 11, 2019. It is now read-only.

reset reconciliation time when publisher window is closed #4516

Merged
merged 2 commits into from
Oct 4, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 15 additions & 13 deletions app/ledger.js
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ const doAction = (action) => {
case appConstants.APP_CHANGE_SETTING:
switch (action.key) {
case settings.PAYMENTS_ENABLED:
initialize(action.value, 'changeSettingPaymentsEnabled')
initialize(action.value)
break
case settings.PAYMENTS_CONTRIBUTION_AMOUNT:
setPaymentInfo(action.value)
Expand Down Expand Up @@ -415,7 +415,7 @@ eventStore.addChangeListener(() => {
* module initialization
*/

var initialize = (paymentsEnabled, reason) => {
var initialize = (paymentsEnabled) => {
enable(paymentsEnabled)

// Check if relevant browser notifications should be shown every 15 minutes
Expand Down Expand Up @@ -458,17 +458,19 @@ var initialize = (paymentsEnabled, reason) => {
// Scenario: User enables Payments, disables it, waits 30+ days, then
// enables it again -> reconcileStamp is in the past.
// In this case reset reconcileStamp to the future.
if (reason === 'changeSettingPaymentsEnabled') {
let timeUntilReconcile = client.timeUntilReconcile()
if (typeof timeUntilReconcile === 'number' && timeUntilReconcile < 0) {
client.setTimeUntilReconcile(null, (_, stateResult) => {
if (!stateResult) {
return
}
ledgerInfo.reconcileStamp = stateResult.reconcileStamp
syncWriter(pathName(statePath), stateResult, () => {})
})
}
let timeUntilReconcile = client.timeUntilReconcile()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

as a result of this PR we can remove changeSettingPaymentsEnabled at ln 134 and the reason arg in this function initialize(paymentsEnabled,reason) (it was added to fix this)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

true. it is used only in one place. remove it?

let ledgerWindow = (synopsis.options.numFrames - 1) * synopsis.options.frameSize
if (typeof timeUntilReconcile === 'number' && timeUntilReconcile < -ledgerWindow) {
client.setTimeUntilReconcile(null, (err, stateResult) => {
if (err) return console.log('ledger setTimeUntilReconcile error: ' + err.toString())

if (!stateResult) {
return
}
getStateInfo(stateResult)

syncWriter(pathName(statePath), stateResult, () => {})
})
}
} catch (ex) {
return console.log('ledger client creation error: ' + ex.toString() + '\n' + ex.stack)
Expand Down