From d65faf02a0d324f223355a6d0f867ef210947a8e Mon Sep 17 00:00:00 2001 From: Vladimir Voronkov Date: Fri, 2 Aug 2024 12:49:54 +0300 Subject: [PATCH 01/13] Show native notification with multiple workspaces mode in Ubuntu --- src/manage-worker-messages.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/manage-worker-messages.js b/src/manage-worker-messages.js index d269fb94..d94d9f16 100644 --- a/src/manage-worker-messages.js +++ b/src/manage-worker-messages.js @@ -242,7 +242,10 @@ module.exports = (ipc) => { state === PROCESS_MESSAGES.READY_TRX_TAX_REPORT || state === PROCESS_MESSAGES.ERROR_TRX_TAX_REPORT ) && - !wins?.mainWindow?.isVisible() + ( + !wins?.mainWindow?.isVisible() || + !wins?.mainWindow?.isFocused() + ) ) { const isError = state === PROCESS_MESSAGES.ERROR_TRX_TAX_REPORT const body = isError From 8f2e427443387dab546d69188714a3bd96efa66d Mon Sep 17 00:00:00 2001 From: Vladimir Voronkov Date: Fri, 9 Aug 2024 13:10:15 +0300 Subject: [PATCH 02/13] Add process messages for sync notifications --- server.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/server.js b/server.js index 2239b520..7e45a92f 100644 --- a/server.js +++ b/server.js @@ -61,6 +61,9 @@ const allowedProcessMessagesSet = _getAllowedStatesSet({ 'READY_TRX_TAX_REPORT', 'ERROR_TRX_TAX_REPORT', + 'READY_SYNC', + 'ERROR_SYNC', + 'ALL_TABLE_HAVE_BEEN_CLEARED', 'ALL_TABLE_HAVE_NOT_BEEN_CLEARED', From db6ada6bb1efea3f9a8fa02db557bacb4637575f Mon Sep 17 00:00:00 2001 From: Vladimir Voronkov Date: Fri, 9 Aug 2024 13:11:58 +0300 Subject: [PATCH 03/13] Add helper to check window invisibility --- src/helpers/manage-window.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/helpers/manage-window.js b/src/helpers/manage-window.js index 9bb72617..5f74f54d 100644 --- a/src/helpers/manage-window.js +++ b/src/helpers/manage-window.js @@ -111,8 +111,16 @@ const centerWindow = (win, workArea) => { win.setBounds(boundsOpts) } +const isWindowInvisible = (win) => { + return ( + !win?.isVisible() || + !win?.isFocused() + ) +} + module.exports = { hideWindow, showWindow, - centerWindow + centerWindow, + isWindowInvisible } From 65bae8316f0a2c6c9a4ed39c333b0256e67fc1f4 Mon Sep 17 00:00:00 2001 From: Vladimir Voronkov Date: Fri, 9 Aug 2024 13:15:55 +0300 Subject: [PATCH 04/13] Add module to show sync notification --- .../show-sync-notification.js | 37 +++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 src/show-notification/show-sync-notification.js diff --git a/src/show-notification/show-sync-notification.js b/src/show-notification/show-sync-notification.js new file mode 100644 index 00000000..30010315 --- /dev/null +++ b/src/show-notification/show-sync-notification.js @@ -0,0 +1,37 @@ +'use strict' + +const PROCESS_MESSAGES = require( + '../../bfx-reports-framework/workers/loc.api/process.message.manager/process.messages' +) +const showNotification = require('./') + +const getBody = (params) => { + const { + isError, + isInterrupted + } = params ?? {} + + if (isError) { + return 'Data sync completed with an error!' + } + if (isInterrupted) { + return 'Data sync interrupted!' + } + + return 'Data sync completed successfully!' +} + +module.exports = (mess) => { + const { + state = '', + data = {} + } = mess ?? {} + + const isError = state === PROCESS_MESSAGES.ERROR_SYNC + const isInterrupted = !!data?.isInterrupted + + const body = getBody({ isError, isInterrupted }) + const urgency = isError ? 'critical' : 'normal' + + showNotification({ body, urgency }) +} From dcfff9018518cc6d1cb17ba9fda87dc80067f320 Mon Sep 17 00:00:00 2001 From: Vladimir Voronkov Date: Fri, 9 Aug 2024 13:18:28 +0300 Subject: [PATCH 05/13] Add ability to show sync notification --- src/manage-worker-messages.js | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/src/manage-worker-messages.js b/src/manage-worker-messages.js index d94d9f16..1738ae36 100644 --- a/src/manage-worker-messages.js +++ b/src/manage-worker-messages.js @@ -10,8 +10,12 @@ const showMessageModalDialog = require( const isMainWinAvailable = require( './helpers/is-main-win-available' ) -const { showWindow } = require('./helpers/manage-window') +const { + showWindow, + isWindowInvisible +} = require('./helpers/manage-window') const showNotification = require('./show-notification') +const showSyncNotification = require('./show-notification/show-sync-notification') const PROCESS_MESSAGES = require( '../bfx-reports-framework/workers/loc.api/process.message.manager/process.messages' ) @@ -242,10 +246,7 @@ module.exports = (ipc) => { state === PROCESS_MESSAGES.READY_TRX_TAX_REPORT || state === PROCESS_MESSAGES.ERROR_TRX_TAX_REPORT ) && - ( - !wins?.mainWindow?.isVisible() || - !wins?.mainWindow?.isFocused() - ) + isWindowInvisible(wins?.mainWindow) ) { const isError = state === PROCESS_MESSAGES.ERROR_TRX_TAX_REPORT const body = isError @@ -255,6 +256,15 @@ module.exports = (ipc) => { showNotification({ body, urgency }) } + if ( + ( + state === PROCESS_MESSAGES.READY_SYNC || + state === PROCESS_MESSAGES.ERROR_SYNC + ) && + isWindowInvisible(wins?.mainWindow) + ) { + showSyncNotification(mess) + } } catch (err) { console.error(err) } From 64011a478b0b16f4afcc16606b51dcb526077fb2 Mon Sep 17 00:00:00 2001 From: Vladimir Voronkov Date: Fri, 9 Aug 2024 13:27:35 +0300 Subject: [PATCH 06/13] Move logic to show trx tax report notification into separate module --- src/manage-worker-messages.js | 23 +++++++--------- .../show-trx-tax-report-notification.js | 26 +++++++++++++++++++ 2 files changed, 35 insertions(+), 14 deletions(-) create mode 100644 src/show-notification/show-trx-tax-report-notification.js diff --git a/src/manage-worker-messages.js b/src/manage-worker-messages.js index 1738ae36..0fe9933d 100644 --- a/src/manage-worker-messages.js +++ b/src/manage-worker-messages.js @@ -14,8 +14,12 @@ const { showWindow, isWindowInvisible } = require('./helpers/manage-window') -const showNotification = require('./show-notification') -const showSyncNotification = require('./show-notification/show-sync-notification') +const showTrxTaxReportNotification = require( + './show-trx-tax-report-notification' +) +const showSyncNotification = require( + './show-notification/show-sync-notification' +) const PROCESS_MESSAGES = require( '../bfx-reports-framework/workers/loc.api/process.message.manager/process.messages' ) @@ -242,19 +246,10 @@ module.exports = (ipc) => { ipc.send({ state: PROCESS_STATES.REMOVE_ALL_TABLES }) } if ( - ( - state === PROCESS_MESSAGES.READY_TRX_TAX_REPORT || - state === PROCESS_MESSAGES.ERROR_TRX_TAX_REPORT - ) && - isWindowInvisible(wins?.mainWindow) + state === PROCESS_MESSAGES.READY_TRX_TAX_REPORT || + state === PROCESS_MESSAGES.ERROR_TRX_TAX_REPORT ) { - const isError = state === PROCESS_MESSAGES.ERROR_TRX_TAX_REPORT - const body = isError - ? 'An unexpected error occurred while generating the tax report!' - : 'Your tax report is ready!' - const urgency = isError ? 'critical' : 'normal' - - showNotification({ body, urgency }) + showTrxTaxReportNotification(mess) } if ( ( diff --git a/src/show-notification/show-trx-tax-report-notification.js b/src/show-notification/show-trx-tax-report-notification.js new file mode 100644 index 00000000..13d6940f --- /dev/null +++ b/src/show-notification/show-trx-tax-report-notification.js @@ -0,0 +1,26 @@ +'use strict' + +const PROCESS_MESSAGES = require( + '../../bfx-reports-framework/workers/loc.api/process.message.manager/process.messages' +) +const wins = require('./windows') +const { isWindowInvisible } = require('../helpers/manage-window') +const showNotification = require('.') + +module.exports = (mess) => { + const { + state = '' + } = mess ?? {} + + if (!isWindowInvisible(wins?.mainWindow)) { + return + } + + const isError = state === PROCESS_MESSAGES.ERROR_TRX_TAX_REPORT + const body = isError + ? 'An unexpected error occurred while generating the tax report!' + : 'Your tax report is ready!' + const urgency = isError ? 'critical' : 'normal' + + showNotification({ body, urgency }) +} From dafec57d25f157dc2fa1074a2586c3ecd5127d16 Mon Sep 17 00:00:00 2001 From: Vladimir Voronkov Date: Fri, 9 Aug 2024 13:30:23 +0300 Subject: [PATCH 07/13] Improve show sync notification module --- src/manage-worker-messages.js | 10 +++------- src/show-notification/show-sync-notification.js | 6 ++++++ 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/src/manage-worker-messages.js b/src/manage-worker-messages.js index 0fe9933d..c65b20a7 100644 --- a/src/manage-worker-messages.js +++ b/src/manage-worker-messages.js @@ -11,8 +11,7 @@ const isMainWinAvailable = require( './helpers/is-main-win-available' ) const { - showWindow, - isWindowInvisible + showWindow } = require('./helpers/manage-window') const showTrxTaxReportNotification = require( './show-trx-tax-report-notification' @@ -252,11 +251,8 @@ module.exports = (ipc) => { showTrxTaxReportNotification(mess) } if ( - ( - state === PROCESS_MESSAGES.READY_SYNC || - state === PROCESS_MESSAGES.ERROR_SYNC - ) && - isWindowInvisible(wins?.mainWindow) + state === PROCESS_MESSAGES.READY_SYNC || + state === PROCESS_MESSAGES.ERROR_SYNC ) { showSyncNotification(mess) } diff --git a/src/show-notification/show-sync-notification.js b/src/show-notification/show-sync-notification.js index 30010315..32c4b354 100644 --- a/src/show-notification/show-sync-notification.js +++ b/src/show-notification/show-sync-notification.js @@ -3,6 +3,8 @@ const PROCESS_MESSAGES = require( '../../bfx-reports-framework/workers/loc.api/process.message.manager/process.messages' ) +const wins = require('./windows') +const { isWindowInvisible } = require('../helpers/manage-window') const showNotification = require('./') const getBody = (params) => { @@ -27,6 +29,10 @@ module.exports = (mess) => { data = {} } = mess ?? {} + if (!isWindowInvisible(wins?.mainWindow)) { + return + } + const isError = state === PROCESS_MESSAGES.ERROR_SYNC const isInterrupted = !!data?.isInterrupted From 67ad1d352bca5e111b44cd423ebe14548ba9ba91 Mon Sep 17 00:00:00 2001 From: Vladimir Voronkov Date: Fri, 9 Aug 2024 13:51:16 +0300 Subject: [PATCH 08/13] Fix imports --- src/manage-worker-messages.js | 2 +- src/show-notification/show-sync-notification.js | 2 +- src/show-notification/show-trx-tax-report-notification.js | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/manage-worker-messages.js b/src/manage-worker-messages.js index c65b20a7..2cbd7265 100644 --- a/src/manage-worker-messages.js +++ b/src/manage-worker-messages.js @@ -14,7 +14,7 @@ const { showWindow } = require('./helpers/manage-window') const showTrxTaxReportNotification = require( - './show-trx-tax-report-notification' + './show-notification/show-trx-tax-report-notification' ) const showSyncNotification = require( './show-notification/show-sync-notification' diff --git a/src/show-notification/show-sync-notification.js b/src/show-notification/show-sync-notification.js index 32c4b354..b63099a4 100644 --- a/src/show-notification/show-sync-notification.js +++ b/src/show-notification/show-sync-notification.js @@ -3,7 +3,7 @@ const PROCESS_MESSAGES = require( '../../bfx-reports-framework/workers/loc.api/process.message.manager/process.messages' ) -const wins = require('./windows') +const wins = require('../windows') const { isWindowInvisible } = require('../helpers/manage-window') const showNotification = require('./') diff --git a/src/show-notification/show-trx-tax-report-notification.js b/src/show-notification/show-trx-tax-report-notification.js index 13d6940f..02be5289 100644 --- a/src/show-notification/show-trx-tax-report-notification.js +++ b/src/show-notification/show-trx-tax-report-notification.js @@ -3,9 +3,9 @@ const PROCESS_MESSAGES = require( '../../bfx-reports-framework/workers/loc.api/process.message.manager/process.messages' ) -const wins = require('./windows') +const wins = require('../windows') const { isWindowInvisible } = require('../helpers/manage-window') -const showNotification = require('.') +const showNotification = require('./') module.exports = (mess) => { const { From 9ec31d94a0b09810c47a296fae63eae859bf603e Mon Sep 17 00:00:00 2001 From: Vladimir Voronkov Date: Tue, 27 Aug 2024 15:08:13 +0300 Subject: [PATCH 09/13] Extend network error processing --- src/error-manager/index.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/error-manager/index.js b/src/error-manager/index.js index 976dc411..910e2fec 100644 --- a/src/error-manager/index.js +++ b/src/error-manager/index.js @@ -6,6 +6,10 @@ const cleanStack = require('clean-stack') const isDevEnv = process.env.NODE_ENV === 'development' +const { isENetError } = require( + '../../bfx-reports-framework/workers/loc.api/helpers/api-errors-testers' +) + const log = require('./log') const getErrorDescription = require('./get-error-description') const showModalDialog = require('./show-modal-dialog') @@ -216,8 +220,8 @@ const initLogger = () => { * - GitHub server can't respond to the auto-update requests */ if ( + isENetError(error) || /Cannot download differentially/gi.test(error) || - /ERR_CONNECTION_REFUSED/gi.test(error) || /objects\.githubusercontent\.com/gi.test(error) || /Error: ERR_FAILED \(-2\) loading 'file:.*\.html'/gi.test(error) || /Failed to generate PDF/gi.test(error) From 20a940aa13d82a68af1cb1e5a42a70116da8f2e1 Mon Sep 17 00:00:00 2001 From: Vladimir Voronkov Date: Wed, 28 Aug 2024 11:24:01 +0300 Subject: [PATCH 10/13] Add electronjs app file locations on different oss --- README.md | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/README.md b/README.md index 19b70f6b..0eaa60b2 100644 --- a/README.md +++ b/README.md @@ -161,3 +161,14 @@ npm run launch -- -aop ``` > Also, we provide [GitHub Actioins workflows](https://docs.github.com/en/actions/using-workflows/about-workflows) configs for automated building and publishing of the Electron app artifacts using the above-described scripts `./scripts/launch.sh` and `./scripts/build-release.sh`, see the corresponding file `.github/workflows/build-electron-app.yml` + +## Locations of ElectronJS App files on different OSs + +- Logs: + - Ubuntu: `~/.config/Bitfinex Report/logs` + - Windows: `C:\Users\$username\AppData\Roaming\Bitfinex Report\logs` + - Mac: ElectronJS logs: `~/Library/Logs/Bitfinex Report` and app logs `~/Library/Application Support/Bitfinex Report/logs` +- DB files `db-sqlite_sync_m0.db`, `db-sqlite_sync_m0.db-shm` (optional), `db-sqlite_sync_m0.db-wal` (optional): + - Ubuntu: `~/.config/Bitfinex Report` + - Windows: `C:\Users\$username\AppData\Roaming\Bitfinex Report` + - Mac: `~/Library/Application Support/Bitfinex Report` From ef4646f10ec5836e920b84cc0334524d6765686c Mon Sep 17 00:00:00 2001 From: Vladimir Voronkov Date: Wed, 28 Aug 2024 11:24:33 +0300 Subject: [PATCH 11/13] Bump version up to v4.26.0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 4eff9d76..d19468eb 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "bfx-report-electron", - "version": "4.25.0", + "version": "4.26.0", "repository": "https://github.com/bitfinexcom/bfx-report-electron", "description": "Reporting tool", "author": "bitfinex.com", From 73956e2314e9f717d786de4374e5a84198eb915a Mon Sep 17 00:00:00 2001 From: Vladimir Voronkov Date: Wed, 28 Aug 2024 11:25:09 +0300 Subject: [PATCH 12/13] Update sub-modules --- bfx-report-ui | 2 +- bfx-reports-framework | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/bfx-report-ui b/bfx-report-ui index ef3faa57..fe31d525 160000 --- a/bfx-report-ui +++ b/bfx-report-ui @@ -1 +1 @@ -Subproject commit ef3faa57d8919ca6833f85736a8911583d58a2b9 +Subproject commit fe31d52501fb436660120f738ddba00cded1de0a diff --git a/bfx-reports-framework b/bfx-reports-framework index 914ed9e5..60e9584e 160000 --- a/bfx-reports-framework +++ b/bfx-reports-framework @@ -1 +1 @@ -Subproject commit 914ed9e58fc9f526c6066d0c1f6e20c8c9c63faf +Subproject commit 60e9584eafc669e4f5d27265e67d3f135a0551d1 From bac8b04018fa3cb32edea3241f9350956c0b3833 Mon Sep 17 00:00:00 2001 From: Vladimir Voronkov Date: Wed, 28 Aug 2024 12:02:43 +0300 Subject: [PATCH 13/13] Add changelog for v4.26.0 --- CHANGELOG.md | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4726d983..138f7167 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,35 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +## [4.26.0] - 2024-08-28 + +### Added + +- Added ability to send `IPC` messages when the sync is ready. PR: [bfx-reports-framework#405](https://github.com/bitfinexcom/bfx-reports-framework/pull/405) +- Added ability to show native notifications in case another screen is displayed and the app window is not hidden with multiple workspaces mode in `Ubuntu`/`Mac`. PR: [bfx-report-electron#389](https://github.com/bitfinexcom/bfx-report-electron/pull/389) +- Added ability to show the native notification in the electron app in case the `sync` is being processed in the background with the hidden main window. There we check if the main window is invisible and show a notification otherwise don't. PR: [bfx-report-electron#390](https://github.com/bitfinexcom/bfx-report-electron/pull/390) + +### Changed + +- Enhanced and unified `Logins` and `Change Logs` reports column configuration getters and reduced redundant code. PR: [bfx-report-ui#840](https://github.com/bitfinexcom/bfx-report-ui/pull/840) +- Reworked and optimized the `TimeFrameSelector` component in a more performant way and reduced redundant code. PR: [bfx-report-ui#841](https://github.com/bitfinexcom/bfx-report-ui/pull/841) +- Reworked cell generation configurations more concisely and optimally for `Wallets`, `Weighted Averages` and `Concentration Risk` reports. PR: [bfx-report-ui#842](https://github.com/bitfinexcom/bfx-report-ui/pull/842) +- Reworked and optimized `LedgersCategorySelect` in a more concise and performant way. PR: [bfx-report-ui#843](https://github.com/bitfinexcom/bfx-report-ui/pull/843) +- Reworked and optimized `Movements`, `Trades`, `Orders` and `Positions` reports column configuration getters. Implemented unified `getFeeCell` and `getActionCell` helpers for better reusability. PR: [bfx-report-ui#844](https://github.com/bitfinexcom/bfx-report-ui/pull/844) +- Reworked `CandlesTimeframe` in a more performant way and improved props linting. PR: [bfx-report-ui#845](https://github.com/bitfinexcom/bfx-report-ui/pull/845) +- Enhanced and unified `Snapshots` sections column configuration getters and reduced redundant code. PR: [bfx-report-ui#846](https://github.com/bitfinexcom/bfx-report-ui/pull/846) +- Removed deprecated methods and fields without breaking the logic and UI functionality. PRs: [bfx-report#389](https://github.com/bitfinexcom/bfx-report/pull/389), [bfx-reports-framework#403](https://github.com/bitfinexcom/bfx-reports-framework/pull/403) +- Improved DB file cleanups for test coverage hooks. PRs: [bfx-report#390](https://github.com/bitfinexcom/bfx-report/pull/390), [bitfinexcom/lokue#3](https://github.com/bitfinexcom/lokue/pull/3) +- Removed unused public colls conf accessor endpoints to use the common `getAllPublicCollsConfs`/`editAllPublicCollsConfs` ones without breaking the logic and UI functionality. PR: [bfx-reports-framework#404](https://github.com/bitfinexcom/bfx-reports-framework/pull/404) +- Implemented a class for DB models to typify and unify model objects. PR: [bfx-reports-framework#406](https://github.com/bitfinexcom/bfx-reports-framework/pull/406) +- Proxied `ENet` error tester for import in electron env. PR: [bfx-reports-framework#407](https://github.com/bitfinexcom/bfx-reports-framework/pull/407) + +### Fixed + +- Extended network error processing. Related to these issues: [bfx-report-electron#396](https://github.com/bitfinexcom/bfx-report-electron/issues/396), [bfx-report-electron#274](https://github.com/bitfinexcom/bfx-report-electron/issues/274). PR: [bfx-report#392](https://github.com/bitfinexcom/bfx-report/pull/392) +- Improved the tax report ccy conversion by adding `6` retries with `10sec` delay for getting `pub-trades` if returns non-array. PR: [bfx-reports-framework#402](https://github.com/bitfinexcom/bfx-reports-framework/pull/402) +- Extended network error processing and prevented showing the error modal dialog. Related to these issues: [bfx-report-electron#396](https://github.com/bitfinexcom/bfx-report-electron/issues/396), [bfx-report-electron#274](https://github.com/bitfinexcom/bfx-report-electron/issues/274). PR: [bfx-report-electron#397](https://github.com/bitfinexcom/bfx-report-electron/pull/397) + ## [4.25.0] - 2024-07-31 ### Added