From 5c4670d542a634ea1e87c6e06b4b56cc6614c1c4 Mon Sep 17 00:00:00 2001
From: thekiba
Date: Sat, 16 Dec 2023 00:03:35 +0400
Subject: [PATCH] feat(ui): enhance transition strategies in tma
---
packages/ui/src/app/utils/web-api.ts | 16 +++++-----------
1 file changed, 5 insertions(+), 11 deletions(-)
diff --git a/packages/ui/src/app/utils/web-api.ts b/packages/ui/src/app/utils/web-api.ts
index 9eec0f91..d20a57db 100644
--- a/packages/ui/src/app/utils/web-api.ts
+++ b/packages/ui/src/app/utils/web-api.ts
@@ -280,7 +280,7 @@ export function redirectToTelegram(
// TON Space should automatically open in stack and should close
// itself after the user action.
- options.returnStrategy = 'none';
+ options.returnStrategy = 'back';
options.twaReturnUrl = undefined;
sendOpenTelegramLink(addReturnStrategy(directLinkUrl.toString(), options));
@@ -290,10 +290,6 @@ export function redirectToTelegram(
// automatically open, and reopen the application once the user
// action is completed.
- if (!options.twaReturnUrl) {
- throw new TonConnectUIError('`twaReturnUrl` is required for this platform');
- }
-
sendOpenTelegramLink(addReturnStrategy(directLinkUrl.toString(), options));
} else if (isTmaPlatform('weba')) {
// Similar to macos/tdesktop strategy, but opening another TMA occurs
@@ -304,7 +300,7 @@ export function redirectToTelegram(
// Similar to iOS/Android strategy, but opening another TMA occurs
// through sending `web_app_open_tg_link` event to `parent`.
- options.returnStrategy = 'none';
+ options.returnStrategy = 'back';
options.twaReturnUrl = undefined;
sendOpenTelegramLink(addReturnStrategy(directLinkUrl.toString(), options));
@@ -316,15 +312,13 @@ export function redirectToTelegram(
} else {
// For browser
if (isOS('ios', 'android')) {
- // Use the `back` strategy. TON Space should pass the command to
- // return to the initiating application to Telegram and close itself.
+ // Use the `none` strategy. TON Space should do nothing after the user action.
- options.returnStrategy = 'back';
+ options.returnStrategy = 'none';
openLinkBlank(addReturnStrategy(directLinkUrl.toString(), options.returnStrategy));
} else if (isOS('macos', 'windows', 'linux')) {
- // Use the `none` strategy.
- // TON Space should close itself after the user action.
+ // Use the `none` strategy. TON Space should do nothing after the user action.
options.returnStrategy = 'none';
options.twaReturnUrl = undefined;