diff --git a/package-lock.json b/package-lock.json index debc9fd8..992e2328 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "rtl", - "version": "0.2.17-beta", + "version": "0.3.0-beta", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index 06767acb..d2cdfe98 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "rtl", - "version": "0.2.17-beta", + "version": "0.3.0-beta", "license": "MIT", "scripts": { "ng": "ng", diff --git a/src/app/pages/channels/channel-closed/channel-closed.component.ts b/src/app/pages/channels/channel-closed/channel-closed.component.ts index 67c8ea09..247f7558 100644 --- a/src/app/pages/channels/channel-closed/channel-closed.component.ts +++ b/src/app/pages/channels/channel-closed/channel-closed.component.ts @@ -1,7 +1,8 @@ import { Component, OnInit, OnDestroy, ViewChild } from '@angular/core'; import { Subject } from 'rxjs'; -import { takeUntil } from 'rxjs/operators'; +import { takeUntil, filter } from 'rxjs/operators'; import { Store } from '@ngrx/store'; +import { Actions } from '@ngrx/effects'; import { MatTableDataSource, MatSort } from '@angular/material'; import { ClosedChannel } from '../../../shared/models/lndModels'; @@ -23,9 +24,9 @@ export class ChannelClosedComponent implements OnInit, OnDestroy { public flgLoading: Array = [true]; public selectedFilter = ''; public flgSticky = false; - private unsub: Array> = [new Subject(), new Subject()]; + private unsub: Array> = [new Subject(), new Subject(), new Subject()]; - constructor(private logger: LoggerService, private store: Store, private rtlEffects: RTLEffects) { + constructor(private logger: LoggerService, private store: Store, private rtlEffects: RTLEffects, private actions$: Actions) { switch (true) { case (window.innerWidth <= 415): this.displayedColumns = ['close_type', 'chan_id', 'settled_balance']; @@ -51,6 +52,9 @@ export class ChannelClosedComponent implements OnInit, OnDestroy { ngOnInit() { this.store.dispatch(new RTLActions.FetchChannels({routeParam: 'closed', channelStatus: ''})); + this.actions$.pipe(takeUntil(this.unsub[2]), filter((action) => action.type === RTLActions.RESET_STORE)).subscribe((resetStore: RTLActions.ResetStore) => { + this.store.dispatch(new RTLActions.FetchChannels({routeParam: 'closed', channelStatus: ''})); + }); this.store.select('rtlRoot') .pipe(takeUntil(this.unsub[0])) .subscribe((rtlStore: fromRTLReducer.State) => { @@ -59,7 +63,7 @@ export class ChannelClosedComponent implements OnInit, OnDestroy { this.flgLoading[0] = 'error'; } }); - if (undefined !== rtlStore.closedChannels && rtlStore.closedChannels.length > 0) { + if (undefined !== rtlStore.closedChannels) { this.loadClosedChannelsTable(rtlStore.closedChannels); } if (this.flgLoading[0] !== 'error') { diff --git a/src/app/pages/channels/channel-manage/channel-manage.component.ts b/src/app/pages/channels/channel-manage/channel-manage.component.ts index 21819236..795c3dd4 100644 --- a/src/app/pages/channels/channel-manage/channel-manage.component.ts +++ b/src/app/pages/channels/channel-manage/channel-manage.component.ts @@ -81,7 +81,7 @@ export class ChannelManageComponent implements OnInit, OnDestroy { }); this.totalBalance = +rtlStore.blockchainBalance.total_balance; - if (undefined !== rtlStore.allChannels && rtlStore.allChannels.length > 0) { + if (undefined !== rtlStore.allChannels) { this.loadChannelsTable(rtlStore.allChannels); } if (this.flgLoading[0] !== 'error') { diff --git a/src/app/pages/routing-peers/routing-peers.component.ts b/src/app/pages/routing-peers/routing-peers.component.ts index ed0403a0..dfaf76d2 100644 --- a/src/app/pages/routing-peers/routing-peers.component.ts +++ b/src/app/pages/routing-peers/routing-peers.component.ts @@ -1,7 +1,8 @@ import { Component, OnInit, OnDestroy, ViewChild } from '@angular/core'; import { Subject } from 'rxjs'; -import { takeUntil } from 'rxjs/operators'; +import { takeUntil, filter } from 'rxjs/operators'; import { Store } from '@ngrx/store'; +import { Actions } from '@ngrx/effects'; import { MatTableDataSource, MatSort } from '@angular/material'; import { ForwardingEvent, RoutingPeers } from '../../shared/models/lndModels'; @@ -32,9 +33,9 @@ export class RoutingPeersComponent implements OnInit, OnDestroy { public endDate = this.today; public startDate = this.lastMonthDay; public flgSticky = false; - private unsub: Array> = [new Subject(), new Subject()]; + private unsub: Array> = [new Subject(), new Subject(), new Subject()]; - constructor(private logger: LoggerService, private commonService: CommonService, private store: Store) { + constructor(private logger: LoggerService, private commonService: CommonService, private store: Store, private actions$: Actions) { switch (true) { case (window.innerWidth <= 415): this.displayedColumns = ['chan_id', 'events', 'total_amount']; @@ -58,6 +59,9 @@ export class RoutingPeersComponent implements OnInit, OnDestroy { ngOnInit() { this.onRoutingPeersFetch(); + this.actions$.pipe(takeUntil(this.unsub[2]), filter((action) => action.type === RTLActions.RESET_STORE)).subscribe((resetStore: RTLActions.ResetStore) => { + this.onRoutingPeersFetch(); + }); this.store.select('rtlRoot') .pipe(takeUntil(this.unsub[0])) .subscribe((rtlStore: fromRTLReducer.State) => { diff --git a/src/app/pages/switch/forwarding-history.component.ts b/src/app/pages/switch/forwarding-history.component.ts index 3faaa98e..dab21330 100644 --- a/src/app/pages/switch/forwarding-history.component.ts +++ b/src/app/pages/switch/forwarding-history.component.ts @@ -1,8 +1,9 @@ import { Component, OnInit, OnDestroy, ViewChild } from '@angular/core'; import { formatDate } from '@angular/common'; import { Subject } from 'rxjs'; -import { takeUntil } from 'rxjs/operators'; +import { takeUntil, filter } from 'rxjs/operators'; import { Store } from '@ngrx/store'; +import { Actions } from '@ngrx/effects'; import { MatTableDataSource, MatSort } from '@angular/material'; import { ForwardingEvent } from '../../shared/models/lndModels'; @@ -29,7 +30,7 @@ export class ForwardingHistoryComponent implements OnInit, OnDestroy { public flgSticky = false; private unsub: Array> = [new Subject(), new Subject()]; - constructor(private logger: LoggerService, private store: Store) { + constructor(private logger: LoggerService, private store: Store, private actions$: Actions) { switch (true) { case (window.innerWidth <= 415): this.displayedColumns = ['timestamp', 'amt_out', 'amt_in']; @@ -53,6 +54,10 @@ export class ForwardingHistoryComponent implements OnInit, OnDestroy { ngOnInit() { this.onForwardingHistoryFetch(); + this.actions$.pipe(takeUntil(this.unsub[2]), filter((action) => action.type === RTLActions.RESET_STORE)).subscribe((resetStore: RTLActions.ResetStore) => { + this.onForwardingHistoryFetch(); + }); + this.store.select('rtlRoot') .pipe(takeUntil(this.unsub[0])) .subscribe((rtlStore: fromRTLReducer.State) => { diff --git a/src/app/pages/transactions/list-transactions/list-transactions.component.ts b/src/app/pages/transactions/list-transactions/list-transactions.component.ts index 1330c4cf..87091a8e 100644 --- a/src/app/pages/transactions/list-transactions/list-transactions.component.ts +++ b/src/app/pages/transactions/list-transactions/list-transactions.component.ts @@ -1,8 +1,9 @@ import { Component, OnInit, OnDestroy, ViewChild } from '@angular/core'; import { formatDate } from '@angular/common'; import { Subject } from 'rxjs'; -import { takeUntil } from 'rxjs/operators'; +import { takeUntil, filter } from 'rxjs/operators'; import { Store } from '@ngrx/store'; +import { Actions } from '@ngrx/effects'; import { MatTableDataSource, MatSort } from '@angular/material'; import { Transaction } from '../../../shared/models/lndModels'; @@ -23,9 +24,9 @@ export class ListTransactionsComponent implements OnInit, OnDestroy { public listTransactions: any; public flgLoading: Array = [true]; public flgSticky = false; - private unsub: Array> = [new Subject(), new Subject()]; + private unsub: Array> = [new Subject(), new Subject(), new Subject()]; - constructor(private logger: LoggerService, private store: Store, private rtlEffects: RTLEffects) { + constructor(private logger: LoggerService, private store: Store, private rtlEffects: RTLEffects, private actions$: Actions) { switch (true) { case (window.innerWidth <= 415): this.displayedColumns = ['dest_addresses', 'total_fees', 'amount']; @@ -49,6 +50,10 @@ export class ListTransactionsComponent implements OnInit, OnDestroy { ngOnInit() { this.store.dispatch(new RTLActions.FetchTransactions()); + this.actions$.pipe(takeUntil(this.unsub[2]), filter((action) => action.type === RTLActions.RESET_STORE)).subscribe((resetStore: RTLActions.ResetStore) => { + this.store.dispatch(new RTLActions.FetchTransactions()); + }); + this.store.select('rtlRoot') .pipe(takeUntil(this.unsub[0])) .subscribe((rtlStore: fromRTLReducer.State) => { @@ -57,7 +62,7 @@ export class ListTransactionsComponent implements OnInit, OnDestroy { this.flgLoading[0] = 'error'; } }); - if (undefined !== rtlStore.transactions && rtlStore.transactions.length > 0) { + if (undefined !== rtlStore.transactions) { this.loadTransactionsTable(rtlStore.transactions); } if (this.flgLoading[0] !== 'error') { diff --git a/src/app/shared/store/rtl.actions.ts b/src/app/shared/store/rtl.actions.ts index 2e91d018..8f138381 100644 --- a/src/app/shared/store/rtl.actions.ts +++ b/src/app/shared/store/rtl.actions.ts @@ -7,6 +7,7 @@ import { } from '../models/lndModels'; import { MatDialogConfig } from '@angular/material'; +export const RESET_STORE = 'RESET_STORE'; export const CLEAR_EFFECT_ERROR = 'CLEAR_EFFECT_ERROR'; export const EFFECT_ERROR = 'EFFECT_ERROR'; export const OPEN_SPINNER = 'OPEN_SPINNER'; @@ -112,6 +113,11 @@ export class CloseConfirmation implements Action { constructor(public payload: boolean) {} } +export class ResetStore implements Action { + readonly type = RESET_STORE; + constructor(public payload: Node) {} +} + export class FetchRTLConfig implements Action { readonly type = FETCH_RTL_CONFIG; } @@ -387,7 +393,7 @@ export type RTLActions = ClearEffectError | EffectError | OpenSpinner | CloseSpinner | FetchRTLConfig | SetRTLConfig | SaveSettings | OpenAlert | CloseAlert | OpenConfirmation | CloseConfirmation | - SetSelelectedNode | FetchInfo | SetInfo | + ResetStore | SetSelelectedNode | FetchInfo | SetInfo | FetchPeers | SetPeers | AddPeer | DetachPeer | SaveNewPeer | RemovePeer | AddInvoice | SaveNewInvoice | GetForwardingHistory | SetForwardingHistory | FetchFees | SetFees | diff --git a/src/app/shared/store/rtl.effects.ts b/src/app/shared/store/rtl.effects.ts index 74ac979a..21a0b07a 100644 --- a/src/app/shared/store/rtl.effects.ts +++ b/src/app/shared/store/rtl.effects.ts @@ -1050,10 +1050,9 @@ export class RTLEffects implements OnDestroy { .pipe( map((postRes: any) => { this.logger.info(postRes); - setTimeout(() => { - this.store.dispatch(new RTLActions.CloseSpinner()); - }, 4000); + this.store.dispatch(new RTLActions.CloseSpinner()); if (sessionStorage.getItem('token')) { + this.store.dispatch(new RTLActions.ResetStore(action.payload)); return { type: RTLActions.FETCH_INFO }; } else { return { diff --git a/src/app/shared/store/rtl.reducers.ts b/src/app/shared/store/rtl.reducers.ts index 5b21d4a1..92c135b5 100644 --- a/src/app/shared/store/rtl.reducers.ts +++ b/src/app/shared/store/rtl.reducers.ts @@ -84,6 +84,12 @@ export function RTLRootReducer(state = initialState, action: RTLActions.RTLActio ...state, effectErrors: [...state.effectErrors, action.payload] }; + case RTLActions.RESET_STORE: + return { + ...initialState, + appConfig: state.appConfig, + selNode: action.payload + }; case RTLActions.SET_SELECTED_NODE: return { ...state,