Skip to content

Commit

Permalink
Version 0.5.1-beta
Browse files Browse the repository at this point in the history
  • Loading branch information
Kirbo committed Apr 25, 2019
1 parent a9bf80b commit 334e4e5
Show file tree
Hide file tree
Showing 11 changed files with 88 additions and 49 deletions.
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ node_modules/*
build/*
pages/*
coverage/*
dist/*
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [Unreleased]
### Added
- Crash reporter.
- Ability to downgrade.

## [0.5.1] - 2019-04-25
### Fixed
- Bug fixes that made the application to crash, due too heavy refactoring.
- `Reload` button for connections is disabled when connections are being reloaded via timer.
- `Enabled`/`Disabled` radio button on modifying existing configuration was not working, due refactoring.

## [0.5.0] - 2019-04-25
### Added
Expand Down
47 changes: 23 additions & 24 deletions config-overrides.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ const CopyWebpackPlugin = require('copy-webpack-plugin');
const { COLOR } = require('./src/assets/css/colors');

module.exports = {
webpack: (config, env) => (
override(
webpack: (config, env) => {
const newConfig = override(
fixBabelImports('import', {
libraryName: 'antd',
libraryDirectory: 'es',
Expand All @@ -18,30 +18,29 @@ module.exports = {
'@primary-color': COLOR.red,
},
}),
process.env.NODE_ENV === 'production'
? () => {
if (!config.plugins) {
config.plugins = [];
}
)(config, env);

config.plugins.push(
new CopyWebpackPlugin([
{
from: 'src/assets/icons',
to: 'icons',
},
{
from: 'src/assets/logo-text',
to: 'logo-text',
},
]),
);
if (process.env.NODE_ENV === 'production') {
if (!newConfig.plugins) {
newConfig.plugins = [];
}

return config;
}
: config,
)(config, env)
),
newConfig.plugins.push(
new CopyWebpackPlugin([
{
from: 'src/assets/icons',
to: 'icons',
},
{
from: 'src/assets/logo-text',
to: 'logo-text',
},
]),
);
}

return newConfig;
},
jest: config => ({
...config,
bail: false,
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version": "0.5.0",
"version": "0.5.1-beta",
"name": "slothy",
"description": "Changes your Slack status based on the SSID you're currently connected to.",
"productName": "Slothy",
Expand Down
8 changes: 6 additions & 2 deletions public/electron.js
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,10 @@ const updateStatusesFunction = async () => {
*/
const startTimers = async (runNow = true) => {
setTimer('slackInstances', () => ifComputerRunning(() => sendIfMainWindow('slackInstances', getWorkspaces)), runNow);
setTimer('connections', () => ifComputerRunning(() => sendIfMainWindow('connections', getConnections)), runNow);
setTimer('connections', async () => {
ifComputerRunning(() => sendIfMainWindow('scanningConnections', () => null));
ifComputerRunning(() => sendIfMainWindow('connections', getConnections));
}, runNow);
setTimer('updateStatus', updateStatusesFunction, runNow);
};

Expand Down Expand Up @@ -273,7 +276,7 @@ const createWindow = async () => {

mainWindow.loadURL(startUrl);

Menu.setApplicationMenu(Menu.buildFromTemplate(menuTemplate(autoUpdater, resetApp)));
Menu.setApplicationMenu(Menu.buildFromTemplate(menuTemplate(autoUpdater, resetApp, config.updates.allowDowngrade)));

mainWindow
.once('ready-to-show', () => {
Expand Down Expand Up @@ -421,6 +424,7 @@ ipc
await startTimers(false);
}
config = appConfigurations;
Menu.setApplicationMenu(Menu.buildFromTemplate(menuTemplate(autoUpdater, resetApp, config.updates.allowDowngrade)));
setAutoUpdater();
await sendIfMainWindow('appConfigurations', () => appConfigurations);
})
Expand Down
8 changes: 4 additions & 4 deletions public/handlers/status.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,8 @@ const setStatus = ({ token, emoji, status }) => (
/**
* Update status in all Slack instances.
*/
const updateStatuses = () => {
Promise(async (resolve, reject) => {
const updateStatuses = () => (
new Promise(async (resolve, reject) => {
try {
(await getEnabledConfigurations())
.forEach(({ token, emoji, status }) => {
Expand All @@ -82,8 +82,8 @@ const updateStatuses = () => {
log.error('updateStatuses', error);
reject(error);
}
});
};
})
);

module.exports = {
getStatus,
Expand Down
30 changes: 22 additions & 8 deletions public/menuTemplate.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,29 @@ const { shell } = electron;
* Populate application menu
* @param {object} autoUpdater - autoUpdater object.
* @param {function} resetApp - resetApp function.
* @param {boolean} allowDowngrade - Is downgrade allowed.
* @returns {array} menuTemplate
*/
// const menuTemplate = (autoUpdater, resetApp, allowDowngrade) => {
const menuTemplate = (autoUpdater, resetApp) => {
const updateOptions = (
// allowDowngrade
// TODO: enable downgrade
false // eslint-disable-line no-constant-condition
? [{
label: 'Check for updates',
click: () => { autoUpdater.checkForUpdates(); },
},
{
label: 'Downgrade to latest Stable',
click: () => { autoUpdater.checkForUpdates(); },
}]
: [{
label: 'Check for updates',
click: () => { autoUpdater.checkForUpdates(); },
}]
);

const MENU_TEMPLATE = [
{
label: 'Edit',
Expand Down Expand Up @@ -135,10 +155,7 @@ const menuTemplate = (autoUpdater, resetApp) => {
{
type: 'separator',
},
{
label: 'Check for updates',
click: () => { autoUpdater.checkForUpdates(); },
},
...updateOptions,
{
role: 'services',
submenu: [],
Expand Down Expand Up @@ -168,10 +185,7 @@ const menuTemplate = (autoUpdater, resetApp) => {
MENU_TEMPLATE.push({
role: 'help',
submenu: [
{
label: 'Check for updates',
click: () => { autoUpdater.checkForUpdates(); },
},
...updateOptions,
{
label: 'Official website',
click: () => { shell.openExternal(packageJson.product.Pages); },
Expand Down
5 changes: 4 additions & 1 deletion src/component/Icon/Icon.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,10 @@ const Icon = ({ icon, size }) => (
);

Icon.propTypes = {
icon: PropTypes.string.isRequired,
icon: PropTypes.oneOfType([
PropTypes.string,
PropTypes.array,
]).isRequired,
size: PropTypes.oneOf(Object.keys(DIMENSION)),
};

Expand Down
2 changes: 1 addition & 1 deletion src/component/ModifyConfiguration/ModifyConfiguration.js
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ const ModifyConfiguration = ({ form }) => {
{getFieldDecorator('enabled', {
initialValue: drawerConfig.config
&& Object.prototype.hasOwnProperty.call(drawerConfig.config, 'enabled')
? drawerConfig.config.enable
? drawerConfig.config.enabled
: true,
})(
<Radio.Group buttonStyle="solid">
Expand Down
21 changes: 14 additions & 7 deletions src/container/App/AppProvider.js
Original file line number Diff line number Diff line change
Expand Up @@ -122,18 +122,24 @@ class AppProvider extends Component {
};

componentDidMount = () => {
const { setProperty, ssids, appConfigurations } = this.state;
const { setProperty, appConfigurations } = this.state;
ipcRenderer.send('initialize');

ipcRenderer
.on('connections', (event, { newSsids, currentSsids }) => {
.on('connections', (event, props) => {
const { ssids } = this.state;
setProperty({
ssids: !!ssids.length && !newSsids.length ? ssids : newSsids,
currentSsids,
wifiEnabled: !!ssids.length || !!currentSsids.length,
ssids: !!ssids.length && !ssids.length ? ssids : props.ssids,
currentSsids: props.currentSsids,
wifiEnabled: !!ssids.length || !!props.currentSsids.length,
ssidsLoaded: true,
});
})
.on('scanningConnections', () => {
setProperty({
ssidsLoaded: false,
});
})
.on('configurations', (event, configurations) => {
setProperty({
configurationsLoaded: true,
Expand Down Expand Up @@ -213,10 +219,10 @@ class AppProvider extends Component {
}
notification[data.type || 'open']({
message: data.title,
description: <div dangerouslySetInnerHTML={{
description: <div dangerouslySetInnerHTML={{ // eslint-disable-line react/no-danger
__html: description,
}}
/>, // eslint-disable-line react/no-danger
/>,
duration: 0,
key: 'update-notification',
btn: (
Expand Down Expand Up @@ -318,6 +324,7 @@ class AppProvider extends Component {
[
'appConfigurations',
'connections',
'scanningConnections',
'configurations',
'slackInstances',
'newSlackInstance',
Expand Down
6 changes: 5 additions & 1 deletion src/container/Loading/Loading.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,14 @@ class Loading extends Component {
}
}

Loading.defaultProps = {
appConfigurationsLoaded: false,
};

Loading.propTypes = {
slackInstancesLoaded: PropTypes.bool.isRequired,
configurationsLoaded: PropTypes.bool.isRequired,
appConfigurationsLoaded: PropTypes.bool.isRequired,
appConfigurationsLoaded: PropTypes.bool,
hideLoading: PropTypes.bool.isRequired,
setProperty: PropTypes.func.isRequired,
};
Expand Down

0 comments on commit 334e4e5

Please sign in to comment.