2
0
mirror of https://github.com/telegramdesktop/tdesktop synced 2025-08-31 06:26:18 +00:00

Merge branch 'game_media' into player

Conflicts:
	Telegram/SourceFiles/application.cpp
	Telegram/SourceFiles/inline_bots/inline_bot_layout_internal.cpp
	Telegram/SourceFiles/mainwidget.cpp
	Telegram/SourceFiles/mainwidget.h
	Telegram/SourceFiles/structs.h
This commit is contained in:
John Preston
2016-09-29 00:31:43 +03:00
63 changed files with 11739 additions and 9283 deletions

View File

@@ -33,6 +33,7 @@ Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org
#include "inline_bots/inline_bot_result.h"
#include "data/data_drafts.h"
#include "history/history_service_layout.h"
#include "history/history_media_types.h"
#include "profile/profile_members_widget.h"
#include "core/click_handler_types.h"
#include "stickers/emoji_pan.h"
@@ -4506,6 +4507,7 @@ void HistoryWidget::updateControlsVisibility() {
if (!_a_show.animating()) {
_topShadow.setVisible(_peer ? true : false);
}
updateToEndVisibility();
if (!_history || _a_show.animating()) {
_reportSpamPanel.hide();
_scroll.hide();
@@ -4536,7 +4538,6 @@ void HistoryWidget::updateControlsVisibility() {
return;
}
updateToEndVisibility();
if (_pinnedBar) {
_pinnedBar->cancel.show();
_pinnedBar->shadow.show();
@@ -5797,16 +5798,13 @@ void HistoryWidget::app_sendBotCallback(const HistoryMessageReplyMarkup::Button
BotCallbackInfo info = { bot, msg->fullId(), row, col, (button->type == ButtonType::Game) };
MTPmessages_GetBotCallbackAnswer::Flags flags = 0;
QByteArray sendData;
int32 sendGameId = 0;
if (info.game) {
flags = MTPmessages_GetBotCallbackAnswer::Flag::f_game_id;
auto strData = QString::fromUtf8(button->data);
sendGameId = strData.midRef(0, strData.indexOf(',')).toInt();
flags = MTPmessages_GetBotCallbackAnswer::Flag::f_game;
} else if (button->type == ButtonType::Callback) {
flags = MTPmessages_GetBotCallbackAnswer::Flag::f_data;
sendData = button->data;
}
button->requestId = MTP::send(MTPmessages_GetBotCallbackAnswer(MTP_flags(flags), _peer->input, MTP_int(msg->id), MTP_bytes(sendData), MTP_int(sendGameId)), rpcDone(&HistoryWidget::botCallbackDone, info), rpcFail(&HistoryWidget::botCallbackFail, info));
button->requestId = MTP::send(MTPmessages_GetBotCallbackAnswer(MTP_flags(flags), _peer->input, MTP_int(msg->id), MTP_bytes(sendData)), rpcDone(&HistoryWidget::botCallbackDone, info), rpcFail(&HistoryWidget::botCallbackFail, info));
Ui::repaintHistoryItem(msg);
if (_replyToId == msg->id) {
@@ -7382,6 +7380,8 @@ void HistoryWidget::updateBotKeyboard(History *h, bool force) {
}
void HistoryWidget::updateToEndVisibility() {
if (_a_show.animating()) return;
auto haveUnreadBelowBottom = [this](History *history) {
if (!_list || !history || history->unreadCount() <= 0) {
return false;
@@ -7392,7 +7392,7 @@ void HistoryWidget::updateToEndVisibility() {
return (_list->itemTop(history->showFrom) >= _scroll.scrollTop() + _scroll.height());
};
auto isToEndVisible = [this, &haveUnreadBelowBottom]() {
if (!_history || _a_show.animating() || _firstLoadRequest) {
if (!_history || _firstLoadRequest) {
return false;
}
if (!_history->loadedAtBottom() || _replyReturn) {
@@ -8138,7 +8138,7 @@ void HistoryWidget::gotPreview(QString links, const MTPMessageMedia &result, mtp
_previewRequest = 0;
}
if (result.type() == mtpc_messageMediaWebPage) {
WebPageData *data = App::feedWebPage(result.c_messageMediaWebPage().vwebpage);
auto data = App::feedWebPage(result.c_messageMediaWebPage().vwebpage);
_previewCache.insert(links, data->id);
if (data->pendingTill > 0 && data->pendingTill <= unixtime()) {
data->pendingTill = -1;
@@ -8147,7 +8147,7 @@ void HistoryWidget::gotPreview(QString links, const MTPMessageMedia &result, mtp
_previewData = (data->id && data->pendingTill >= 0) ? data : 0;
updatePreview();
}
if (App::main()) App::main()->webPagesUpdate();
if (App::main()) App::main()->webPagesOrGamesUpdate();
} else if (result.type() == mtpc_messageMediaEmpty) {
_previewCache.insert(links, 0);
if (links == _previewLinks && !_previewCancelled) {