Skip to content

Commit

Permalink
fix: accoutin deletion on logout
Browse files Browse the repository at this point in the history
  • Loading branch information
ilya-lopukhin committed Mar 15, 2018
1 parent 40956d3 commit 280ff32
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions app/sagas/auth.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import {
import Raven from 'raven-js';

import * as Api from 'api';
import * as R from 'ramda';

import {
actionTypes,
Expand Down Expand Up @@ -115,7 +116,7 @@ function* saveAccount(payload: { host: string, username: string }): Generator<*,
const { host, username } = payload;
let accounts = yield call(getFromStorage, 'accounts');
if (!accounts) accounts = [];
if (!accounts.find(ac => ac.host === host && ac.username === username)) {
if (!R.find(R.whereEq({ host, username }), accounts)) {
accounts.push(payload);
yield call(setToStorage, 'accounts', accounts);
}
Expand All @@ -125,9 +126,9 @@ function* deleteAccount(payload: { host: string, username: string }): Generator<
const { host, username } = payload;
let accounts = yield call(getFromStorage, 'accounts');
if (!accounts) accounts = [];
const index = accounts.indexOf(ac => ac.host === host && ac.username === username);
const index = R.findIndex(R.whereEq({ host, username }), accounts);
if (index !== -1) {
accounts = accounts.splice(index, 1);
accounts = R.without([{ host, username }], accounts);
yield call(setToStorage, 'accounts', accounts);
}
}
Expand Down

0 comments on commit 280ff32

Please sign in to comment.