Skip to content

[Bug]: theme_changed event not being fired if TMA is launched from Menu Button #789

@linustws

Description

@linustws

Telegram Application

Telegram for iOS

Describe the Bug

tested for both iOS and macOS

iOS: theme_changed event fires whenever night mode is switched only when app is launched from Main App, but not when app is launched from Menu Button

macOS: theme_changed event fires regardless of whether app is launched from Main App or Menu Button (expected behaviour)

To Reproduce

Steps to reproduce the behavior in Test Env:

  1. Import setDebug from '@tma.js/bridge' and setDebug(true).
  2. On iOS, launch a miniapp from the Menu Button.
  3. Open safari devtools (ref) and select opened webview URL under Telegram block.
  4. Hide the miniapp to tray.
  5. Go to Telegram Settings and switch Night Mode.
  6. Witness theme_changed event not being received, no debug log.
  7. Repeat above steps for iOS launch from Main App and macOS launch from both Main App and Menu Button to observe the discrepancy.

Also, would be great if there's a isNightMode Method & Event to know when to toggle dark mode, would like to have my own theming and not bind with tg theme params. Currently using a workaround to check themeparams bg-color and they don't follow the same theme on different devices (bg_color on iOS is #000000 while it's #18222D on macOS when Night Mode ), unsure whether Android's bg_color is different, hard to test for all devices.

Expected Behavior

Expected to see log entry from debug mode like this:

[Log] INFO 14:12:55.448 Bridge – "Event received:" (@tma__js_bridge.js, line 903)
{name: "theme_changed", payload: Object}

theme_changed event fires regardless of whether app is launched from Main App or Menu Button, for consistency, else have to manually call web_app_request_theme to check

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions