Skip to content

Commit

Permalink
Merge pull request #251 from Telegram-Mini-Apps/bugfix/reload-iframe
Browse files Browse the repository at this point in the history
Call `iframe_will_reload` method on `reload_iframe` event
  • Loading branch information
heyqbnk authored Mar 9, 2024
2 parents 2b576d0 + 25ee92d commit 1064370
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/itchy-jobs-rescue.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@tma.js/sdk": patch
---

Call iframe_will_reload method on reload_iframe event
5 changes: 4 additions & 1 deletion packages/sdk/src/init/init.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,10 @@ export function init(options: InitOptions = {}): InitResult | Promise<InitResult
// application which is used in catchCustomStyles function. We should call this method also
// to start receiving "reload_iframe" events from the Telegram application.
postEvent('iframe_ready', { reload_supported: true });
on('reload_iframe', () => window.location.reload());
on('reload_iframe', () => {
postEvent('iframe_will_reload');
window.location.reload();
});
}

const result: Omit<InitResult, 'viewport'> = {
Expand Down

0 comments on commit 1064370

Please sign in to comment.