diff --git a/app/core/RPCMethods/RPCMethodMiddleware.ts b/app/core/RPCMethods/RPCMethodMiddleware.ts index d3b02187aa4..01f49f97dcd 100644 --- a/app/core/RPCMethods/RPCMethodMiddleware.ts +++ b/app/core/RPCMethods/RPCMethodMiddleware.ts @@ -783,45 +783,50 @@ export const getRpcMethodMiddleware = ({ metamask_removeFavorite: async () => { checkTabActive(); + if (!isHomepage()) { throw providerErrors.unauthorized('Forbidden.'); } const { bookmarks } = store.getState(); - Alert.alert( - strings('browser.remove_bookmark_title'), - strings('browser.remove_bookmark_msg'), - [ - { - text: strings('browser.cancel'), - onPress: () => { - res.result = { - favorites: bookmarks, - }; + return new Promise((resolve) => { + Alert.alert( + strings('browser.remove_bookmark_title'), + strings('browser.remove_bookmark_msg'), + [ + { + text: strings('browser.cancel'), + onPress: () => { + res.result = { + favorites: bookmarks, + }; + resolve(); + }, + style: 'cancel', }, - style: 'cancel', - }, - { - text: strings('browser.yes'), - onPress: () => { - const bookmark = { url: req.params[0] }; + { + text: strings('browser.yes'), + onPress: () => { + const bookmark = { url: req.params[0] }; - store.dispatch(removeBookmark(bookmark)); + store.dispatch(removeBookmark(bookmark)); - const { bookmarks: updatedBookmarks } = store.getState(); + const { bookmarks: updatedBookmarks } = store.getState(); - if (isHomepage()) { - injectHomePageScripts(updatedBookmarks); - } + if (isHomepage()) { + injectHomePageScripts(updatedBookmarks); + } - res.result = { - favorites: bookmarks, - }; + res.result = { + favorites: bookmarks, + }; + resolve(); + }, }, - }, - ], - ); + ], + ); + }); }, metamask_showTutorial: async () => {