Skip to content

Commit

Permalink
Merge branch 'release/7.34.0' into chore/cherry-pick-12074
Browse files Browse the repository at this point in the history
  • Loading branch information
salimtb authored Oct 29, 2024
2 parents 9dae0ba + c8174c7 commit ca2980b
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 3 deletions.
39 changes: 36 additions & 3 deletions app/components/Views/BrowserTab/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ import Routes from '../../../constants/navigation/Routes';
import generateTestId from '../../../../wdio/utils/generateTestId';
import {
ADD_FAVORITES_OPTION,
OPEN_FAVORITES_OPTION,
MENU_ID,
NEW_TAB_OPTION,
OPEN_IN_BROWSER_OPTION,
Expand Down Expand Up @@ -302,7 +303,8 @@ export const BrowserTab = (props) => {
const { colors, shadows } = useTheme();
const styles = createStyles(colors, shadows);
const favicon = useFavicon(url.current);
const { trackEvent, isEnabled, getMetaMetricsId } = useMetrics();
const { trackEvent, isEnabled, getMetaMetricsId, createEventBuilder } =
useMetrics();
/**
* Is the current tab the active tab
*/
Expand Down Expand Up @@ -992,6 +994,18 @@ export const BrowserTab = (props) => {
trackEvent(MetaMetricsEvents.DAPP_HOME);
};

/**
* Go to favorites page
*/
const goToFavorites = async () => {
toggleOptionsIfNeeded();
if (url.current === OLD_HOMEPAGE_URL_HOST) return reload();
await go(OLD_HOMEPAGE_URL_HOST);
trackEvent(
createEventBuilder(MetaMetricsEvents.DAPP_GO_TO_FAVORITES).build(),
);
};

/**
* Handle url input submit
*/
Expand Down Expand Up @@ -1302,11 +1316,29 @@ export const BrowserTab = (props) => {
trackReloadEvent();
};

/**
* Renders Go to Favorites option
*/
const renderGoToFavorites = () => (
<Button onPress={goToFavorites} style={styles.option}>
<View style={styles.optionIconWrapper}>
<Icon name="star" size={16} style={styles.optionIcon} />
</View>
<Text
style={styles.optionText}
numberOfLines={2}
{...generateTestId(Platform, OPEN_FAVORITES_OPTION)}
>
{strings('browser.go_to_favorites')}
</Text>
</Button>
);

/**
* Render non-homepage options menu
*/
const renderNonHomeOptions = () => {
if (isHomepage()) return null;
if (isHomepage()) return renderGoToFavorites();

return (
<React.Fragment>
Expand All @@ -1325,7 +1357,7 @@ export const BrowserTab = (props) => {
{!isBookmark() && (
<Button onPress={addBookmark} style={styles.option}>
<View style={styles.optionIconWrapper}>
<Icon name="star" size={16} style={styles.optionIcon} />
<Icon name="plus-square" size={16} style={styles.optionIcon} />
</View>
<Text
style={styles.optionText}
Expand All @@ -1336,6 +1368,7 @@ export const BrowserTab = (props) => {
</Text>
</Button>
)}
{renderGoToFavorites()}
<Button onPress={share} style={styles.option}>
<View style={styles.optionIconWrapper}>
<Icon name="share" size={15} style={styles.optionIcon} />
Expand Down
1 change: 1 addition & 0 deletions app/core/Analytics/MetaMetrics.events.ts
Original file line number Diff line number Diff line change
Expand Up @@ -877,6 +877,7 @@ enum DESCRIPTION {
DAPP_BROWSER_OPTIONS = 'More Browser Options',
DAPP_HOME = 'Home',
DAPP_ADD_TO_FAVORITE = 'Add to Favorites',
DAPP_GO_TO_FAVORITES = 'Go to Favorites',
DAPP_OPEN_IN_BROWSER = 'Open in Browser',
// Wallet
WALLET_TOKENS = 'Tokens',
Expand Down
1 change: 1 addition & 0 deletions locales/languages/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -1566,6 +1566,7 @@
"share": "Share",
"bookmark": "Bookmark",
"add_to_favorites": "Add to Favorites",
"go_to_favorites": "Go to Favorites",
"error": "Error",
"cancel": "Cancel",
"go_back": "Go back",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ export const MENU_ID = 'browser-options-menu';

export const ADD_FAVORITES_OPTION = 'browser-options-menu-add-favorites';

export const OPEN_FAVORITES_OPTION = 'browser-options-menu-open-favorites';

export const NEW_TAB_OPTION = 'browser-options-menu-new-tab';

export const RELOAD_OPTION = 'browser-options-menu-reload';
Expand Down

0 comments on commit ca2980b

Please sign in to comment.