Skip to content

Commit 9c2d9d7

Browse files
committed
1.0.5
1 parent 413088a commit 9c2d9d7

77 files changed

Lines changed: 53 additions & 43205 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
node_modules
22
!app/node_modules
3+
electron
34
build
45
release

Gruntfile.coffee

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ grunt.loadNpmTasks 'grunt-contrib-copy'
66
grunt.loadNpmTasks 'grunt-rcedit'
77
grunt.loadNpmTasks 'grunt-electron-installer'
88
grunt.loadNpmTasks 'grunt-shell'
9+
grunt.loadNpmTasks 'grunt-download-electron'
910

1011
version = require('./package.json').version
1112

@@ -21,6 +22,10 @@ grunt.initConfig
2122
run:
2223
command: path.resolve(__dirname, 'build', 'birdex.exe')
2324

25+
'download-electron':
26+
version: '0.36.3'
27+
outputDir: 'electron'
28+
2429
copy:
2530
electron:
2631
expand: true
@@ -62,5 +67,5 @@ grunt.initConfig
6267
iconUrl: 'https://cdn.rawgit.com/AlgorithmLLC/chat-client-electron/master/app/birdex.ico'
6368
remoteReleases: 'https://github.com/AlgorithmLLC/chat-client-electron'
6469

65-
grunt.registerTask 'build', ['shell:kill', 'clean', 'copy', 'rcedit', 'shell:run', 'shell:kill']
66-
grunt.registerTask 'default', ['shell:kill', 'clean', 'copy', 'rcedit', 'create-windows-installer', 'clean:build']
70+
grunt.registerTask 'build', ['shell:kill', 'clean', 'download-electron', 'copy', 'rcedit', 'shell:run', 'shell:kill']
71+
grunt.registerTask 'default', ['shell:kill', 'clean', 'download-electron', 'copy', 'rcedit', 'create-windows-installer', 'clean:build']

app/main.js

Lines changed: 42 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,13 @@
22
const electron = require('electron');
33
const app = electron.app;
44
const BrowserWindow = electron.BrowserWindow;
5-
const localShortcut = require('electron-localshortcut');
65

76
const APP_URL = 'app://birdex/index.html'; // birdex.asar
87
// const APP_URL = 'http://new.001.birdex.org/';
98
// const APP_URL = 'http://oleg.dev:8000/index-dev.html';
109
// const APP_URL = 'http://oleg.dev:8000/index.html';
1110

12-
const handleSetupEvent = function() {
11+
const handleStartupEvent = function() {
1312
if (process.argv.length === 1) {
1413
return false;
1514
}
@@ -49,7 +48,6 @@ const handleSetupEvent = function() {
4948

5049
spawnUpdate(['--createShortcut', exeName]);
5150

52-
setTimeout(app.quit, 1000);
5351
return true;
5452

5553
case '--squirrel-uninstall':
@@ -58,74 +56,52 @@ const handleSetupEvent = function() {
5856

5957
spawnUpdate(['--removeShortcut', exeName]);
6058

61-
setTimeout(app.quit, 1000);
6259
return true;
6360

6461
case '--squirrel-obsolete':
6562
// This is called on the outgoing version of your app before
6663
// we update to the new version - it's the opposite of
6764
// --squirrel-updated
6865

69-
app.quit();
7066
return true;
7167
}
7268
};
73-
if (handleSetupEvent()) {
74-
return;
69+
if (handleStartupEvent()) {
70+
return setTimeout(app.quit, 1000);
7571
}
7672

77-
function devTools() {
78-
const win = BrowserWindow.getFocusedWindow();
79-
80-
if (win) {
81-
win.toggleDevTools();
73+
app.on('ready', () => {
74+
const localShortcut = require('electron-localshortcut');
75+
const openDevTools = function() {
76+
const win = BrowserWindow.getFocusedWindow();
77+
if (win) {
78+
win.toggleDevTools();
79+
}
8280
}
83-
}
84-
85-
function refresh() {
86-
const win = BrowserWindow.getFocusedWindow();
8781

88-
// return console.log(APP_URL.substr(3));
89-
if (win) {
90-
if (APP_URL.substr(0, 3) === 'app') {
91-
win.loadURL(APP_URL);
92-
} else {
93-
win.webContents.reloadIgnoringCache();
82+
const refresh = function() {
83+
const win = BrowserWindow.getFocusedWindow();
84+
if (win) {
85+
if (APP_URL.substr(0, 3) === 'app') {
86+
win.loadURL(APP_URL);
87+
} else {
88+
win.webContents.reloadIgnoringCache();
89+
}
9490
}
9591
}
96-
}
9792

98-
app.on('ready', () => {
99-
localShortcut.register('Ctrl+Shift+I', devTools);
100-
localShortcut.register('F12', devTools);
93+
localShortcut.register('Ctrl+Shift+I', openDevTools);
94+
localShortcut.register('F12', openDevTools);
10195

10296
localShortcut.register('CmdOrCtrl+R', refresh);
10397
localShortcut.register('F5', refresh);
10498
});
10599

106-
let downloadedUpdate = false;
107-
108-
const GhReleases = require('electron-gh-releases')
109-
let options = {
110-
repo: 'AlgorithmLLC/chat-client-electron',
111-
currentVersion: app.getVersion()
112-
};
113-
const updater = new GhReleases(options);
114-
// Check for updates
115-
// `status` returns true if there is a new update available
116-
updater.check((err, status) => {
117-
if (!err && status) {
118-
// Download the update
119-
updater.download();
120-
}
121-
});
122-
123100
// Quit when all windows are closed.
124101
app.on('window-all-closed', function() {
125102
app.quit();
126103
});
127104

128-
129105
let mainWindow;
130106
// This method will be called when Electron has finished
131107
// initialization and is ready to create browser windows.
@@ -135,21 +111,23 @@ app.on('ready', function() {
135111
let url = request.url.substr(12);
136112
callback({path: require('path').normalize(__dirname + '/birdex.asar/' + url)});
137113
}, function (error) {
138-
if (error)
139-
console.error('Failed to register protocol')
114+
if (error) {
115+
console.error('Failed to register protocol');
116+
}
140117
});
141118

142119
// bugfix for <img ng-src> requesting unsafe:app://birdex/path
143120
protocol.registerFileProtocol('unsafe', function(request, callback) {
144121
let url = request.url.substr(19);
145122
callback({path: require('path').normalize(__dirname + '/birdex.asar/' + url)});
146123
}, function (error) {
147-
if (error)
148-
console.error('Failed to register protocol')
124+
if (error) {
125+
console.error('Failed to register protocol');
126+
}
149127
});
150128

151129
// Create the browser window.
152-
mainWindow = new electron.BrowserWindow({
130+
mainWindow = new BrowserWindow({
153131
width: 1280
154132
, height: 720
155133
, minHeight: 720
@@ -161,12 +139,26 @@ app.on('ready', function() {
161139

162140
// and load the index.html of the app.
163141
mainWindow.loadURL(APP_URL);
164-
165142
// Emitted when the window is closed.
166143
mainWindow.on('closed', function() {
167144
// Dereference the window object, usually you would store windows
168145
// in an array if your app supports multi windows, this is the time
169146
// when you should delete the corresponding element.
170147
mainWindow = null;
171148
});
149+
150+
const GhReleases = require('electron-gh-releases');
151+
let options = {
152+
repo: 'AlgorithmLLC/chat-client-electron',
153+
currentVersion: app.getVersion()
154+
};
155+
const updater = new GhReleases(options);
156+
// Check for updates
157+
// `status` returns true if there is a new update available
158+
updater.check((err, status) => {
159+
if (!err && status) {
160+
// Download the update
161+
updater.download();
162+
}
163+
});
172164
});

electron/LICENSE

Lines changed: 0 additions & 20 deletions
This file was deleted.

0 commit comments

Comments
 (0)