2
0
mirror of https://github.com/kotatogram/kotatogram-desktop synced 2025-09-03 16:15:13 +00:00

Support theming for webview-s (payments, attach).

This commit is contained in:
John Preston
2022-03-29 00:14:10 +04:00
parent df15ff9f8e
commit aed1904b4c
14 changed files with 147 additions and 31 deletions

View File

@@ -432,12 +432,14 @@ void SessionNavigation::requestAttachWebview(
not_null<UserData*> bot,
const WebViewButton &button) {
using Flag = MTPmessages_RequestWebView::Flag;
const auto flags = Flag::f_theme_params
| (button.url.isEmpty() ? Flag(0) : Flag::f_url);
_api.request(MTPmessages_RequestWebView(
MTP_flags(button.url.isEmpty() ? Flag(0) : Flag::f_url),
MTP_flags(flags),
peer->input,
bot->inputUser,
MTP_bytes(button.url),
MTPDataJSON(), // theme_params
MTP_dataJSON(MTP_bytes(Theme::WebViewParams())),
MTPint() // reply_to_msg_id
)).done([=](const MTPWebViewResult &result) {
result.match([&](const MTPDwebViewResultUrl &data) {
@@ -509,7 +511,17 @@ void SessionNavigation::showAttachWebview(
.userDataPath = session().domain().local().webviewDataPath(),
.sendData = sendData,
.close = close,
.themeParams = [] { return Window::Theme::WebViewParams(); },
});
session().data().webViewResultSent(
) | rpl::filter([=](const Data::Session::WebViewResultSent &sent) {
return (sent.peerId == peer->id)
&& (sent.botId == bot->id)
&& (sent.queryId == queryId);
}) | rpl::start_with_next([=] {
_botWebView = nullptr;
}, _botWebView->lifetime());
}
void SessionNavigation::requestAddToMenu(