Skip to content

Commit

Permalink
Rename launcherView to passwordView.
Browse files Browse the repository at this point in the history
  • Loading branch information
Mikunj committed Dec 6, 2018
1 parent 6620244 commit 7a96b84
Show file tree
Hide file tree
Showing 11 changed files with 59 additions and 74 deletions.
2 changes: 1 addition & 1 deletion _locales/en/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -1686,7 +1686,7 @@
"description": "A toast message telling the user that the mnemonic was copied"
},

"launcherViewTitle": {
"passwordViewTitle": {
"message": "Type in your password",
"description": "The title shown when user needs to type in a password to unlock the messenger"
},
Expand Down
2 changes: 1 addition & 1 deletion app/user_config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const path = require('path');

const app = require('electron').app || require('electron').remote.app;
const { app } = require('electron');

const { start } = require('./base_config');
const config = require('./config');
Expand Down
4 changes: 2 additions & 2 deletions js/launcher_start.js → js/password_start.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* global $, Whisper, storage */
/* global $, Whisper */
const $body = $(document.body);

// eslint-disable-next-line strict
window.view = new Whisper.LauncherView();
window.view = new Whisper.PasswordView();
$body.html('');
window.view.$el.prependTo($body);
8 changes: 4 additions & 4 deletions js/views/launcher_view.js → js/views/password_view.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@

window.Whisper = window.Whisper || {};

Whisper.LauncherView = Whisper.View.extend({
className: 'launcher full-screen-flow standalone-fullscreen',
templateName: 'launcher',
Whisper.PasswordView = Whisper.View.extend({
className: 'password full-screen-flow standalone-fullscreen',
templateName: 'password',
events: {
'click #unlock-button': 'onLogin',
},
Expand All @@ -20,7 +20,7 @@
},
render_attributes() {
return {
title: i18n('launcherViewTitle'),
title: i18n('passwordViewTitle'),
buttonText: i18n('unlock'),
};
},
Expand Down
84 changes: 35 additions & 49 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -415,47 +415,37 @@ function setupAsStandalone() {
}
}

let launcherWindow;
function showLauncher() {
if (launcherWindow) {
launcherWindow.show();
let passwordWindow;
function showPasswordWindow() {
if (passwordWindow) {
passwordWindow.show();
return;
}

const windowOptions = Object.assign(
{
show: !startInTray, // allow to start minimised in tray
width: DEFAULT_WIDTH,
height: DEFAULT_HEIGHT,
minWidth: MIN_WIDTH,
minHeight: MIN_HEIGHT,
autoHideMenuBar: false,
webPreferences: {
nodeIntegration: false,
nodeIntegrationInWorker: false,
// sandbox: true,
preload: path.join(__dirname, 'launcher_preload.js'),
nativeWindowOpen: true,
},
icon: path.join(__dirname, 'images', 'icon_256.png'),
const windowOptions = {
show: true, // allow to start minimised in tray
width: DEFAULT_WIDTH,
height: DEFAULT_HEIGHT,
minWidth: MIN_WIDTH,
minHeight: MIN_HEIGHT,
autoHideMenuBar: false,
webPreferences: {
nodeIntegration: false,
nodeIntegrationInWorker: false,
// sandbox: true,
preload: path.join(__dirname, 'password_preload.js'),
nativeWindowOpen: true,
},
_.pick(windowConfig, [
'maximized',
'autoHideMenuBar',
'width',
'height',
'x',
'y',
])
);
icon: path.join(__dirname, 'images', 'icon_256.png'),
};

launcherWindow = new BrowserWindow(windowOptions);
passwordWindow = new BrowserWindow(windowOptions);

launcherWindow.loadURL(prepareURL([__dirname, 'launcher.html']));
passwordWindow.loadURL(prepareURL([__dirname, 'password.html']));

captureClicks(launcherWindow);
captureClicks(passwordWindow);

launcherWindow.on('close', e => {
passwordWindow.on('close', e => {
// If the application is terminating, just do the default
if (
config.environment === 'test' ||
Expand All @@ -467,7 +457,7 @@ function showLauncher() {

// Prevent the shutdown
e.preventDefault();
launcherWindow.hide();
passwordWindow.hide();

// On Mac, or on other platforms when the tray icon is in use, the window
// should be only hidden, not closed, when the user clicks the close button
Expand All @@ -483,16 +473,12 @@ function showLauncher() {
return;
}

launcherWindow.readyForShutdown = true;
passwordWindow.readyForShutdown = true;
app.quit();
});

launcherWindow.on('closed', () => {
launcherWindow = null;
});

launcherWindow.once('ready-to-show', () => {
launcherWindow.show();
passwordWindow.on('closed', () => {
passwordWindow = null;
});
}

Expand Down Expand Up @@ -723,11 +709,11 @@ app.on('ready', async () => {

const key = getDefaultSQLKey();

// If we have a password set then show the launcher
// If we have a password set then show the password window
// Otherwise show the main window
const passHash = userConfig.get('passHash');
if (passHash) {
showLauncher();
showPasswordWindow();
} else {
await showMainWindow(key);
}
Expand Down Expand Up @@ -962,9 +948,9 @@ ipc.on('update-tray-icon', (event, unreadCount) => {
}
});

// Launch screen related IPC calls
ipc.on('launcher-login', async (event, passPhrase) => {
const sendError = (e) => event.sender.send('launcher-login-response', e);
// Password screen related IPC calls
ipc.on('password-window-login', async (event, passPhrase) => {
const sendError = (e) => event.sender.send('password-window-login-response', e);

// Check if the phrase matches with the hash we have stored
const hash = userConfig.get('passHash');
Expand All @@ -978,9 +964,9 @@ ipc.on('launcher-login', async (event, passPhrase) => {
const key = hash ? passPhrase : getDefaultSQLKey();
try {
await showMainWindow(key);
if (launcherWindow) {
launcherWindow.close();
launcherWindow = null;
if (passwordWindow) {
passwordWindow.close();
passwordWindow = null;
}
} catch (e) {
sendError('Failed to decrypt SQL database');
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@
"background.html",
"about.html",
"settings.html",
"launcher.html",
"password.html",
"permissions_popup.html",
"debug_log.html",
"_locales/**",
Expand Down
6 changes: 3 additions & 3 deletions launcher.html → password.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
<link href="stylesheets/manifest.css" rel="stylesheet" type="text/css" />
<style>
</style>
<script type='text/x-tmpl-mustache' id='launcher'>
<script type='text/x-tmpl-mustache' id='password'>
<div class='content-wrapper standalone'>
<div class='content'>
<h2>{{ title }}</h2>
Expand All @@ -31,7 +31,7 @@ <h2>{{ title }}</h2>

<script type='text/javascript' src='js/components.js'></script>
<script type='text/javascript' src='js/views/whisper_view.js'></script>
<script type='text/javascript' src='js/views/launcher_view.js'></script>
<script type='text/javascript' src='js/views/password_view.js'></script>
</head>
<body>
<div class='app-loading-screen'>
Expand All @@ -45,6 +45,6 @@ <h2>{{ title }}</h2>
<div class='message'></div>
</div>
</div>
<script type='text/javascript' src='js/launcher_start.js'></script>
<script type='text/javascript' src='js/password_start.js'></script>
</body>
</html>
9 changes: 2 additions & 7 deletions launcher_preload.js → password_preload.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@ const { ipcRenderer } = require('electron');
const url = require('url');
const i18n = require('./js/modules/i18n');

const passwordUtil = require('./app/password_util');
const userConfig = require('./app/user_config');

const config = url.parse(window.location.toString(), true).query;
const { locale } = config;
const localeMessages = ipcRenderer.sendSync('locale-data');
Expand All @@ -23,20 +20,18 @@ window.Signal = Signal.setup({
getRegionCode: () => null,
});

window.passwordUtil = passwordUtil;
window.userConfig = userConfig;
window.getEnvironment = () => config.environment;
window.getVersion = () => config.version;
window.getAppInstance = () => config.appInstance;

window.onLogin = (passPhrase) => new Promise((resolve, reject) => {
ipcRenderer.once('launcher-login-response', (event, error) => {
ipcRenderer.once('password-window-login-response', (event, error) => {
if (error) {
return reject(error);
}
return resolve();
});
ipcRenderer.send('launcher-login', passPhrase);
ipcRenderer.send('password-window-login', passPhrase);
});

require('./js/logging');
10 changes: 7 additions & 3 deletions stylesheets/_global.scss
Original file line number Diff line number Diff line change
Expand Up @@ -637,9 +637,12 @@ textarea {
width: 100%;
}
.step {
height: 100%;
width: 100%;
padding: 70px 0 50px;
display: flex;
align-items: center;
min-width: 100%;
min-height: 100%;
margin: auto;
padding: 10px 0;
}
.step-body {
margin-left: auto;
Expand All @@ -653,6 +656,7 @@ textarea {
justify-content: center;
flex-direction: column;
height: 100%;
width: 100%;
}

.banner-image {
Expand Down
4 changes: 2 additions & 2 deletions stylesheets/_launcher.scss → stylesheets/_password.scss
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.launcher {
.password {
.content-wrapper {
display: flex;
align-items: center;
Expand Down Expand Up @@ -26,4 +26,4 @@
font-size: 16px;
margin-top: 1em;
}
}
}
2 changes: 1 addition & 1 deletion stylesheets/manifest.scss
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
@import 'recorder';
@import 'emoji';
@import 'settings';
@import 'launcher';
@import 'password';

// Build the main view
@import 'index';
Expand Down

0 comments on commit 7a96b84

Please sign in to comment.