mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-04-16 14:17:12 +02:00
Fix boost reassign.
This commit is contained in:
parent
076291b98f
commit
bde39970a0
2 changed files with 14 additions and 9 deletions
|
@ -685,6 +685,7 @@ void SessionNavigation::applyBoost(
|
|||
done(false);
|
||||
return;
|
||||
}
|
||||
auto slot = int();
|
||||
auto different = PeerId();
|
||||
auto earliest = TimeId(-1);
|
||||
const auto now = base::unixtime::now();
|
||||
|
@ -695,13 +696,13 @@ void SessionNavigation::applyBoost(
|
|||
? peerFromMTP(*data.vpeer())
|
||||
: PeerId();
|
||||
if (!peerId && cooldown <= now) {
|
||||
applyBoostChecked(channel, done);
|
||||
applyBoostChecked(channel, data.vslot().v, done);
|
||||
return;
|
||||
} else if (peerId != channel->id) {
|
||||
} else if (peerId != channel->id
|
||||
&& (earliest < 0 || cooldown < earliest)) {
|
||||
slot = data.vslot().v;
|
||||
different = peerId;
|
||||
if (earliest < 0 || cooldown < earliest) {
|
||||
earliest = cooldown;
|
||||
}
|
||||
earliest = cooldown;
|
||||
}
|
||||
}
|
||||
if (different) {
|
||||
|
@ -727,7 +728,7 @@ void SessionNavigation::applyBoost(
|
|||
done(false);
|
||||
} else {
|
||||
const auto peer = _session->data().peer(different);
|
||||
replaceBoostConfirm(peer, channel, done);
|
||||
replaceBoostConfirm(peer, channel, slot, done);
|
||||
}
|
||||
} else {
|
||||
uiShow()->show(Ui::MakeConfirmBox({
|
||||
|
@ -748,11 +749,12 @@ void SessionNavigation::applyBoost(
|
|||
void SessionNavigation::replaceBoostConfirm(
|
||||
not_null<PeerData*> from,
|
||||
not_null<ChannelData*> channel,
|
||||
int slot,
|
||||
Fn<void(bool)> done) {
|
||||
const auto forwarded = std::make_shared<bool>(false);
|
||||
const auto confirmed = [=](Fn<void()> close) {
|
||||
*forwarded = true;
|
||||
applyBoostChecked(channel, done);
|
||||
applyBoostChecked(channel, slot, done);
|
||||
close();
|
||||
};
|
||||
const auto box = uiShow()->show(Box([=](not_null<Ui::GenericBox*> box) {
|
||||
|
@ -781,10 +783,11 @@ void SessionNavigation::replaceBoostConfirm(
|
|||
|
||||
void SessionNavigation::applyBoostChecked(
|
||||
not_null<ChannelData*> channel,
|
||||
int slot,
|
||||
Fn<void(bool)> done) {
|
||||
_api.request(MTPpremium_ApplyBoost(
|
||||
MTP_flags(0),
|
||||
MTPVector<MTPint>(), // slots
|
||||
MTP_flags(MTPpremium_ApplyBoost::Flag::f_slots),
|
||||
MTP_vector<MTPint>({ MTP_int(slot) }),
|
||||
channel->input
|
||||
)).done([=](const MTPpremium_MyBoosts &result) {
|
||||
done(true);
|
||||
|
|
|
@ -318,9 +318,11 @@ private:
|
|||
void replaceBoostConfirm(
|
||||
not_null<PeerData*> from,
|
||||
not_null<ChannelData*> channel,
|
||||
int slot,
|
||||
Fn<void(bool)> done);
|
||||
void applyBoostChecked(
|
||||
not_null<ChannelData*> channel,
|
||||
int slot,
|
||||
Fn<void(bool)> done);
|
||||
|
||||
const not_null<Main::Session*> _session;
|
||||
|
|
Loading…
Add table
Reference in a new issue