From d528f9ca919b43e4d942492aaaf53d507e7e9bc0 Mon Sep 17 00:00:00 2001
From: thekiba
Date: Wed, 14 Aug 2024 16:39:24 +0400
Subject: [PATCH] fix(ui): enhance transitions for android and macos
---
.../ui/src/app/utils/url-strategy-helpers.ts | 28 ++++++-------------
1 file changed, 8 insertions(+), 20 deletions(-)
diff --git a/packages/ui/src/app/utils/url-strategy-helpers.ts b/packages/ui/src/app/utils/url-strategy-helpers.ts
index b55c4790..78796699 100644
--- a/packages/ui/src/app/utils/url-strategy-helpers.ts
+++ b/packages/ui/src/app/utils/url-strategy-helpers.ts
@@ -79,39 +79,27 @@ export function redirectToTelegram(
if (isInTelegramBrowser()) {
// return back to the telegram browser
options.returnStrategy = 'back';
- options.twaReturnUrl = undefined;
- const linkWitStrategy = addReturnStrategy(directLinkUrl.toString(), options);
+ const linkWitStrategy = addReturnStrategy(directLinkUrl.toString(), options.returnStrategy);
openLinkBlank(linkWitStrategy);
} else if (isInTMA()) {
- if (isTmaPlatform('ios', 'android', 'macos')) {
+ if (isTmaPlatform('ios', 'android', 'macos', 'tdesktop', 'web')) {
// Use the `back` strategy, the current TMA instance will keep open.
// TON Space should automatically open in stack and should close
// itself after the user action.
options.returnStrategy = 'back';
- options.twaReturnUrl = undefined;
-
- sendOpenTelegramLink(addReturnStrategy(directLinkUrl.toString(), options));
- } else if (isTmaPlatform('tdesktop')) {
- // Use a strategy involving a direct link to return to the app.
- // The current TMA instance will close, and TON Space should
- // automatically open, and reopen the application once the user
- // action is completed.
+ const linkWitStrategy = addReturnStrategy(
+ directLinkUrl.toString(),
+ options.returnStrategy
+ );
- sendOpenTelegramLink(addReturnStrategy(directLinkUrl.toString(), options));
+ sendOpenTelegramLink(linkWitStrategy);
} else if (isTmaPlatform('weba')) {
+ // TODO: move weba to the ios/android/macOS/tdesktop strategy
// Similar to tdesktop strategy, but opening another TMA occurs
// through sending `web_app_open_tg_link` event to `parent`.
- sendOpenTelegramLink(addReturnStrategy(directLinkUrl.toString(), options));
- } else if (isTmaPlatform('web')) {
- // Similar to iOS/Android strategy, but opening another TMA occurs
- // through sending `web_app_open_tg_link` event to `parent`.
-
- options.returnStrategy = 'back';
- options.twaReturnUrl = undefined;
-
sendOpenTelegramLink(addReturnStrategy(directLinkUrl.toString(), options));
} else {
// Fallback for unknown platforms. Should use desktop strategy.