Skip to content

Commit 161c2b2

Browse files
Merge pull request #210 from ekonstantinidis/fix-autolaunch
Fix Autolaunch
2 parents 31de096 + 7bb3458 commit 161c2b2

File tree

5 files changed

+84
-2
lines changed

5 files changed

+84
-2
lines changed

main.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@ var isWindows = (process.platform === 'win32');
2323

2424
var autoStart = new AutoLaunch({
2525
name: 'Gitify',
26-
path: process.execPath.match(/.*?\.app/)[0]
26+
path: process.execPath.match(/.*?\.app/)[0],
27+
isHidden: true
2728
});
2829

2930
app.on('ready', function() {

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848
},
4949
"homepage": "https://github.com/ekonstantinidis/gitify",
5050
"dependencies": {
51-
"auto-launch": "=2.0.1",
51+
"auto-launch": "=4.0.0",
5252
"bootstrap": "=4.0.0-alpha.2",
5353
"electron-gh-releases": "=2.0.3",
5454
"electron-positioner": "=3.0.0",
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
import { expect } from 'chai';
2+
import * as actions from '../../actions';
3+
import settingsMiddleware from '../../middleware/settings';
4+
const ipcRenderer = window.require('electron').ipcRenderer;
5+
6+
const createFakeStore = fakeData => ({
7+
getState() {
8+
return {
9+
notifications: {},
10+
settings: {
11+
openAtStartup: false,
12+
playSound: false,
13+
showNotifications: false
14+
}
15+
};
16+
}
17+
});
18+
19+
const dispatchWithStoreOf = (storeData, action) => {
20+
let dispatched = null;
21+
const dispatch = settingsMiddleware(createFakeStore(storeData))(actionAttempt => dispatched = actionAttempt);
22+
dispatch(action);
23+
return dispatched;
24+
};
25+
26+
describe('middleware/settings.js', () => {
27+
28+
beforeEach(function() {
29+
ipcRenderer.send.reset();
30+
});
31+
32+
it('should mark auto-launch setting to true (enable)', () => {
33+
34+
const action = {
35+
type: actions.UPDATE_SETTING,
36+
setting: 'openAtStartup',
37+
value: true
38+
};
39+
40+
expect(dispatchWithStoreOf({}, action)).to.eql(action);
41+
42+
expect(ipcRenderer.send).to.have.been.calledOnce;
43+
expect(ipcRenderer.send).to.have.been.calledWith('startup-enable');
44+
45+
});
46+
47+
it('should mark auto-launch setting to false (disable)', () => {
48+
49+
const action = {
50+
type: actions.UPDATE_SETTING,
51+
setting: 'openAtStartup',
52+
value: false
53+
};
54+
55+
expect(dispatchWithStoreOf({}, action)).to.eql(action);
56+
57+
expect(ipcRenderer.send).to.have.been.calledOnce;
58+
expect(ipcRenderer.send).to.have.been.calledWith('startup-disable');
59+
60+
});
61+
});

src/js/middleware/settings.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
const ipcRenderer = window.require('electron').ipcRenderer;
2+
import { UPDATE_SETTING } from '../actions';
3+
4+
export default store => next => action => {
5+
6+
switch (action.type) {
7+
case UPDATE_SETTING:
8+
if (action.setting === 'openAtStartup') {
9+
if (action.value) {
10+
ipcRenderer.send('startup-enable');
11+
} else {
12+
ipcRenderer.send('startup-disable');
13+
}
14+
}
15+
}
16+
17+
return next(action);
18+
};

src/js/store/configureStore.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import filter from 'redux-storage-decorator-filter';
88
import { fetchNotifications, UPDATE_SETTING, LOGIN_SUCCESS, LOGOUT } from '../actions';
99
import constants from '../utils/constants';
1010
import notifications from '../middleware/notifications';
11+
import settings from '../middleware/settings';
1112
import requests from '../middleware/requests';
1213
import rootReducer from '../reducers';
1314

@@ -19,6 +20,7 @@ export default function configureStore(initialState) {
1920
requests, // Should be passed before 'apiMiddleware'
2021
apiMiddleware,
2122
notifications,
23+
settings,
2224
storageMiddleware
2325
)(createStore);
2426

0 commit comments

Comments
 (0)