mirror of
https://github.com/telegramdesktop/tdesktop
synced 2025-08-31 14:38:15 +00:00
Added same_peer flag support for keyboard switch inline button.
This commit is contained in:
@@ -689,10 +689,10 @@ void checkForSwitchInlineButton(HistoryItem *item) {
|
||||
} // namespace
|
||||
|
||||
HistoryItem *Histories::addNewMessage(const MTPMessage &msg, NewMessageType type) {
|
||||
PeerId peer = peerFromMessage(msg);
|
||||
auto peer = peerFromMessage(msg);
|
||||
if (!peer) return nullptr;
|
||||
|
||||
HistoryItem *result = App::history(peer)->addNewMessage(msg, type);
|
||||
auto result = App::history(peer)->addNewMessage(msg, type);
|
||||
if (result && type == NewMessageUnread) {
|
||||
checkForSwitchInlineButton(result);
|
||||
}
|
||||
@@ -2552,9 +2552,14 @@ void HistoryMessageReplyMarkup::createFromButtonRows(const QVector<MTPKeyboardBu
|
||||
buttonRow.push_back({ Button::Url, qs(buttonData.vtext), qba(buttonData.vurl), 0 });
|
||||
} break;
|
||||
case mtpc_keyboardButtonSwitchInline: {
|
||||
const auto &buttonData(button.c_keyboardButtonSwitchInline());
|
||||
buttonRow.push_back({ Button::SwitchInline, qs(buttonData.vtext), qba(buttonData.vquery), 0 });
|
||||
flags |= MTPDreplyKeyboardMarkup_ClientFlag::f_has_switch_inline_button;
|
||||
auto &buttonData = button.c_keyboardButtonSwitchInline();
|
||||
auto buttonType = buttonData.is_same_peer() ? Button::SwitchInlineSame : Button::SwitchInline;
|
||||
buttonRow.push_back({ buttonType, qs(buttonData.vtext), qba(buttonData.vquery), 0 });
|
||||
if (buttonType == Button::SwitchInline) {
|
||||
// Optimization flag.
|
||||
// Fast check on all new messages if there is a switch button to auto-click it.
|
||||
flags |= MTPDreplyKeyboardMarkup_ClientFlag::f_has_switch_inline_button;
|
||||
}
|
||||
} break;
|
||||
}
|
||||
}
|
||||
@@ -6593,6 +6598,7 @@ void HistoryMessage::KeyboardStyle::paintButtonIcon(Painter &p, const QRect &rec
|
||||
case Button::Url: sprite = st::msgBotKbUrlIcon; break;
|
||||
// case Button::RequestPhone: sprite = st::msgBotKbRequestPhoneIcon; break;
|
||||
// case Button::RequestLocation: sprite = st::msgBotKbRequestLocationIcon; break;
|
||||
case Button::SwitchInlineSame:
|
||||
case Button::SwitchInline: sprite = st::msgBotKbSwitchPmIcon; break;
|
||||
}
|
||||
if (!sprite.isEmpty()) {
|
||||
@@ -6612,6 +6618,7 @@ int HistoryMessage::KeyboardStyle::minButtonWidth(HistoryMessageReplyMarkup::But
|
||||
case Button::Url: iconWidth = st::msgBotKbUrlIcon.pxWidth(); break;
|
||||
//case Button::RequestPhone: iconWidth = st::msgBotKbRequestPhoneIcon.pxWidth(); break;
|
||||
//case Button::RequestLocation: iconWidth = st::msgBotKbRequestLocationIcon.pxWidth(); break;
|
||||
case Button::SwitchInlineSame:
|
||||
case Button::SwitchInline: iconWidth = st::msgBotKbSwitchPmIcon.pxWidth(); break;
|
||||
case Button::Callback: iconWidth = st::msgInvSendingImg.pxWidth(); break;
|
||||
}
|
||||
|
Reference in New Issue
Block a user