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

Adds confirmation dialog upon clicking the trash icon in the ledger table. #13128

Closed
wants to merge 25 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
7755b35
Adds confirmation dialog upon clicking the trash icon in the ledger t…
ryanml Feb 13, 2018
ea424bc
removing spanish translation
ryanml Feb 19, 2018
f97a11c
Check userAgent before trying to parse
bsclifton Feb 13, 2018
fc92852
Update pkg-installed app permissions to $USER:admin
petemill Feb 13, 2018
5aabb1f
add date-fns dep
cezaraugusto Dec 18, 2017
e6a23b7
replace moment in ledgerexportutil
cezaraugusto Dec 18, 2017
97dba3b
replace moment in advanced panel tests (skipped)
cezaraugusto Dec 18, 2017
5a6a004
replace moment in contrib statement
cezaraugusto Dec 18, 2017
ae3bf96
replace moment in bm exporter
cezaraugusto Dec 18, 2017
35193cb
replace moment in ledgerUtil
cezaraugusto Dec 18, 2017
57eb977
replace moment in ledger api
cezaraugusto Dec 18, 2017
2747d69
remove moment call in ledger history
cezaraugusto Dec 18, 2017
2125a63
replace moment in enabledContent
cezaraugusto Dec 18, 2017
710ab6c
Updated to muon-winstaller 2.6.1
bsclifton Feb 14, 2018
fca1896
Release notes for 0.20.x Hotfix 2
kjozwiak Feb 15, 2018
6537171
Made urlBarIconContainer clickable to display connection info. Fix #7888
MargarytaChepiga Feb 15, 2018
fbceda9
Adds promo check when opening payments tab
NejcZdovc Feb 9, 2018
8c5e50e
perf: when choosing 'Toggle react profiling', also record mergeProps …
petemill Nov 27, 2017
eef58de
Fixes stop promotions for notifications
NejcZdovc Feb 7, 2018
190c4c1
Create a Buffer Window, which is used consistently to open new window…
petemill Dec 29, 2017
3d56296
[HTTPS Everywhere] update to latest HTTPS Everywhere
diracdeltas Feb 14, 2018
b74450b
Optimization of synopsisNormalizer
NejcZdovc Feb 5, 2018
ffc277a
Fixes pinned values when total is not over 100
NejcZdovc Feb 5, 2018
50cb955
Adds confirmation dialog upon clicking the trash icon in the ledger t…
ryanml Feb 13, 2018
77209db
Removing spanish translation for bansiteconfirmation
ryanml Feb 19, 2018
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
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
# Changelog

## [0.20.42](https://github.com/brave/browser-laptop/releases/tag/v0.20.42dev)

- Fixed websites randomly being unpinned under Payments. ([#13102](https://github.com/brave/browser-laptop/issues/13102))
- Fixed incorrect keyboard shortcuts being used for session tabs. ([#13000](https://github.com/brave/browser-laptop/issues/13000))
- Fixed AltGr + Number shortcuts opening new session tabs. ([#12956](https://github.com/brave/browser-laptop/issues/12956))
- Fixed Copying and Pasting images. ([#7388](https://github.com/brave/browser-laptop/issues/7388))
- Upgraded to muon 4.8.2. ([#12641](https://github.com/brave/browser-laptop/issues/13041))
- Upgraded to Chromium 64.0.3282.140. ([#12521](https://github.com/brave/browser-laptop/issues/13149))

## [0.20.30](https://github.com/brave/browser-laptop/releases/tag/v0.20.30dev)

- Fixed restoring tabs at startup causing slow performance. ([#12976](https://github.com/brave/browser-laptop/issues/12976))
Expand Down
116 changes: 64 additions & 52 deletions app/browser/api/ledger.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
'use strict'

const acorn = require('acorn')
const moment = require('moment')
const format = require('date-fns/format')
const Immutable = require('immutable')
const electron = require('electron')
const ipc = electron.ipcMain
Expand Down Expand Up @@ -174,11 +174,12 @@ const paymentPresent = (state, tabId, present) => {
delete ledgerPaymentsPresent[tabId]
}

if (Object.keys(ledgerPaymentsPresent).length > 0 && getSetting(settings.PAYMENTS_ENABLED)) {
if (getSetting(settings.PAYMENTS_ENABLED) && present) {
if (!balanceTimeoutId) {
module.exports.getBalance(state)
}

appActions.onPromotionGet()
getPublisherTimestamp(true)
} else if (balanceTimeoutId) {
clearTimeout(balanceTimeoutId)
Expand Down Expand Up @@ -418,70 +419,69 @@ const synopsisNormalizer = (state, changedPublisher, returnState = true, prune =
state = module.exports.pruneSynopsis(state)
}

let results = []
let publishers = ledgerState.getPublishers(state)
for (let item of publishers) {
const publisherKey = item[0]
let publisher = item[1]
if (!ledgerUtil.visibleP(state, publisherKey)) {
continue
}

publisher = publisher.set('publisherKey', publisherKey)
results.push(publisher.toJS())
}
let publishers = ledgerState.getPublishers(state).toJS()
let pinnedTotal = 0
let unPinnedTotal = 0
Object.keys(publishers).forEach(publisherKey => {
let publisher = publishers[publisherKey]

if (results.length === 0) {
if (returnState) {
return ledgerState.saveAboutSynopsis(state, Immutable.List())
if (!ledgerUtil.visibleP(state, publisherKey)) {
return
}

return []
}

results = underscore.sortBy(results, (entry) => -entry.scores[scorekeeper])
publisher.publisherKey = publisherKey

let pinnedTotal = 0
let unPinnedTotal = 0
// move publisher to the correct array and get totals
results.forEach((result) => {
if (result.pinPercentage && result.pinPercentage > 0) {
if (publisher.pinPercentage && publisher.pinPercentage > 0) {
// pinned
pinnedTotal += result.pinPercentage
dataPinned.push(getPublisherData(result, scorekeeper))
} else if (ledgerUtil.stickyP(state, result.publisherKey)) {
pinnedTotal += publisher.pinPercentage
dataPinned.push(getPublisherData(publisher, scorekeeper))
} else if (ledgerUtil.stickyP(state, publisher.publisherKey)) {
// unpinned
unPinnedTotal += result.scores[scorekeeper]
dataUnPinned.push(result)
unPinnedTotal += publisher.scores[scorekeeper]
dataUnPinned.push(publisher)
} else {
// excluded
let publisher = getPublisherData(result, scorekeeper)
publisher.percentage = 0
publisher.weight = 0
dataExcluded.push(publisher)
let newPublisher = getPublisherData(publisher, scorekeeper)
newPublisher.percentage = 0
newPublisher.weight = 0
dataExcluded.push(newPublisher)
}
})

if (
dataPinned.length === 0 &&
dataUnPinned.length === 0 &&
dataExcluded.length === 0
) {
if (returnState) {
return ledgerState.saveAboutSynopsis(state, Immutable.List())
}

return []
}

// round if over 100% of pinned publishers
if (pinnedTotal > 100) {
if (changedPublisher) {
let changedObject = dataPinned.filter(publisher => publisher.publisherKey === changedPublisher)[0] // TOOD optimize to find from filter
const setOne = changedObject.pinPercentage > (100 - dataPinned.length - 1)
let changedObject = dataPinned.find(publisher => publisher.publisherKey === changedPublisher)
if (changedObject) {
const setOne = changedObject.pinPercentage > (100 - dataPinned.length - 1)

if (setOne) {
changedObject.pinPercentage = 100 - dataPinned.length + 1
changedObject.weight = changedObject.pinPercentage
}
if (setOne) {
changedObject.pinPercentage = 100 - dataPinned.length + 1
changedObject.weight = changedObject.pinPercentage
}

const pinnedRestTotal = pinnedTotal - changedObject.pinPercentage
dataPinned = dataPinned.filter(publisher => publisher.publisherKey !== changedPublisher)
dataPinned = normalizePinned(dataPinned, pinnedRestTotal, (100 - changedObject.pinPercentage), setOne)
dataPinned = roundToTarget(dataPinned, (100 - changedObject.pinPercentage), 'pinPercentage')
const pinnedRestTotal = pinnedTotal - changedObject.pinPercentage
dataPinned = dataPinned.filter(publisher => publisher.publisherKey !== changedPublisher)
dataPinned = module.exports.normalizePinned(dataPinned, pinnedRestTotal, (100 - changedObject.pinPercentage), setOne)
dataPinned = module.exports.roundToTarget(dataPinned, (100 - changedObject.pinPercentage), 'pinPercentage')

dataPinned.push(changedObject)
dataPinned.push(changedObject)
}
} else {
dataPinned = normalizePinned(dataPinned, pinnedTotal, 100)
dataPinned = roundToTarget(dataPinned, 100, 'pinPercentage')
dataPinned = module.exports.normalizePinned(dataPinned, pinnedTotal, 100)
dataPinned = module.exports.roundToTarget(dataPinned, 100, 'pinPercentage')
}

dataUnPinned = dataUnPinned.map((result) => {
Expand All @@ -495,8 +495,18 @@ const synopsisNormalizer = (state, changedPublisher, returnState = true, prune =
state = ledgerState.changePinnedValues(state, dataPinned)
} else if (dataUnPinned.length === 0 && pinnedTotal < 100) {
// when you don't have any unpinned sites and pinned total is less then 100 %
dataPinned = normalizePinned(dataPinned, pinnedTotal, 100, false)
dataPinned = roundToTarget(dataPinned, 100, 'pinPercentage')
let changedObject = dataPinned.find(publisher => publisher.publisherKey === changedPublisher)
if (changedObject) {
const pinnedRestTotal = pinnedTotal - changedObject.pinPercentage
const restPercentage = 100 - changedObject.pinPercentage
dataPinned = dataPinned.filter(publisher => publisher.publisherKey !== changedPublisher)
dataPinned = module.exports.normalizePinned(dataPinned, pinnedRestTotal, restPercentage)
dataPinned = module.exports.roundToTarget(dataPinned, restPercentage, 'pinPercentage')
dataPinned.push(changedObject)
} else {
dataPinned = module.exports.normalizePinned(dataPinned, pinnedTotal, 100, false)
dataPinned = module.exports.roundToTarget(dataPinned, 100, 'pinPercentage')
}

// sync app store
state = ledgerState.changePinnedValues(state, dataPinned)
Expand All @@ -511,7 +521,7 @@ const synopsisNormalizer = (state, changedPublisher, returnState = true, prune =
})

// normalize unpinned values
dataUnPinned = roundToTarget(dataUnPinned, (100 - pinnedTotal), 'percentage')
dataUnPinned = module.exports.roundToTarget(dataUnPinned, (100 - pinnedTotal), 'percentage')
}

const newData = dataPinned.concat(dataUnPinned, dataExcluded)
Expand Down Expand Up @@ -999,7 +1009,7 @@ const pageDataChanged = (state, viewData = {}, keepInfo = false) => {
}

const backupKeys = (state, backupAction) => {
const date = moment().format('L')
const date = format(new Date(), 'MM/DD/YYYY')
const passphrase = ledgerState.getInfoProp(state, 'passphrase')

const messageLines = [
Expand Down Expand Up @@ -2835,6 +2845,8 @@ const getMethods = () => {
deleteSynopsis,
transitionWalletToBat,
getNewClient,
normalizePinned,
roundToTarget,
savePublisherData,
pruneSynopsis,
checkBtcBatMigrated,
Expand Down
3 changes: 2 additions & 1 deletion app/browser/api/ledgerNotifications.js
Original file line number Diff line number Diff line change
Expand Up @@ -364,7 +364,8 @@ const showPromotionNotification = (state) => {
(
getSetting(settings.PAYMENTS_ENABLED) &&
!getSetting(settings.PAYMENTS_NOTIFICATIONS)
)
) ||
!getSetting(settings.PAYMENTS_ALLOW_PROMOTIONS)
) {
return
}
Expand Down
4 changes: 2 additions & 2 deletions app/browser/bookmarksExporter.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
'use strict'

const path = require('path')
const moment = require('moment')
const format = require('date-fns/format')
const fs = require('fs')
const electron = require('electron')
const dialog = electron.dialog
Expand All @@ -29,7 +29,7 @@ const indentType = ' '

const showDialog = (state) => {
const focusedWindow = BrowserWindow.getFocusedWindow()
const fileName = moment().format('DD_MM_YYYY') + '.html'
const fileName = format(new Date(), 'DD_MM_YYYY') + '.html'
const defaultPath = path.join(getSetting(settings.DOWNLOAD_DEFAULT_PATH) || app.getPath('downloads'), fileName)
let personal = []
let other = []
Expand Down
27 changes: 4 additions & 23 deletions app/browser/reducers/windowsReducer.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,9 @@ const {makeImmutable, isImmutable} = require('../../common/state/immutableUtil')
const electron = require('electron')
const BrowserWindow = electron.BrowserWindow
const firstDefinedValue = require('../../../js/lib/functional').firstDefinedValue
const appConfig = require('../../../js/constants/appConfig')
const settings = require('../../../js/constants/settings')
const getSetting = require('../../../js/settings').getSetting

const platformUtil = require('../../common/lib/platformUtil')

const isDarwin = platformUtil.isDarwin()
const isWindows = platformUtil.isWindows()

// TODO cleanup all this createWindow crap
function isModal (browserOpts) {
// this needs some better checks
Expand Down Expand Up @@ -100,6 +94,8 @@ const setWindowPosition = (browserOpts, defaults, immutableWindowState) => {
const screenPos = electron.screen.getCursorScreenPoint()
browserOpts.x = screenPos.x
browserOpts.y = screenPos.y
// ensure only valid BrowserWindow opts remain in browserOpts
delete browserOpts.positionByMouseCursor
} else if (immutableWindowState.getIn(['windowInfo'])) {
// Position comes from window state
browserOpts.x = firstDefinedValue(browserOpts.x, immutableWindowState.getIn(['windowInfo', 'left']))
Expand All @@ -120,7 +116,7 @@ const setMaximized = (state, browserOpts, immutableWindowState) => {
if (Object.keys(browserOpts).length > 0 && !browserOpts.checkMaximized) {
return false
}

delete browserOpts.checkMaximized
if (immutableWindowState.getIn(['windowInfo'])) {
return immutableWindowState.getIn(['windowInfo', 'state']) === 'maximized'
}
Expand All @@ -138,12 +134,7 @@ function windowDefaults (state) {
minHeight: 300,
minModalHeight: 100,
minModalWidth: 100,
windowOffset: 20,
webPreferences: {
// XXX: Do not edit without security review
sharedWorker: true,
partition: 'default'
}
windowOffset: 20
}
}

Expand Down Expand Up @@ -246,20 +237,10 @@ const handleCreateWindowAction = (state, action) => {
browserOpts.width = browserOpts.width < minWidth ? minWidth : browserOpts.width
browserOpts.height = browserOpts.height < minHeight ? minHeight : browserOpts.height

const autoHideMenuBarSetting = isDarwin || getSetting(settings.AUTO_HIDE_MENU)

const windowProps = {
// smaller min size for "modal" windows
minWidth,
minHeight,
// Neither a frame nor a titlebar
// frame: false,
// A frame but no title bar and windows buttons in titlebar 10.10 OSX and up only?
titleBarStyle: 'hidden-inset',
autoHideMenuBar: autoHideMenuBarSetting,
title: appConfig.name,
webPreferences: defaults.webPreferences,
frame: !isWindows,
disposition: frameOpts.disposition
}

Expand Down
Loading