Skip to content

Commit

Permalink
Merge branch 'master' into 'release'
Browse files Browse the repository at this point in the history
Version 0.5.2-beta3

See merge request kirbo/slothy!12
  • Loading branch information
Kirbo committed Apr 26, 2019
2 parents 478db89 + b791245 commit 6ed8119
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 9 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Crash reporter.
- Ability to downgrade.

## [0.5.2-beta3] - 2019-04-26
### Fixed
- Adding new Slack instance (authorisation) was broken (again).
- When removing a Slack instance, removes also the configurations for it.

## [0.5.2-beta2] - 2019-04-26
### Fixed
- Auto updater bug.
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.2-beta2",
"version": "0.5.2-beta3",
"name": "slothy",
"description": "Changes your Slack status based on the SSID you're currently connected to.",
"productName": "Slothy",
Expand Down
5 changes: 4 additions & 1 deletion public/electron.js
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,10 @@ ipc
}
})
.on('getConnections', async () => sendIfMainWindow('connections', getConnections))
.on('removeSlackInstance', async (event, data) => sendIfMainWindow('slackInstances', removeSlackInstance, data))
.on('removeSlackInstance', async (event, data) => {
await sendIfMainWindow('slackInstances', removeSlackInstance, data);
sendIfMainWindow('configurations', getConfigurations);
})
.on('getConfigurations', async () => sendIfMainWindow('configurations', getConfigurations))
.on('saveConfiguration', async (event, data, updateNow = true) => {
await sendIfMainWindow('configurations', saveConfiguration, data);
Expand Down
6 changes: 3 additions & 3 deletions public/handlers/auth.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,13 @@ const handleAuth = (sendIfMainWindow, uri) => {
};

request(options, async (error, response, body) => {
const { ok, accessToken } = JSON.parse(body);
const { ok, access_token } = JSON.parse(body); // eslint-disable-line camelcase
if (!ok) {
sendIfMainWindow('error', () => 'Error in authentication!');
throw error;
} else {
const token = {
token: accessToken,
token: access_token,
};
const profile = await getStatus(token);
const workspace = await getWorkspace(token);
Expand All @@ -43,7 +43,7 @@ const handleAuth = (sendIfMainWindow, uri) => {

if (profile) {
instance = await saveSlackInstance({
token: accessToken,
token: access_token,
profile,
});
}
Expand Down
8 changes: 6 additions & 2 deletions public/handlers/slackInstances.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,10 +85,13 @@ const saveSlackInstance = instance => (
* @param {object} slackInstance - Slack instance to remove.
* @returns {array} slackInstances
*/
const removeSlackInstance = ({ token }) => (
const removeSlackInstance = ({ id, token }) => (
new Promise(async (resolve, reject) => {
try {
resolve(await storage.set('slackInstances', (await getSlackInstances()).filter(instance => instance.token !== token)));
const slackInstances = await getSlackInstances();
await storage.set('configurations', (await getConfigurations()).filter(({ instanceId }) => instanceId !== id));
const filteredSlackInstances = slackInstances.filter(instance => instance.token !== token);
resolve(await storage.set('slackInstances', filteredSlackInstances));
} catch (error) {
log.error('removeSlackInstance', error);
reject(error);
Expand All @@ -103,4 +106,5 @@ module.exports = {
removeSlackInstance,
};

const { getConfigurations } = require('./configurations');
const { getWorkspace, getWorkspaceEmojis } = require('./workspaces');
2 changes: 1 addition & 1 deletion src/component/Menu/MenuConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export const contextMenu = (instance, removeSlackInstance) => (
<Menu>
<Menu.Item
key="remove-instance"
onClick={() => showDeleteConfirm(instance.name, () => removeSlackInstance(instance.token))}
onClick={() => showDeleteConfirm(instance.name, () => removeSlackInstance(instance))}
>
<RemoveInstance>
<Icon icon={['far', 'trash-alt']} /> Remove {instance.name}
Expand Down
3 changes: 2 additions & 1 deletion src/container/App/AppProvider.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,9 @@ const closeOtherNotifications = (skip = '') => {
class AppProvider extends Component {
state = {
...INITIAL_STATE,
removeSlackInstance: token => {
removeSlackInstance: ({ token, id }) => {
ipcRenderer.send('removeSlackInstance', {
id,
token,
});
},
Expand Down

0 comments on commit 6ed8119

Please sign in to comment.