Skip to content

Commit

Permalink
Fix activeTabUrl (#2005)
Browse files Browse the repository at this point in the history
* Fix transaction header title

* Get activeTabUrl from props now

* Update tests

* Update CHANGELOG

* bump

* fixwcicon

Co-authored-by: Esteban Mino <efmino@uc.cl>
  • Loading branch information
rickycodes and estebanmino authored Nov 19, 2020
1 parent b31949c commit b37ff20
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 15 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
## Current Develop Branch

## v1.0.7 - Nov 17 2020
- [#2005](https://github.com/MetaMask/metamask-mobile/pull/2005): Fix activeTabUrl (#2005)
- [#2003](https://github.com/MetaMask/metamask-mobile/pull/2003): Bugfix/android choose password (#2003)
- [#1992](https://github.com/MetaMask/metamask-mobile/pull/1992): Android api level (#1992)
- [#1993](https://github.com/MetaMask/metamask-mobile/pull/1993): Catch SVG Errors (#1993)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ exports[`ApproveTransactionModal should render correctly 1`] = `
}
}
accountsLength={1}
activeTabUrl=""
activeTabUrl="https://metamask.github.io/test-dapp/"
conversionRate={5}
primaryCurrency="fiat"
providerType="ETH"
Expand Down
11 changes: 9 additions & 2 deletions app/components/UI/ApproveTransactionReview/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,14 @@ class ApproveTransactionReview extends PureComponent {
* Error coming from gas component
*/
gasError: PropTypes.string,
primaryCurrency: PropTypes.string
/**
* Primary currency, either ETH or Fiat
*/
primaryCurrency: PropTypes.string,
/**
* Active tab URL, the currently active tab url
*/
activeTabUrl: PropTypes.string
};

state = {
Expand Down Expand Up @@ -534,7 +541,6 @@ class ApproveTransactionReview extends PureComponent {

render = () => {
const {
activeTabUrl,
host,
tokenSymbol,
viewDetails,
Expand All @@ -549,6 +555,7 @@ class ApproveTransactionReview extends PureComponent {
primaryCurrency,
currentCurrency,
gasError,
activeTabUrl,
transaction: { origin }
} = this.props;

Expand Down
4 changes: 4 additions & 0 deletions app/components/UI/ApproveTransactionReview/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ describe('ApproveTransactionModal', () => {
transaction: {},
settings: {
primaryCurrency: 'fiat'
},
browser: {
activeTab: 1605778647042,
tabs: [{ id: 1605778647042, url: 'https://metamask.github.io/test-dapp/' }]
}
};
const wrapper = shallow(<ApproveTransactionModal />, {
Expand Down
10 changes: 7 additions & 3 deletions app/components/UI/TransactionHeader/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,8 @@ const TransactionHeader = props => {
};

const renderTopIcon = () => {
const { url, currentEnsName, icon, origin } = props.currentPageInformation;
const { currentEnsName, icon, origin } = props.currentPageInformation;
let url = props.currentPageInformation.url;
if (originIsDeeplink) {
return (
<View style={styles.deeplinkIconContainer}>
Expand All @@ -126,7 +127,10 @@ const TransactionHeader = props => {
);
}
let iconTitle = getHost(currentEnsName || url);
if (originIsWalletConnect) iconTitle = getHost(origin.split(WALLET_CONNECT_ORIGIN)[1]);
if (originIsWalletConnect) {
url = origin.split(WALLET_CONNECT_ORIGIN)[1];
iconTitle = getHost(url);
}
return (
<WebsiteIcon
style={styles.domainLogo}
Expand All @@ -143,7 +147,7 @@ const TransactionHeader = props => {
let title = '';
if (originIsDeeplink) title = renderShortAddress(spenderAddress);
else if (originIsWalletConnect) title = getHost(origin.split(WALLET_CONNECT_ORIGIN)[1]);
else title = getHost(currentEnsName || url);
else title = getHost(currentEnsName || url || origin);

return <Text style={styles.domainUrl}>{title}</Text>;
};
Expand Down
9 changes: 2 additions & 7 deletions app/util/transactions.js
Original file line number Diff line number Diff line change
Expand Up @@ -414,10 +414,5 @@ export function getNormalizedTxState(state) {
return { ...state.transaction, ...state.transaction.transaction };
}

export function getActiveTabUrl({ browser = {} }) {
let tab;
if (browser.tabs && browser.activeTab) {
tab = browser.tabs.find(({ id }) => id === browser.activeTab);
}
return tab ? tab.url : '';
}
export const getActiveTabUrl = ({ browser = {} }) =>
browser.tabs && browser.activeTab && browser.tabs.find(({ id }) => id === browser.activeTab)?.url;
4 changes: 2 additions & 2 deletions ios/MetaMask.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -847,7 +847,7 @@
CODE_SIGN_ENTITLEMENTS = MetaMask/MetaMaskDebug.entitlements;
CODE_SIGN_IDENTITY = "iPhone Developer";
CODE_SIGN_STYLE = Manual;
CURRENT_PROJECT_VERSION = 550;
CURRENT_PROJECT_VERSION = 551;
DEAD_CODE_STRIPPING = NO;
DEBUG_INFORMATION_FORMAT = dwarf;
DEVELOPMENT_TEAM = 48XVW22RCG;
Expand Down Expand Up @@ -910,7 +910,7 @@
CODE_SIGN_ENTITLEMENTS = MetaMask/MetaMask.entitlements;
CODE_SIGN_IDENTITY = "iPhone Distribution";
CODE_SIGN_STYLE = Manual;
CURRENT_PROJECT_VERSION = 550;
CURRENT_PROJECT_VERSION = 551;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
DEVELOPMENT_TEAM = 48XVW22RCG;
FRAMEWORK_SEARCH_PATHS = (
Expand Down

0 comments on commit b37ff20

Please sign in to comment.