Skip to content

Commit 6681205

Browse files
committed
Slight grab-bag of fixes for electron on Windows
* Implement the squirrel install / uninstall hooks (so we have a start menu entry / desktop shortcut) * Wait longer before checking for update * Set the window icon * Add a 'file' menu * Bump electron-builder * Add the icon url for the control panel entry
1 parent 6da1a10 commit 6681205

3 files changed

Lines changed: 32 additions & 5 deletions

File tree

‎electron/src/electron-main.js‎

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,12 @@ See the License for the specific language governing permissions and
1717
limitations under the License.
1818
*/
1919

20+
// Squirrel on windows starts the app with various flags
21+
// as hooks to tell us when we've been installed/uninstalled
22+
// etc.
23+
const check_squirrel_hooks = require('./squirrelhooks');
24+
if (check_squirrel_hooks()) return;
25+
2026
const electron = require('electron');
2127
const url = require('url');
2228

@@ -29,6 +35,7 @@ const PERMITTED_URL_SCHEMES = [
2935
];
3036

3137
const UPDATE_POLL_INTERVAL_MS = 60 * 60 * 1000;
38+
const INITIAL_UPDATE_DELAY_MS = 30 * 1000;
3239

3340
let mainWindow = null;
3441
let appQuitting = false;
@@ -107,15 +114,18 @@ electron.app.on('ready', () => {
107114
// do it in the main process (and we don't really need to check every 10 minutes:
108115
// every hour should be just fine for a desktop app)
109116
// However, we still let the main window listen for the update events.
110-
pollForUpdates();
117+
// We also wait a short time before checking for updates the first time because
118+
// of squirrel on windows and it taking a small amount of time to release a
119+
// lock file.
120+
setTimeout(pollForUpdates, INITIAL_UPDATE_DELAY_MS);
111121
setInterval(pollForUpdates, UPDATE_POLL_INTERVAL_MS);
112122
} catch (err) {
113123
// will fail if running in debug mode
114124
console.log("Couldn't enable update checking", err);
115125
}
116126

117127
mainWindow = new electron.BrowserWindow({
118-
icon: `${__dirname}/../../vector/img/logo.png`,
128+
icon: `${__dirname}/../img/riot.ico`,
119129
width: 1024, height: 768,
120130
});
121131
mainWindow.loadURL(`file://${__dirname}/../../vector/index.html`);

‎electron/src/vectormenu.js‎

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,20 @@ if (process.platform === 'darwin') {
182182
role: 'front'
183183
}
184184
]
185-
};
185+
} else {
186+
template.unshift({
187+
label: 'File',
188+
submenu: [
189+
// For some reason, 'about' does not seem to work on windows.
190+
/*{
191+
role: 'about'
192+
},*/
193+
{
194+
role: 'quit'
195+
}
196+
]
197+
});
198+
}
186199

187200
module.exports = electron.Menu.buildFromTemplate(template)
188201

‎package.json‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@
9393
"catw": "^1.0.1",
9494
"cpx": "^1.3.2",
9595
"css-raw-loader": "^0.1.1",
96-
"electron-builder": "^7.10.2",
96+
"electron-builder": "^7.23.2",
9797
"emojione": "^2.2.3",
9898
"expect": "^1.16.0",
9999
"fs-extra": "^0.30.0",
@@ -132,9 +132,13 @@
132132
"files": [
133133
"!**/*",
134134
"electron/src/**",
135+
"electron/img/**",
135136
"vector/**",
136137
"package.json"
137-
]
138+
],
139+
"squirrelWindows": {
140+
"iconUrl": "https://riot.im/favicon.ico"
141+
}
138142
},
139143
"directories": {
140144
"buildResources": "electron/build",

0 commit comments

Comments
 (0)