Reload web view when reopening different inline button#30725
Open
eav93 wants to merge 1 commit into
Open
Conversation
WebViewSourceButton compared only the `simple` flag, so two different inline keyboard buttons opening different URLs produced equal sources. AttachWebView::open() then just activated the previously opened panel for the same bot and dropped the new URL on the floor, with no events fired in the running web app. Include the button URL in WebViewSourceButton so that distinct URLs produce distinct sources and a fresh WebViewInstance is created. Fixes telegramdesktop#29475.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Fixes #29475.
When two inline keyboard buttons in the same chat point to different web app URLs of the same bot, clicking the second one while the first web app panel is still open silently does nothing — the new URL is not loaded and no event (
themeChanged,viewportChanged, etc.) is fired inside the running web app.Root cause
AttachWebView::open()deduplicates by(bot, source):For inline buttons the source is built in
api/api_bot.cppas.source = InlineBots::WebViewSourceButton{ .simple = false },WebViewSourceButtononly stores thesimpleflag, so two different inline buttons of the same bot always compare equal. The match succeeds andactivate()just calls_panel->requestActivate()on the existing panel, ignoring the new URL entirely.Fix
Include the button URL in
WebViewSourceButtonso distinct URLs produce distinct sources, and a freshWebViewInstanceis created (matching how, e.g., MainMenu and InlineButton already coexist for the same bot).Telegram/SourceFiles/inline_bots/bot_attach_web_view.h— addQByteArray urltoWebViewSourceButton, switch the defaultedoperator==to by-const-ref since the struct is no longer trivial enough to pass by value cleanly.Telegram/SourceFiles/api/api_bot.cpp— passbutton->dataas the newurlfield in bothButtonType::WebViewandButtonType::SimpleWebViewpaths.Clicking the same button twice still hits the dedup path (URL is identical) and only re-activates the existing panel — previous behavior preserved.
Out of scope
The original issue also mentions the
deactivatedevent not firing when tapping outside the panel. That lives inUi::BotWebView::Paneland is a separate change.Test plan