mirror of
https://github.com/Kong/insomnia
synced 2024-11-07 22:30:15 +00:00
Cap window bounds and update notification'
This commit is contained in:
parent
c56b938e20
commit
493b4fcfab
@ -6,7 +6,7 @@ export const LOCALSTORAGE_KEY = 'insomnia.state';
|
||||
export const DB_PERSIST_INTERVAL = 1000 * 60 * 10;
|
||||
export const DEBOUNCE_MILLIS = 100;
|
||||
export const REQUEST_TIME_TO_SHOW_COUNTER = 1; // Seconds
|
||||
export const CHECK_FOR_UPDATES_INTERVAL = 1000 * 60 * 60 * 24; // 1 day
|
||||
export const CHECK_FOR_UPDATES_INTERVAL = 1000 * 60 * 60 * 3; // 3 hours
|
||||
export const CHANGELOG_URL = 'https://changelog.insomnia.rest/changelog.json';
|
||||
export const STATUS_CODE_PEBKAC = -333;
|
||||
export const LARGE_RESPONSE_MB = 10;
|
||||
|
82
app/main.js
82
app/main.js
@ -24,11 +24,11 @@ if (!IS_DEV) {
|
||||
}
|
||||
|
||||
// Don't npm install this (it breaks). Rely on the global one.
|
||||
const electron = require('electron');
|
||||
const request = require('request');
|
||||
const path = require('path');
|
||||
const {version: appVersion, productName: appName} = require('./package.json');
|
||||
const {LocalStorage} = require('node-localstorage');
|
||||
const electron = require('electron');
|
||||
const {
|
||||
app,
|
||||
dialog,
|
||||
@ -38,7 +38,7 @@ const {
|
||||
Menu,
|
||||
BrowserWindow,
|
||||
webContents
|
||||
} = electron;
|
||||
} = require('electron');
|
||||
|
||||
const UPDATE_URLS = {
|
||||
// Add `r` param to help cache bust
|
||||
@ -85,17 +85,17 @@ autoUpdater.on('update-available', () => {
|
||||
|
||||
autoUpdater.on('update-downloaded', (e, releaseNotes, releaseName, releaseDate, updateUrl) => {
|
||||
console.log(`-- Update Downloaded ${releaseName} --`);
|
||||
showUpdateModal();
|
||||
showUpdateNotification();
|
||||
});
|
||||
|
||||
function checkForUpdates () {
|
||||
if (IS_DEV) {
|
||||
console.log('Skipping update check in Development');
|
||||
if (hasPromptedForUpdates) {
|
||||
// We've already prompted for updates. Don't bug the user anymore
|
||||
return;
|
||||
}
|
||||
|
||||
if (hasPromptedForUpdates) {
|
||||
// We've already prompted for updates. Don't bug the user anymore
|
||||
if (IS_DEV) {
|
||||
console.log('Skipping update check in Development');
|
||||
return;
|
||||
}
|
||||
|
||||
@ -129,10 +129,7 @@ function checkForUpdates () {
|
||||
function showUnresponsiveModal () {
|
||||
dialog.showMessageBox({
|
||||
type: 'info',
|
||||
buttons: [
|
||||
'Cancel',
|
||||
'Reload',
|
||||
],
|
||||
buttons: ['Cancel', 'Reload',],
|
||||
defaultId: 1,
|
||||
cancelId: 0,
|
||||
title: 'Unresponsive',
|
||||
@ -145,27 +142,18 @@ function showUnresponsiveModal () {
|
||||
});
|
||||
}
|
||||
|
||||
function showUpdateModal () {
|
||||
hasPromptedForUpdates = true;
|
||||
function showUpdateNotification () {
|
||||
if (hasPromptedForUpdates) {
|
||||
return;
|
||||
}
|
||||
|
||||
dialog.showMessageBox({
|
||||
type: 'info',
|
||||
buttons: [
|
||||
'Install and Restart',
|
||||
'Later',
|
||||
],
|
||||
defaultId: 0,
|
||||
cancelId: 1,
|
||||
title: 'Insomnia Update Available',
|
||||
message: 'Exciting news!\n\nA new version of Insomnia has been downloaded and is ready to install\n\n\n~Gregory'
|
||||
}, id => {
|
||||
if (id === 0) {
|
||||
console.log('-- Installing Update --');
|
||||
autoUpdater.quitAndInstall();
|
||||
} else {
|
||||
console.log('-- Cancel Update --');
|
||||
}
|
||||
});
|
||||
const window = BrowserWindow.getFocusedWindow();
|
||||
if (!window || !window.webContents) {
|
||||
return;
|
||||
}
|
||||
|
||||
window.send('update-available');
|
||||
hasPromptedForUpdates = true;
|
||||
}
|
||||
|
||||
function showDownloadModal (version) {
|
||||
@ -173,10 +161,7 @@ function showDownloadModal (version) {
|
||||
|
||||
dialog.showMessageBox({
|
||||
type: 'info',
|
||||
buttons: [
|
||||
'Download',
|
||||
'Later',
|
||||
],
|
||||
buttons: ['Download', 'Later'],
|
||||
defaultId: 0,
|
||||
cancelId: 1,
|
||||
title: 'Insomnia Update Available',
|
||||
@ -296,16 +281,23 @@ function createWindow () {
|
||||
|
||||
const zoomFactor = getZoomFactor();
|
||||
const {bounds, fullscreen} = getBounds();
|
||||
const {
|
||||
x,
|
||||
y,
|
||||
width,
|
||||
height
|
||||
} = bounds;
|
||||
const {x, y, width, height} = bounds;
|
||||
|
||||
// Make sure we don't place the window outside of the visible space
|
||||
let maxX = 0;
|
||||
let maxY = 0;
|
||||
for (const d of electron.screen.getAllDisplays()) {
|
||||
// Set the maximum placement location to 50 pixels short of the end
|
||||
maxX = Math.max(maxX, d.bounds.x + d.bounds.width - 50);
|
||||
maxY = Math.max(maxY, d.bounds.y + d.bounds.height - 50);
|
||||
}
|
||||
const finalX = Math.min(maxX, x);
|
||||
const finalY = Math.min(maxX, y);
|
||||
|
||||
mainWindow = new BrowserWindow({
|
||||
x: x,
|
||||
y: y,
|
||||
// Make sure we don't initialize the window outside the bounds
|
||||
x: finalX,
|
||||
y: finalY,
|
||||
fullscreen: fullscreen,
|
||||
fullscreenable: true,
|
||||
title: appName,
|
||||
@ -493,14 +485,14 @@ function createWindow () {
|
||||
{
|
||||
label: "Contact Support",
|
||||
click: () => {
|
||||
electron.shell.openExternal('mailto:support@insomnia.rest');
|
||||
shell.openExternal('mailto:support@insomnia.rest');
|
||||
}
|
||||
},
|
||||
{
|
||||
label: "Insomnia Help",
|
||||
accelerator: "CmdOrCtrl+?",
|
||||
click: () => {
|
||||
electron.shell.openExternal('http://docs.insomnia.rest');
|
||||
shell.openExternal('http://docs.insomnia.rest');
|
||||
}
|
||||
}
|
||||
]
|
||||
|
BIN
app/static/notify-icon.png
Normal file
BIN
app/static/notify-icon.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 4.1 KiB |
@ -396,6 +396,12 @@ class App extends Component {
|
||||
db.workspace.update(workspace, {metaSidebarHidden});
|
||||
}
|
||||
|
||||
_showUpdateNotification () {
|
||||
new Notification('Insomnia Update Ready', {
|
||||
body: 'Relaunch the app for it to take effect'
|
||||
});
|
||||
}
|
||||
|
||||
componentWillReceiveProps (nextProps) {
|
||||
const sidebarWidth = this._getActiveWorkspace(nextProps).metaSidebarWidth;
|
||||
this.setState({sidebarWidth});
|
||||
@ -442,6 +448,10 @@ class App extends Component {
|
||||
getModal(SettingsModal).toggle();
|
||||
});
|
||||
|
||||
ipcRenderer.on('update-available', () => {
|
||||
console.log('-- Update Available --');
|
||||
this._showUpdateNotification();
|
||||
});
|
||||
|
||||
ipcRenderer.on('toggle-sidebar', this._handleToggleSidebar.bind(this));
|
||||
}
|
||||
|
@ -84,8 +84,8 @@
|
||||
"tough-cookie": "^2.3.1",
|
||||
"traverse": "^0.6.6",
|
||||
"vkbeautify": "^0.99.1",
|
||||
"xpath": "^0.0.23",
|
||||
"xmldom": "^0.1.22"
|
||||
"xmldom": "^0.1.22",
|
||||
"xpath": "^0.0.23"
|
||||
},
|
||||
"devDependencies": {
|
||||
"babel-cli": "^6.11.4",
|
||||
|
@ -25,7 +25,7 @@ echo "-- COPYING REMAINING FILES --"
|
||||
cp app/package.json "$BUILD_DIR"
|
||||
|
||||
# Copy some things
|
||||
cp -r app/external assets/* app/main.js "$BUILD_DIR/"
|
||||
cp -r app/external assets/* app/static app/main.js "$BUILD_DIR/"
|
||||
|
||||
echo "-- INSTALLING PACKAGES --"
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user