Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

revamped wallet landing page should be transactions #2919

Merged
merged 1 commit into from
Jul 21, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 13 additions & 5 deletions packages/yoroi-extension/app/containers/wallet/Wallet.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ import NavBarTitle from '../../components/topbar/NavBarTitle';
import SubMenu from '../../components/topbar/SubMenu';
import type { GeneratedData as NavBarContainerRevampData } from '../NavBarContainerRevamp';
import WalletSyncingOverlay from '../../components/wallet/syncingOverlay/WalletSyncingOverlay';
import { THEMES } from '../../styles/utils';
import type { Theme } from '../../styles/utils';

export type GeneratedData = typeof Wallet.prototype.generated;

Expand Down Expand Up @@ -64,6 +66,12 @@ class Wallet extends Component<AllProps> {
}

checkRoute(): void | string {
let categories;
if (this.generated.stores.profile.currentTheme === THEMES.YOROI_REVAMP) {
categories = allSubcategoriesRevamp;
} else {
categories = allCategories;
}
// void -> this route is fine for this wallet type
// string -> what you should be redirected to
const publicDeriver = this.generated.stores.wallets.selected;
Expand All @@ -72,7 +80,7 @@ class Wallet extends Component<AllProps> {
const spendableBalance = this.generated.stores.transactions.getBalanceRequest.result;
const walletHasAssets = !!(spendableBalance?.nonDefaultEntries().length);

const activeCategory = allCategories.find(
const activeCategory = categories.find(
category => this.generated.stores.app.currentRoute.startsWith(category.route)
);

Expand All @@ -81,7 +89,7 @@ class Wallet extends Component<AllProps> {
// or no category is selected yet (wallet selected for the first time)
const visibilityContext = { selected: publicDeriver, walletHasAssets };
if (!activeCategory?.isVisible(visibilityContext)) {
const firstValidCategory = allCategories
const firstValidCategory = categories
.find(c => c.isVisible(visibilityContext));
if (firstValidCategory == null) {
throw new Error(`Selected wallet has no valid category`);
Expand All @@ -102,7 +110,7 @@ class Wallet extends Component<AllProps> {
if (this.generated.stores.wallets.firstSync === publicDeriver.getPublicDeriverId()) {
return (
<WalletSyncingOverlay
classicTheme={this.generated.stores.profile.isClassicTheme}
classicTheme={this.generated.stores.profile.currentTheme === THEMES.YOROI_CLASSIC}
onClose={() => this.navigateToMyWallets(ROUTES.MY_WALLETS)}
/>
)
Expand Down Expand Up @@ -264,7 +272,7 @@ class Wallet extends Component<AllProps> {
|},
|},
profile: {|
isClassicTheme: boolean,
currentTheme: Theme,
|},
|}
|} {
Expand Down Expand Up @@ -304,7 +312,7 @@ class Wallet extends Component<AllProps> {
})(),
},
profile: {
isClassicTheme: stores.profile.isClassicTheme
currentTheme: stores.profile.currentTheme,
}
},
actions: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import WalletStore from '../../stores/toplevel/WalletStore';
import type { GeneratedData } from './Wallet';
import { mockFromDefaults, getDefaultEntryTokenInfo, } from '../../stores/toplevel/TokenInfoStore';
import { defaultAssets, } from '../../api/ada/lib/storage/database/prepackaged/networks';
import { THEMES } from '../../styles/utils';

export const mockWalletProps: {
selected: null | PublicDeriver<>,
Expand All @@ -36,7 +37,7 @@ export const mockWalletProps: {
currentRoute: request.location,
},
profile: {
isClassicTheme: true
currentTheme: THEMES.YOROI_CLASSIC,
},
wallets: {
selected: request.selected,
Expand Down