Skip to content

Commit

Permalink
fix(ui): enhance transitions for android and macos
Browse files Browse the repository at this point in the history
  • Loading branch information
thekiba committed Aug 14, 2024
1 parent 34b3da7 commit d528f9c
Showing 1 changed file with 8 additions and 20 deletions.
28 changes: 8 additions & 20 deletions packages/ui/src/app/utils/url-strategy-helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit d528f9c

Please sign in to comment.