Closed heyqbnk closed 1 year ago
Mini app will now handle reload_iframe
event and call location.reload
on its side (see commit). You just have to update the library and then check whether the issue is fixed.
What should happen if the mini app declares reload_supported
, but then hangs up or gets killed by the browser? On the user side, reload button stops working.
What should happen if the mini app declares
reload_supported
, but then hangs up or gets killed by the browser? On the user side, reload button stops working.
Added fallback with 300ms. Should be enough.
In my mind, the better solution would be adding new method to set the location which can be used on the Mini App's side.
Think of some method called web_app_set_location which notifies the Telegram application about changes in Mini App's location.
This will let us to avoid creation of any fallbacks and application stuttering, this does not break backward compatibility with previous behavior and in this case we can always say developer "you just forgot to notify Telegram application about location changes". But we should add some checks related to the passed location
So, this could work this way:
This is not really the native iframe reload and has some flaws, but this will probably work more intuitive. I remember this kind of solution in some other popular platform of the same kind
This approach would require implementing it in every other Telegram app, seems like overkill to me.
Current workaround is about fixing the issue that exists only on Web. The only thing developer should do here, is to update the library, reloading will be handled by it.
I have just found out, that current solution still does not cover all cases. The problem is in the case when Mini App didn't respond in time, Telegram application will reload the Mini App with force, making it think, it was just launched, but not reloaded. This still does not fully solve the problem
Why can't it respond with iframe_will_reload
in time?
Only synchronous extensive computations came into my mind.
I don't really like the approach connected with "you have N time to do it. Otherwise something will break" when it can be avoided. It also brings us new not documented Telegram Mini Apps method property, event and method, when it all could be replaced with the only 1 clear method.
Moreover, I don't like global architecture solutions which are focused on working in some specific library implementing platform functionality. This solution becomes really worse than just implementing the single method in case, there are other libraries rather than Telegram SDK
El El lun, 6 nov 2023 a las 16:24, Eduard Kuzmenko @.***> escribió:
Mini app will now handle reload_iframe event and call location.reload on its side (see commit https://github.com/morethanwords/tweb/commit/d77232985ce417be5bb4261f7e0d3abd7bfa85bf). You just have to update the library and then check whether the issue is fixed.
— Reply to this email directly, view it on GitHub https://github.com/morethanwords/tweb/issues/271#issuecomment-1795085924, or unsubscribe https://github.com/notifications/unsubscribe-auth/A56ZJHWW567MDLK3YB47DZTYDD6KRAVCNFSM6AAAAAA67MRXL2VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTOOJVGA4DKOJSGQ . You are receiving this because you are subscribed to this thread.Message ID: @.***>
Is your feature request related to a problem? Please describe.
It seems like both Web A and Web K versions of Telegram require some parameter which is responsible for determining the unique application launch. We already discussed this problem in this issue in Web A repository, but @zubiden offered to create an issue in Web K to make a discussion: https://github.com/Ajaxy/telegram-tt/issues/282
As long as we are unable to reload iframe we appended using the default way (
iframe.currentWindow.reload()
or something) due to security policy violations, we have to reload it by re-inserting the iframe with the initial location.In turn, this makes the Mini App to lose all its routing history and create possible problems related to components (BackButton, MainButton, etc.) state restoration as long as we don't really know if current application was reloaded or re-launched.
Moreover, external developers are unable to solve this problem by themselves as long as there is no possible solution for this problem at the moment. Each application restart is always considered as fresh (even when page was "reloaded"), because session storage would have the same state (because application is launched in the same tab) and init data can be missing in some cases. So, we can't use init data
hash
to differ one launch from another.Describe the solution you'd like
We could probably add some launch parameter called
tgWebAppTimestamp
which defines the timestamp of launch parameters creation. This will allow developers to differ one application launch from another even when init data is missing.