From 3e0c8d66fd60881f32e44fba08ef890525686491 Mon Sep 17 00:00:00 2001 From: Bernhard Owen Josephus Date: Fri, 30 Jun 2023 13:03:47 +0800 Subject: [PATCH 1/3] fix can't open link inside promise in safari --- src/libs/actions/Link.js | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/src/libs/actions/Link.js b/src/libs/actions/Link.js index 09c040ab47bc..350528bb6086 100644 --- a/src/libs/actions/Link.js +++ b/src/libs/actions/Link.js @@ -67,17 +67,12 @@ function openOldDotLink(url) { // If shortLivedAuthToken is not accessible, fallback to opening the link without the token. // eslint-disable-next-line rulesdir/no-api-side-effects-method - API.makeRequestWithSideEffects('OpenOldDotLink', {}, {}) - .then((response) => { - buildOldDotURL(url, response.shortLivedAuthToken).then((oldDotUrl) => { - Linking.openURL(oldDotUrl); - }); - }) - .catch(() => { - buildOldDotURL(url).then((oldDotUrl) => { - Linking.openURL(oldDotUrl); - }); - }); + asyncOpenURL( + API.makeRequestWithSideEffects('OpenOldDotLink', {}, {}) + .then((response) => buildOldDotURL(url, response.shortLivedAuthToken)) + .catch(() => buildOldDotURL(url)), + (url) => url, + ); } /** From 96c4b35f8dc407e3f8486bd808b88e392031fd0f Mon Sep 17 00:00:00 2001 From: Bernhard Owen Josephus Date: Fri, 30 Jun 2023 13:23:59 +0800 Subject: [PATCH 2/3] fix lint --- src/libs/actions/Link.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/libs/actions/Link.js b/src/libs/actions/Link.js index 350528bb6086..fc29e70de5e0 100644 --- a/src/libs/actions/Link.js +++ b/src/libs/actions/Link.js @@ -66,12 +66,12 @@ function openOldDotLink(url) { } // If shortLivedAuthToken is not accessible, fallback to opening the link without the token. - // eslint-disable-next-line rulesdir/no-api-side-effects-method asyncOpenURL( + // eslint-disable-next-line rulesdir/no-api-side-effects-method API.makeRequestWithSideEffects('OpenOldDotLink', {}, {}) .then((response) => buildOldDotURL(url, response.shortLivedAuthToken)) .catch(() => buildOldDotURL(url)), - (url) => url, + (urlRes) => urlRes, ); } From 47fffd37d1f973b0cd0f2e3bfd8f25740dd02e46 Mon Sep 17 00:00:00 2001 From: Bernhard Owen Josephus Date: Fri, 30 Jun 2023 13:53:31 +0800 Subject: [PATCH 3/3] renaming --- src/libs/actions/Link.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libs/actions/Link.js b/src/libs/actions/Link.js index fc29e70de5e0..b920cb1c7ee6 100644 --- a/src/libs/actions/Link.js +++ b/src/libs/actions/Link.js @@ -71,7 +71,7 @@ function openOldDotLink(url) { API.makeRequestWithSideEffects('OpenOldDotLink', {}, {}) .then((response) => buildOldDotURL(url, response.shortLivedAuthToken)) .catch(() => buildOldDotURL(url)), - (urlRes) => urlRes, + (oldDotURL) => oldDotURL, ); }