Skip to content

Commit

Permalink
fix: broken my-profile tap after purchase (#11200)
Browse files Browse the repository at this point in the history
* fix: broken my-profile tap after purchase

* fix: again

* fix: again 2

* chore: update routes.tests.ts

* fix: typo
  • Loading branch information
MounirDhahri authored Nov 27, 2024
1 parent 271c58f commit 8330e61
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 9 deletions.
5 changes: 5 additions & 0 deletions src/app/AppRegistry.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -730,6 +730,7 @@ export const modules = defineModules({
Component: HomeViewScreen,
options: {
isRootViewForTabName: "home",
onlyShowInTabName: "home",
fullBleed: true,
screenOptions: {
headerShown: false,
Expand Down Expand Up @@ -758,6 +759,7 @@ export const modules = defineModules({
Component: InboxQueryRenderer,
options: {
isRootViewForTabName: "inbox",
onlyShowInTabName: "inbox",
fullBleed: true,
screenOptions: {
headerShown: false,
Expand Down Expand Up @@ -926,6 +928,7 @@ export const modules = defineModules({
Component: MyProfile,
options: {
isRootViewForTabName: "profile",
onlyShowInTabName: "profile",
fullBleed: true,
screenOptions: {
headerShown: false,
Expand Down Expand Up @@ -1124,6 +1127,7 @@ export const modules = defineModules({
Component: SellWithArtsy,
options: {
isRootViewForTabName: "sell",
onlyShowInTabName: "sell",
fullBleed: true,
screenOptions: {
headerShown: false,
Expand Down Expand Up @@ -1154,6 +1158,7 @@ export const modules = defineModules({
Component: SearchScreen,
options: {
isRootViewForTabName: "search",
onlyShowInTabName: "search",
fullBleed: true,
screenOptions: {
headerShown: false,
Expand Down
1 change: 0 additions & 1 deletion src/app/Components/ArtsyWebView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,6 @@ export const ArtsyWebView = forwardRef<

if (shouldDismissModal) {
dismissModal(() => {
// We need to navigate only after the modal has been dismissed to avoid a race
// condition breaking the UI
navigate(targetURL)
})
Expand Down
1 change: 1 addition & 0 deletions src/app/routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ export function addWebViewRoute(url: string, config?: ArtsyWebViewConfig) {
config?.alwaysPresentModally ? "ModalWebView" : "ReactWebView",
(params) => ({
url: replaceParams(url, params),
isPresentedModally: !!config?.alwaysPresentModally,
...config,
})
)
Expand Down
17 changes: 10 additions & 7 deletions src/app/system/navigation/navigate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,13 +93,16 @@ export async function navigate(url: string, options: NavigateOptions = {}) {
} else {
if (module.options.onlyShowInTabName) {
switchTab(module.options.onlyShowInTabName)
// We wait for a frame to allow the tab to be switched before we navigate
// This allows us to also override the back button behavior in the tab
requestAnimationFrame(() => {
internal_navigationRef.current?.dispatch(
StackActions.push(result.module, { ...result.params, ...options.passProps })
)
})

if (!module.options.isRootViewForTabName) {
// We wait for a frame to allow the tab to be switched before we navigate
// This allows us to also override the back button behavior in the tab
requestAnimationFrame(() => {
internal_navigationRef.current?.dispatch(
StackActions.push(result.module, { ...result.params, ...options.passProps })
)
})
}
} else {
internal_navigationRef.current?.dispatch(
StackActions.push(result.module, { ...result.params, ...options.passProps })
Expand Down
16 changes: 15 additions & 1 deletion src/app/system/navigation/routes.tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -671,6 +671,7 @@ describe("artsy.net routes", () => {
"module": "ModalWebView",
"params": {
"alwaysPresentModally": true,
"isPresentedModally": true,
"url": "/terms",
},
"type": "match",
Expand All @@ -684,6 +685,7 @@ describe("artsy.net routes", () => {
"module": "ModalWebView",
"params": {
"alwaysPresentModally": true,
"isPresentedModally": true,
"url": "/privacy",
},
"type": "match",
Expand All @@ -696,6 +698,7 @@ describe("artsy.net routes", () => {
{
"module": "ReactWebView",
"params": {
"isPresentedModally": false,
"url": "/unsubscribe",
},
"type": "match",
Expand Down Expand Up @@ -870,6 +873,7 @@ describe("artsy.net routes", () => {
"module": "ModalWebView",
"params": {
"alwaysPresentModally": true,
"isPresentedModally": true,
"url": "/conditions-of-sale",
},
"type": "match",
Expand Down Expand Up @@ -1129,6 +1133,7 @@ describe("artsy.net routes", () => {
{
"module": "ReactWebView",
"params": {
"isPresentedModally": false,
"url": "/categories",
},
"type": "match",
Expand All @@ -1142,6 +1147,7 @@ describe("artsy.net routes", () => {
"module": "ModalWebView",
"params": {
"alwaysPresentModally": true,
"isPresentedModally": true,
"url": "/privacy",
},
"type": "match",
Expand Down Expand Up @@ -1184,6 +1190,7 @@ describe("artsy.net routes", () => {
{
"module": "ReactWebView",
"params": {
"isPresentedModally": false,
"url": "/the/mighty/boosh",
},
"type": "match",
Expand All @@ -1193,6 +1200,7 @@ describe("artsy.net routes", () => {
{
"module": "ReactWebView",
"params": {
"isPresentedModally": false,
"url": "/one-hundred/years-of/solitude",
},
"type": "match",
Expand Down Expand Up @@ -1249,26 +1257,32 @@ describe("addWebViewRoute", () => {
it("returns a route matcher for web views", () => {
const matcher = addWebViewRoute("/conditions-of-sale")
expect(matcher.module).toBe("ReactWebView")
expect(matcher.match(["conditions-of-sale"])).toEqual({ url: "/conditions-of-sale" })
expect(matcher.match(["conditions-of-sale"])).toEqual({
isPresentedModally: false,
url: "/conditions-of-sale",
})
})

it("inlines params and wildcards in the original route", () => {
const matcher = addWebViewRoute("/artist/:artistID/*")
expect(matcher.match(["artist", "banksy", "auction-results", "8907"])).toEqual({
isPresentedModally: false,
url: "/artist/banksy/auction-results/8907",
})
})

it("inlines params in the original order history route", () => {
const matcher = addWebViewRoute("/user/purchases/:orderID")
expect(matcher.match(["user", "purchases", "8907"])).toEqual({
isPresentedModally: false,
url: "/user/purchases/8907",
})
})

it("inlines params in the original article route", () => {
const matcher = addWebViewRoute("/article/:orderID")
expect(matcher.match(["article", "article-article"])).toEqual({
isPresentedModally: false,
url: "/article/article-article",
})
})
Expand Down

0 comments on commit 8330e61

Please sign in to comment.