Skip to content

Commit

Permalink
Fixing the rendering of the banner
Browse files Browse the repository at this point in the history
fixing rendering in language selection page
  • Loading branch information
YankoFelipe committed Jun 26, 2019
1 parent 70aa4ba commit 4fb17a0
Show file tree
Hide file tree
Showing 13 changed files with 24 additions and 15 deletions.
1 change: 0 additions & 1 deletion app/api/ada/lib/state-fetch/batchedFetcher.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import type {
HistoryFunc,
TxBodiesFunc,
UtxoSumFunc,
ServerStatusFunc,
} from './types';

import type {
Expand Down
2 changes: 1 addition & 1 deletion app/api/ada/lib/state-fetch/types.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,6 @@ export type FilterFunc = (body: FilterUsedRequest) => Promise<FilterUsedResponse
// checkServer

export type ServerStatusResponse = {
status: boolean
apiStatus: boolean
};
export type ServerStatusFunc = () => Promise<ServerStatusResponse>;
1 change: 1 addition & 0 deletions app/api/ada/lib/test-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ const CONFIG: ConfigType = {
},
app: {
walletRefreshInterval: 10,
serverStatusRefreshInterval: 10,
logsBufferSize: 10,
logsFileSuffix: 'log',
addressScanSize: 20,
Expand Down
9 changes: 5 additions & 4 deletions app/containers/MainLayout.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,15 @@ export default class MainLayout extends Component<MainLayoutProps> {
connectionErrorType: null,
};

displayedBanner = this.props.connectionErrorType === null ?
<TestnetWarningBanner /> :
<ServerErrorBanner errorType={this.props.connectionErrorType} />;

render() {
const displayedBanner = this.props.connectionErrorType === null ?
<TestnetWarningBanner /> :
<ServerErrorBanner errorType={this.props.connectionErrorType} />;

return (
<TopBarLayout
banner={this.displayedBanner}
banner={displayedBanner}
topbar={this.props.topbar}
notification={<div />}
footer={this.props.footer}
Expand Down
12 changes: 6 additions & 6 deletions app/containers/profile/LanguageSelectionPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,6 @@ export default class LanguageSelectionPage extends Component<InjectedProps> {
this.props.actions.profile.redirectToTermsOfUse.trigger(values);
};

displayedBanner = (connectionErrorType: ?ServerStatusErrorType) => {
connectionErrorType === null ?
<TestnetWarningBanner /> :
<ServerErrorBanner errorType={connectionErrorType} />;
};

render() {
const { setProfileLocaleRequest, currentLocale, LANGUAGE_OPTIONS } = this.props.stores.profile;
Expand All @@ -54,12 +49,17 @@ export default class LanguageSelectionPage extends Component<InjectedProps> {
title={topBartitle}
activeTopbarCategory={topbar.activeTopbarCategory}
/>) : undefined;
const displayedBanner = (connectionErrorType: ?ServerStatusErrorType) => {
connectionErrorType === null ?
<TestnetWarningBanner /> :
<ServerErrorBanner errorType={connectionErrorType} />;
};
return (
<TopBarLayout
topbar={topBar}
classicTheme={profile.isClassicTheme}
languageSelectionBackground
banner={this.displayedBanner(checkAdaServerStatus)}
banner={displayedBanner(checkAdaServerStatus)}
>
<LanguageSelectionForm
onSelectLanguage={this.onSelectLanguage}
Expand Down
2 changes: 2 additions & 0 deletions app/environment.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ export const environment = (Object.assign({
isMainnet: () => environment.NETWORK === NetworkType.MAINNET,
isAdaApi: () => environment.API === 'ada',
walletRefreshInterval: CONFIG.app.walletRefreshInterval,
serverStatusRefreshInterval: CONFIG.app.serverStatusRefreshInterval,
userAgentInfo,
}, process.env): {
NETWORK: Network,
Expand All @@ -39,6 +40,7 @@ export const environment = (Object.assign({
isMainnet: void => boolean,
isAdaApi: void => boolean,
walletRefreshInterval: number,
serverStatusRefreshInterval: number,
userAgentInfo: UserAgentInfo
});

Expand Down
6 changes: 3 additions & 3 deletions app/stores/ada/ServerConnectionStore.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import environment from '../../environment';
import type { ServerStatusResponse } from '../../api/ada/lib/state-fetch/types';

export default class ServerConnectionStore extends Store {
SERVER_STATUS_REFRESH_INTERVAL = 20000;
// TODO: set using environment.serverStatusRefreshInterval;
SERVER_STATUS_REFRESH_INTERVAL = environment.serverStatusRefreshInterval;

@observable serverStatus: ?ServerStatusErrorType = null;

setup() {
Expand All @@ -25,7 +25,7 @@ export default class ServerConnectionStore extends Store {
try {
const response: ServerStatusResponse = await checkServerStatusFunc();
runInAction('refresh server status', () => {
this.serverStatus = response.status === true ? null : 'server';
this.serverStatus = response.apiStatus === true ? null : 'server';
});
} catch (err) {
runInAction('refresh server status', () => {
Expand Down
1 change: 1 addition & 0 deletions config/config-types.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ export type ConfigType = {

export type AppConfigType = {
walletRefreshInterval: number,
serverStatusRefreshInterval: number,
logsBufferSize: number,
logsFileSuffix: string,
/** Defined by bip44
Expand Down
1 change: 1 addition & 0 deletions config/development.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
},
"app": {
"walletRefreshInterval": 20000,
"serverStatusRefreshInterval": 20000,
"logsBufferSize": 500,
"logsFileSuffix": "-yoroi.log",
"addressScanSize": 20,
Expand Down
1 change: 1 addition & 0 deletions config/mainnet.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
},
"app": {
"walletRefreshInterval": 20000,
"serverStatusRefreshInterval": 20000,
"logsBufferSize": 500,
"logsFileSuffix": "-yoroi.log",
"addressScanSize": 20,
Expand Down
1 change: 1 addition & 0 deletions config/staging.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
},
"app": {
"walletRefreshInterval": 20000,
"serverStatusRefreshInterval": 20000,
"logsBufferSize": 500,
"logsFileSuffix": "-yoroi.log",
"addressScanSize": 20,
Expand Down
1 change: 1 addition & 0 deletions config/test.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
},
"app": {
"walletRefreshInterval": 2000,
"serverStatusRefreshInterval": 20000,
"logsBufferSize": 500,
"logsFileSuffix": "-yoroi.log",
"addressScanSize": 20,
Expand Down
1 change: 1 addition & 0 deletions config/testnet.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
},
"app": {
"walletRefreshInterval": 20000,
"serverStatusRefreshInterval": 20000,
"logsBufferSize": 500,
"logsFileSuffix": "-yoroi.log",
"addressScanSize": 20,
Expand Down

0 comments on commit 4fb17a0

Please sign in to comment.