Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move window modules into common folder #410

Merged
Show file tree
Hide file tree
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
6 changes: 3 additions & 3 deletions src/auto-updater/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,19 @@ const yaml = require('js-yaml')

const log = require('../error-manager/log')
const BfxMacUpdater = require('./bfx.mac.updater')
const wins = require('../windows')
const wins = require('../window-creators/windows')
const {
showLoadingWindow,
hideLoadingWindow
} = require('../change-loading-win-visibility-state')
} = require('../window-creators/change-loading-win-visibility-state')
const {
closeAlert
} = require('../modal-dialog-src/utils')
const parseEnvValToBool = require('../helpers/parse-env-val-to-bool')
const {
WINDOW_EVENT_NAMES,
addOnceProcEventHandler
} = require('../window-event-manager')
} = require('../window-creators/window-event-manager')

const MENU_ITEM_IDS = require('../create-menu/menu.item.ids')

Expand Down
2 changes: 1 addition & 1 deletion src/change-sync-frequency.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ const getAlertCustomClassObj = require(
const {
WINDOW_EVENT_NAMES,
addOnceProcEventHandler
} = require('./window-event-manager')
} = require('./window-creators/window-event-manager')

const _getSchedulerRule = (timeFormat, alertRes) => {
if (timeFormat.value === 'days') {
Expand Down
2 changes: 1 addition & 1 deletion src/enforce-macos-app-location.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const productName = require('./helpers/product-name')
const {
showLoadingWindow,
hideLoadingWindow
} = require('./change-loading-win-visibility-state')
} = require('./window-creators/change-loading-win-visibility-state')

module.exports = async () => {
if (
Expand Down
4 changes: 2 additions & 2 deletions src/error-manager/show-modal-dialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const { Converter } = require('showdown')
const Alert = require('electron-alert')
const { rootPath } = require('electron-root-path')

const wins = require('../windows')
const wins = require('../window-creators/windows')
const spawn = require('../helpers/spawn')
const getAlertCustomClassObj = require(
'../helpers/get-alert-custom-class-obj'
Expand All @@ -21,7 +21,7 @@ const {
const {
WINDOW_EVENT_NAMES,
addOnceProcEventHandler
} = require('../window-event-manager')
} = require('../window-creators/window-event-manager')

const mdStyle = fs.readFileSync(path.join(
rootPath, 'node_modules', 'github-markdown-css/github-markdown.css'
Expand Down
2 changes: 1 addition & 1 deletion src/export-db.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const showMessageModalDialog = require('./show-message-modal-dialog')
const {
showLoadingWindow,
hideLoadingWindow
} = require('./change-loading-win-visibility-state')
} = require('./window-creators/change-loading-win-visibility-state')
const {
DEFAULT_ARCHIVE_DB_FILE_NAME,
DB_FILE_NAME,
Expand Down
2 changes: 1 addition & 1 deletion src/helpers/is-main-win-available.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use strict'

const wins = require('../windows')
const wins = require('../window-creators/windows')

module.exports = (
win = wins?.mainWindow,
Expand Down
6 changes: 3 additions & 3 deletions src/initialize-app.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const { REPORT_FILES_PATH_VERSION } = require('./const')

const triggerSyncAfterUpdates = require('./trigger-sync-after-updates')
const triggerElectronLoad = require('./trigger-electron-load')
const wins = require('./windows')
const wins = require('./window-creators/windows')
const runServer = require('./run-server')
const appStates = require('./app-states')
const {
Expand All @@ -16,7 +16,7 @@ const {
} = require('./window-creators')
const {
hideLoadingWindow
} = require('./change-loading-win-visibility-state')
} = require('./window-creators/change-loading-win-visibility-state')
const makeOrReadSecretKey = require('./make-or-read-secret-key')
const {
configsKeeperFactory
Expand All @@ -43,7 +43,7 @@ const manageWorkerMessages = require(
)
const printToPDF = require('./print-to-pdf')

const pathToLayouts = path.join(__dirname, 'layouts')
const pathToLayouts = path.join(__dirname, 'window-creators/layouts')
const pathToLayoutAppInitErr = path
.join(pathToLayouts, 'app-init-error.html')

Expand Down
2 changes: 1 addition & 1 deletion src/make-single-instance.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

const { app } = require('electron')

const windows = require('./windows')
const windows = require('./window-creators/windows')

module.exports = () => {
const isGottenLock = app.requestSingleInstanceLock()
Expand Down
2 changes: 1 addition & 1 deletion src/manage-worker-messages.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

const { app, BrowserWindow } = require('electron')

const wins = require('./windows')
const wins = require('./window-creators/windows')
const relaunch = require('./relaunch')
const showMessageModalDialog = require(
'./show-message-modal-dialog'
Expand Down
2 changes: 1 addition & 1 deletion src/pause-app.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
const ipcs = require('./ipcs')
const {
showLoadingWindow
} = require('./change-loading-win-visibility-state')
} = require('./window-creators/change-loading-win-visibility-state')

const _closeServer = () => {
return new Promise((resolve, reject) => {
Expand Down
2 changes: 1 addition & 1 deletion src/print-to-pdf/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const fs = require('fs/promises')
const path = require('path')

const ipcs = require('../ipcs')
const wins = require('../windows')
const wins = require('../window-creators/windows')

const PROCESS_MESSAGES = require(
'../../bfx-reports-framework/workers/loc.api/process.message.manager/process.messages'
Expand Down
4 changes: 2 additions & 2 deletions src/restore-db/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const Alert = require('electron-alert')
const { rootPath } = require('electron-root-path')

const ipcs = require('../ipcs')
const wins = require('../windows')
const wins = require('../window-creators/windows')
const {
deserializeError
} = require('../helpers/utils')
Expand All @@ -29,7 +29,7 @@ const {
const {
WINDOW_EVENT_NAMES,
addOnceProcEventHandler
} = require('../window-event-manager')
} = require('../window-creators/window-event-manager')

const fontsStyle = fs.readFileSync(path.join(
rootPath, 'bfx-report-ui/build/fonts/roboto.css'
Expand Down
4 changes: 2 additions & 2 deletions src/show-docs/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const { Converter } = require('showdown')
const Alert = require('electron-alert')
const { rootPath } = require('electron-root-path')

const wins = require('../windows')
const wins = require('../window-creators/windows')
const isMainWinAvailable = require(
'../helpers/is-main-win-available'
)
Expand All @@ -26,7 +26,7 @@ const mdUserManual = fs.readFileSync(
const {
WINDOW_EVENT_NAMES,
addOnceProcEventHandler
} = require('../window-event-manager')
} = require('../window-creators/window-event-manager')

const mdStyle = fs.readFileSync(path.join(
rootPath, 'node_modules', 'github-markdown-css/github-markdown.css'
Expand Down
2 changes: 1 addition & 1 deletion src/show-notification/show-sync-notification.js
Original file line number Diff line number Diff line change
Expand Up @@ -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('../window-creators/windows')
const { isWindowInvisible } = require('../helpers/manage-window')
const showNotification = require('./')

Expand Down
2 changes: 1 addition & 1 deletion src/show-notification/show-trx-tax-report-notification.js
Original file line number Diff line number Diff line change
Expand Up @@ -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('../window-creators/windows')
const { isWindowInvisible } = require('../helpers/manage-window')
const showNotification = require('./')

Expand Down
2 changes: 1 addition & 1 deletion src/trigger-electron-load.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
const path = require('path')
const fs = require('fs')

const wins = require('./windows')
const wins = require('./window-creators/windows')
const pathToTriggerElectronLoad = path.join(
__dirname,
'../bfx-report-ui/build/triggerElectronLoad.js'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const {
hideWindow,
showWindow,
centerWindow
} = require('./helpers/manage-window')
} = require('../helpers/manage-window')

let intervalMarker

Expand Down Expand Up @@ -158,7 +158,7 @@ const showLoadingWindow = async (opts = {}) => {
typeof wins.loadingWindow !== 'object' ||
wins.loadingWindow.isDestroyed()
) {
await require('./window-creators')
await require('.')
.createLoadingWindow()
}

Expand Down
16 changes: 8 additions & 8 deletions src/window-creators.js → src/window-creators/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ const isDevEnv = process.env.NODE_ENV === 'development'
const isMac = process.platform === 'darwin'

const wins = require('./windows')
const ipcs = require('./ipcs')
const serve = require('./serve')
const appStates = require('./app-states')
const ipcs = require('../ipcs')
const serve = require('../serve')
const appStates = require('../app-states')
const windowStateKeeper = require('./window-state-keeper')
const createMenu = require('./create-menu')
const createMenu = require('../create-menu')
const {
showLoadingWindow,
hideLoadingWindow
Expand All @@ -22,10 +22,10 @@ const {
showWindow,
hideWindow,
centerWindow
} = require('./helpers/manage-window')
const isBfxApiStaging = require('./helpers/is-bfx-api-staging')
} = require('../helpers/manage-window')
const isBfxApiStaging = require('../helpers/is-bfx-api-staging')

const publicDir = path.join(__dirname, '../bfx-report-ui/build')
const publicDir = path.join(__dirname, '../../bfx-report-ui/build')
const loadURL = serve({ directory: publicDir })

const pathToLayouts = path.join(__dirname, 'layouts')
Expand Down Expand Up @@ -90,7 +90,7 @@ const _createWindow = async (
y: !y
? bounds.y
: y,
icon: path.join(__dirname, '../build/icons/512x512.png'),
icon: path.join(__dirname, '../../build/icons/512x512.png'),
backgroundColor: '#172d3e',
show: false,
...props,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<link rel="shortcut icon" href="../../bfx-report-ui/build/favicon.ico">
<link href="../../bfx-report-ui/build/fonts/roboto.css" rel="stylesheet">
<link rel="shortcut icon" href="../../../bfx-report-ui/build/favicon.ico">
<link href="../../../bfx-report-ui/build/fonts/roboto.css" rel="stylesheet">
<title>Bitfinex Reports</title>
<style>
body {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<link rel="shortcut icon" href="../../bfx-report-ui/build/favicon.ico">
<link href="../../bfx-report-ui/build/fonts/roboto.css" rel="stylesheet">
<link rel="shortcut icon" href="../../../bfx-report-ui/build/favicon.ico">
<link href="../../../bfx-report-ui/build/fonts/roboto.css" rel="stylesheet">
<title>Bitfinex Reports</title>
<style>
html {
Expand Down Expand Up @@ -201,7 +201,7 @@
<div></div>
</div>
<div class="logo">
<img class="logo-img" src="../../build/loader.png" alt="logo">
<img class="logo-img" src="../../../build/loader.png" alt="logo">
</div>
<div id="description" class="description"></div>
</body>
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use strict'

const wins = require('../windows')
const wins = require('./windows')

const WINDOW_EVENT_NAMES = {
CLOSED: 'closed'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

const { screen } = require('electron')

const { getConfigsKeeperByName } = require('./configs-keeper')
const { getConfigsKeeperByName } = require('../configs-keeper')

module.exports = (options) => {
let state = null
Expand Down
File renamed without changes.