From 9ed12ef4c26cb6b303f7ba0ad2639716057c181e Mon Sep 17 00:00:00 2001 From: Jan Hovancik Date: Thu, 23 Dec 2021 09:39:51 +0100 Subject: [PATCH] Fix break window "no text" issues (#1073) --- CHANGELOG.md | 1 + app/break.js | 4 ++++ app/main.js | 18 ++++++++---------- app/microbreak.js | 4 ++++ 4 files changed, 17 insertions(+), 10 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 148e6cd62..10aed9c36 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/). - transparency not working in breaks - command line arguments - Turkish option in Welcome window +- no break texts and time in break window ### Changed - updated many translations diff --git a/app/break.js b/app/break.js index c4b312e2b..c831e9807 100644 --- a/app/break.js +++ b/app/break.js @@ -4,6 +4,9 @@ const Utils = remote.require('./utils/utils') const HtmlTranslate = require('./utils/htmlTranslate') const Store = require('electron-store') const settings = new Store() +const log = require('electron-log') +const path = require('path') +log.transports.file.resolvePath = () => path.join(remote.app.getPath('userData'), 'logs/main.log') window.onload = (event) => { ipcRenderer.send('send-break-data') @@ -30,6 +33,7 @@ window.onload = (event) => { }) ipcRenderer.once('progress', (event, started, duration, strictMode, postpone, postponePercent, backgroundColor) => { + ipcRenderer.send('long-break-loaded') const progress = document.querySelector('#progress') const progressTime = document.querySelector('#progress-time') const postponeElement = document.querySelector('#postpone') diff --git a/app/main.js b/app/main.js index 108a4fbd7..f51e7ce9d 100644 --- a/app/main.js +++ b/app/main.js @@ -309,6 +309,10 @@ function numberOfDisplays () { function closeWindows (windowArray) { for (const window of windowArray) { window.hide() + if (windowArray[0] === window) { + ipcMain.removeAllListeners('send-break-data') + ipcMain.removeAllListeners('send-microbreak-data') + } window.close() } return null @@ -748,12 +752,9 @@ function startMicrobreak () { if (process.platform === 'darwin') { app.dock.hide() } - setTimeout(() => { + ipcMain.on('mini-break-loaded', (event) => { updateTray() - }, 500) - setTimeout(() => { - ipcMain.removeAllListeners('send-microbreak-data') - }, 2000) + }) } function startBreak () { @@ -894,12 +895,9 @@ function startBreak () { if (process.platform === 'darwin') { app.dock.hide() } - setTimeout(() => { + ipcMain.on('long-break-loaded', (event) => { updateTray() - }, 500) - setTimeout(() => { - ipcMain.removeAllListeners('send-break-data') - }, 2000) + }) } function breakComplete (shouldPlaySound, windows) { diff --git a/app/microbreak.js b/app/microbreak.js index 709e4d1aa..2b530c45a 100644 --- a/app/microbreak.js +++ b/app/microbreak.js @@ -4,6 +4,9 @@ const Utils = remote.require('./utils/utils') const HtmlTranslate = require('./utils/htmlTranslate') const Store = require('electron-store') const settings = new Store() +const log = require('electron-log') +const path = require('path') +log.transports.file.resolvePath = () => path.join(remote.app.getPath('userData'), 'logs/main.log') window.onload = (e) => { ipcRenderer.send('send-microbreak-data') @@ -28,6 +31,7 @@ window.onload = (e) => { }) ipcRenderer.once('progress', (event, started, duration, strictMode, postpone, postponePercent, backgroundColor) => { + ipcRenderer.send('mini-break-loaded') const progress = document.querySelector('#progress') const progressTime = document.querySelector('#progress-time') const postponeElement = document.querySelector('#postpone')