Browse Source

refactor(clightning): remove unused c-lightning redux model

master
jamaljsr 5 years ago
parent
commit
5b77c31f5a
  1. 3
      src/store/models/index.ts
  2. 57
      src/store/models/lightning.ts

3
src/store/models/index.ts

@ -5,7 +5,6 @@ import { AnyAction } from 'redux';
import appModel, { AppModel } from './app';
import bitcoindModel, { BitcoindModel } from './bitcoind';
import designerModel, { DesignerModel } from './designer';
import lightningModel, { LightningModel } from './lightning';
import lndModel, { LndModel } from './lnd';
import modalsModel, { ModalsModel } from './modals';
import networkModel, { NetworkModel } from './network';
@ -16,7 +15,6 @@ export interface RootModel {
network: NetworkModel;
bitcoind: BitcoindModel;
lnd: LndModel;
lightning: LightningModel;
designer: DesignerModel;
modals: ModalsModel;
}
@ -28,7 +26,6 @@ export const createModel = (history: History<any>): RootModel => {
network: networkModel,
bitcoind: bitcoindModel,
lnd: lndModel,
lightning: lightningModel,
designer: designerModel,
modals: modalsModel,
};

57
src/store/models/lightning.ts

@ -1,57 +0,0 @@
import { Action, action, Thunk, thunk } from 'easy-peasy';
import { LightningNode } from 'shared/types';
import { LightningNodeBalances, LightningNodeInfo } from 'lib/lightning/types';
import { StoreInjections } from 'types';
import { RootModel } from './';
export interface LightningNodeMapping {
[key: string]: LightningNodeModel;
}
export interface LightningNodeModel {
info?: LightningNodeInfo;
balances?: LightningNodeBalances;
}
export interface LightningModel {
nodes: LightningNodeMapping;
removeNode: Action<LightningModel, string>;
setInfo: Action<LightningModel, { node: LightningNode; info: LightningNodeInfo }>;
getInfo: Thunk<LightningModel, LightningNode, StoreInjections, RootModel>;
setBalances: Action<
LightningModel,
{ node: LightningNode; balances: LightningNodeBalances }
>;
getBalances: Thunk<LightningModel, LightningNode, StoreInjections, RootModel>;
}
const lightningModel: LightningModel = {
// state properties
nodes: {},
// reducer actions (mutations allowed thx to immer)
removeNode: action((state, name) => {
if (state.nodes[name]) {
delete state.nodes[name];
}
}),
setInfo: action((state, { node, info }) => {
if (!state.nodes[node.name]) state.nodes[node.name] = {};
state.nodes[node.name].info = info;
}),
getInfo: thunk(async (actions, node, { injections }) => {
const api = injections.lightningFactory.getService(node);
const info = await api.getInfo(node);
actions.setInfo({ node, info });
}),
setBalances: action((state, { node, balances }) => {
if (!state.nodes[node.name]) state.nodes[node.name] = {};
state.nodes[node.name].balances = balances;
}),
getBalances: thunk(async (actions, node, { injections }) => {
const api = injections.lightningFactory.getService(node);
const balances = await api.getBalances(node);
actions.setBalances({ node, balances });
}),
};
export default lightningModel;
Loading…
Cancel
Save