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

Bugfix: not open help tutorial every time #41

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
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
7 changes: 3 additions & 4 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ let rulers;
let settingsWindow;
let helpWindow;
let lastFocusedRuler;
let showRuler = false;

/**
* Create a ruler window and push it to the `rulers` array. The ruler window
Expand Down Expand Up @@ -88,16 +89,14 @@ function showHelp() {
});
}

let hidden = false;

/**
* Toggle a ruler asynchronously and give back a promise.
* @param {BrowserWindow} ruler - The ruler to toggle
* @return {Promise}
*/
const toggleRuler = ruler => {
return new Promise(resolve => setTimeout(() => {
ruler[hidden ? 'hide' : 'show']();
ruler[showRuler ? 'show' : 'hide']();
resolve();
}));
};
Expand All @@ -110,7 +109,7 @@ function toggleRulerCommand() {
return;
}

hidden = !hidden;
showRuler = !showRuler;

// Close all rulers sequentially. Doing otherwise doesn't toggle them
// properly. This is most likely an issue with Electron.
Expand Down
7 changes: 3 additions & 4 deletions src/app/help/help.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
'use strict';

const ipc = require('electron').ipcRenderer;
const remote = require('electron').remote;
const { ipcRenderer, remote } = require('electron');
const browserWindow = remote.getCurrentWindow();
const dataStore = require('../../data-store');

// When the help menu is loaded, we create a ruler
// so the user can get a feel of how to use them.
ipc.send('create-ruler', {
ipcRenderer.send('create-ruler', {
x: browserWindow.getPosition()[0] + 274,
y: browserWindow.getPosition()[1] + 250
});
Expand All @@ -20,8 +19,8 @@ document.querySelector('.next-step').addEventListener('click', () => {
if (currentStep === 5) {
document.querySelector('.next-step .btn__inner').textContent = 'Got it!';
document.querySelector('.next-step').addEventListener('click', () => {
browserWindow.close();
dataStore.saveSettings('tutorialShown', true);
browserWindow.close();
});
}
});