mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +02:00
Improve gift-to-channel button conditions.
This commit is contained in:
parent
9f79dda463
commit
16830a410c
2 changed files with 34 additions and 18 deletions
|
@ -1015,6 +1015,18 @@ void HistoryWidget::refreshJoinChannelText() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void HistoryWidget::refreshGiftToChannelShown() {
|
||||||
|
if (!_giftToChannelIn || !_giftToChannelOut) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const auto channel = _peer->asChannel();
|
||||||
|
const auto shown = channel
|
||||||
|
&& channel->isBroadcast()
|
||||||
|
&& channel->stargiftsAvailable();
|
||||||
|
_giftToChannelIn->setVisible(shown);
|
||||||
|
_giftToChannelOut->setVisible(shown);
|
||||||
|
}
|
||||||
|
|
||||||
void HistoryWidget::refreshTopBarActiveChat() {
|
void HistoryWidget::refreshTopBarActiveChat() {
|
||||||
const auto state = computeDialogsEntryState();
|
const auto state = computeDialogsEntryState();
|
||||||
_topBar->setActiveChat(state, _history->sendActionPainter());
|
_topBar->setActiveChat(state, _history->sendActionPainter());
|
||||||
|
@ -2036,17 +2048,22 @@ void HistoryWidget::setupShortcuts() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void HistoryWidget::setupGiftToChannelButton() {
|
void HistoryWidget::setupGiftToChannelButton() {
|
||||||
_giftToChannel = Ui::CreateChild<Ui::IconButton>(
|
const auto setupButton = [=](not_null<Ui::RpWidget*> parent) {
|
||||||
_muteUnmute.data(),
|
auto *button = Ui::CreateChild<Ui::IconButton>(
|
||||||
st::historyGiftToChannel);
|
parent.get(),
|
||||||
_muteUnmute->widthValue() | rpl::start_with_next([=](int width) {
|
st::historyGiftToChannel);
|
||||||
_giftToChannel->moveToRight(0, 0);
|
parent->widthValue() | rpl::start_with_next([=](int width) {
|
||||||
}, _giftToChannel->lifetime());
|
button->moveToRight(0, 0);
|
||||||
_giftToChannel->setClickedCallback([=] {
|
}, button->lifetime());
|
||||||
if (_peer) {
|
button->setClickedCallback([=] {
|
||||||
Ui::ShowStarGiftBox(controller(), _peer);
|
if (_peer) {
|
||||||
}
|
Ui::ShowStarGiftBox(controller(), _peer);
|
||||||
});
|
}
|
||||||
|
});
|
||||||
|
return button;
|
||||||
|
};
|
||||||
|
_giftToChannelIn = setupButton(_muteUnmute);
|
||||||
|
_giftToChannelOut = setupButton(_joinChannel);
|
||||||
}
|
}
|
||||||
|
|
||||||
void HistoryWidget::pushReplyReturn(not_null<HistoryItem*> item) {
|
void HistoryWidget::pushReplyReturn(not_null<HistoryItem*> item) {
|
||||||
|
@ -2409,6 +2426,8 @@ void HistoryWidget::showHistory(
|
||||||
) | rpl::start_with_next([=] {
|
) | rpl::start_with_next([=] {
|
||||||
updateControlsGeometry();
|
updateControlsGeometry();
|
||||||
}, _contactStatus->bar().lifetime());
|
}, _contactStatus->bar().lifetime());
|
||||||
|
|
||||||
|
refreshGiftToChannelShown();
|
||||||
if (const auto user = _peer->asUser()) {
|
if (const auto user = _peer->asUser()) {
|
||||||
_businessBotStatus = std::make_unique<BusinessBotStatus>(
|
_businessBotStatus = std::make_unique<BusinessBotStatus>(
|
||||||
controller(),
|
controller(),
|
||||||
|
@ -2418,8 +2437,6 @@ void HistoryWidget::showHistory(
|
||||||
) | rpl::start_with_next([=] {
|
) | rpl::start_with_next([=] {
|
||||||
updateControlsGeometry();
|
updateControlsGeometry();
|
||||||
}, _businessBotStatus->bar().lifetime());
|
}, _businessBotStatus->bar().lifetime());
|
||||||
} else if (const auto channel = _peer->asChannel()) {
|
|
||||||
_giftToChannel->setVisible(channel->stargiftsAvailable());
|
|
||||||
}
|
}
|
||||||
orderWidgets();
|
orderWidgets();
|
||||||
controller()->tabbedSelector()->setCurrentPeer(_peer);
|
controller()->tabbedSelector()->setCurrentPeer(_peer);
|
||||||
|
@ -8372,10 +8389,7 @@ void HistoryWidget::fullInfoUpdated() {
|
||||||
if (readyForBotStart && clearMaybeSendStart() && hasNonEmpty) {
|
if (readyForBotStart && clearMaybeSendStart() && hasNonEmpty) {
|
||||||
sendBotStartCommand();
|
sendBotStartCommand();
|
||||||
}
|
}
|
||||||
|
refreshGiftToChannelShown();
|
||||||
if (const auto channel = _peer->asChannel()) {
|
|
||||||
_giftToChannel->setVisible(channel->stargiftsAvailable());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if (updateCmdStartShown()) {
|
if (updateCmdStartShown()) {
|
||||||
refresh = true;
|
refresh = true;
|
||||||
|
|
|
@ -395,6 +395,7 @@ private:
|
||||||
void refreshTopBarActiveChat();
|
void refreshTopBarActiveChat();
|
||||||
|
|
||||||
void refreshJoinChannelText();
|
void refreshJoinChannelText();
|
||||||
|
void refreshGiftToChannelShown();
|
||||||
void requestMessageData(MsgId msgId);
|
void requestMessageData(MsgId msgId);
|
||||||
void messageDataReceived(not_null<PeerData*> peer, MsgId msgId);
|
void messageDataReceived(not_null<PeerData*> peer, MsgId msgId);
|
||||||
|
|
||||||
|
@ -774,7 +775,8 @@ private:
|
||||||
object_ptr<Ui::FlatButton> _botStart;
|
object_ptr<Ui::FlatButton> _botStart;
|
||||||
object_ptr<Ui::FlatButton> _joinChannel;
|
object_ptr<Ui::FlatButton> _joinChannel;
|
||||||
object_ptr<Ui::FlatButton> _muteUnmute;
|
object_ptr<Ui::FlatButton> _muteUnmute;
|
||||||
QPointer<Ui::IconButton> _giftToChannel;
|
QPointer<Ui::IconButton> _giftToChannelIn;
|
||||||
|
QPointer<Ui::IconButton> _giftToChannelOut;
|
||||||
object_ptr<Ui::FlatButton> _reportMessages;
|
object_ptr<Ui::FlatButton> _reportMessages;
|
||||||
struct {
|
struct {
|
||||||
object_ptr<Ui::RoundButton> button = { nullptr };
|
object_ptr<Ui::RoundButton> button = { nullptr };
|
||||||
|
|
Loading…
Add table
Reference in a new issue