feat(telegram): re-apply theme live on themeChanged
CI / changes (pull_request) Successful in 2s
CI / unit (pull_request) Has been skipped
CI / integration (pull_request) Has been skipped
CI / ui (pull_request) Successful in 56s
CI / gate (pull_request) Successful in 0s
CI / deploy (pull_request) Successful in 1m21s
CI / changes (pull_request) Successful in 2s
CI / unit (pull_request) Has been skipped
CI / integration (pull_request) Has been skipped
CI / ui (pull_request) Successful in 56s
CI / gate (pull_request) Successful in 0s
CI / deploy (pull_request) Successful in 1m21s
The Mini App read Telegram's themeParams/colorScheme only once at launch, so switching Telegram's light/dark theme (or its auto day/night) while the app was open left the SPA on stale colours until a relaunch. Subscribe to the themeChanged WebApp event and re-apply the theme live. Extract the launch-time token + colour-scheme + chrome application into syncTelegramTheme (reading live themeParams when no launch snapshot is passed) and call it from both applyTelegramChrome (launch) and the new event handler. Add a telegramThemeParams live getter (+ unit test). Drop the stale 'immersive fullscreen' note from applyTelegramChrome — the app deliberately does not request fullscreen.
This commit is contained in:
@@ -7,6 +7,7 @@ import {
|
||||
routeExternalLinkInTelegram,
|
||||
telegramLaunch,
|
||||
telegramOpenExternalLink,
|
||||
telegramThemeParams,
|
||||
} from './telegram';
|
||||
|
||||
function stubWebApp(initData: string, startParam?: string) {
|
||||
@@ -44,6 +45,12 @@ describe('telegram launch detection', () => {
|
||||
expect(launch.startParam).toBe('g123');
|
||||
expect(launch.theme?.bg_color).toBe('#101418');
|
||||
});
|
||||
|
||||
it('telegramThemeParams reads the live palette (undefined outside Telegram)', () => {
|
||||
expect(telegramThemeParams()).toBeUndefined();
|
||||
stubWebApp('query_id=abc');
|
||||
expect(telegramThemeParams()?.bg_color).toBe('#101418');
|
||||
});
|
||||
});
|
||||
|
||||
describe('telegramOpenExternalLink', () => {
|
||||
|
||||
Reference in New Issue
Block a user