Show error on webapp share-to-story.

This commit is contained in:
John Preston 2024-08-14 16:49:26 +02:00
parent eec9c8a46b
commit 3001464f6b
3 changed files with 17 additions and 0 deletions

View file

@ -3249,6 +3249,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
"lng_bot_add_to_side_menu" = "{bot} asks your permission to be added as an option to your main menu so you can access it any time.";
"lng_bot_add_to_side_menu_done" = "Bot added to the main menu.";
"lng_bot_no_scan_qr" = "QR Codes for bots are not supported on Desktop. Please use one of Telegram's mobile apps.";
"lng_bot_no_share_story" = "Sharing to Stories is not supported on Desktop. Please use one of Telegram's mobile apps.";
"lng_bot_click_to_start" = "Click here to use this bot.";
"lng_bot_status_users#one" = "{count} user";
"lng_bot_status_users#other" = "{count} users";

View file

@ -699,6 +699,8 @@ bool Panel::createWebview(const Webview::ThemeParams &params) {
openPopup(arguments);
} else if (command == "web_app_open_scan_qr_popup") {
openScanQrPopup(arguments);
} else if (command == "web_app_share_to_story") {
openShareStory(arguments);
} else if (command == "web_app_request_write_access") {
requestWriteAccess();
} else if (command == "web_app_request_phone") {
@ -936,6 +938,19 @@ void Panel::openScanQrPopup(const QJsonObject &args) {
});
}
void Panel::openShareStory(const QJsonObject &args) {
const auto widget = _webview->window.widget();
[[maybe_unused]] const auto ok = Webview::ShowBlockingPopup({
.parent = widget ? widget->window() : nullptr,
.text = tr::lng_bot_no_share_story(tr::now),
.buttons = { {
.id = "ok",
.text = tr::lng_box_ok(tr::now),
.type = Webview::PopupArgs::Button::Type::Ok,
}},
});
}
void Panel::requestWriteAccess() {
if (_inBlockingRequest) {
replyRequestWriteAccess(false);

View file

@ -135,6 +135,7 @@ private:
void openInvoice(const QJsonObject &args);
void openPopup(const QJsonObject &args);
void openScanQrPopup(const QJsonObject &args);
void openShareStory(const QJsonObject &args);
void requestWriteAccess();
void replyRequestWriteAccess(bool allowed);
void requestPhone();