Fixed some unused-but-set-variable warnings.

This commit is contained in:
23rd 2025-04-12 20:44:45 +03:00 committed by John Preston
parent 667e614bf3
commit 9ad1d1c25d
55 changed files with 98 additions and 99 deletions

View file

@ -28,8 +28,8 @@ constexpr auto kSearchPerPage = 50;
auto result = MessageIdsList(); auto result = MessageIdsList();
for (const auto &message : messages) { for (const auto &message : messages) {
const auto peerId = PeerFromMessage(message); const auto peerId = PeerFromMessage(message);
if (const auto peer = data->peerLoaded(peerId)) { if (data->peerLoaded(peerId)) {
if (const auto lastDate = DateFromMessage(message)) { if (DateFromMessage(message)) {
const auto item = data->addNewMessage( const auto item = data->addNewMessage(
message, message,
MessageFlags(), MessageFlags(),

View file

@ -313,7 +313,7 @@ void PublicForwards::request(
const auto msgId = IdFromMessage(message); const auto msgId = IdFromMessage(message);
const auto peerId = PeerFromMessage(message); const auto peerId = PeerFromMessage(message);
const auto lastDate = DateFromMessage(message); const auto lastDate = DateFromMessage(message);
if (const auto peer = owner.peerLoaded(peerId)) { if (owner.peerLoaded(peerId)) {
if (!lastDate) { if (!lastDate) {
return; return;
} }

View file

@ -808,7 +808,7 @@ void AddParticipantsBoxController::rowClicked(not_null<PeerListRow*> row) {
updateTitle(); updateTitle();
} else if (const auto channel = _peer ? _peer->asChannel() : nullptr) { } else if (const auto channel = _peer ? _peer->asChannel() : nullptr) {
if (!_peer->isMegagroup()) { if (!_peer->isMegagroup()) {
showBox(Box<MaxInviteBox>(_peer->asChannel())); showBox(Box<MaxInviteBox>(channel));
} }
} else if (count >= serverConfig.chatSizeMax } else if (count >= serverConfig.chatSizeMax
&& count < serverConfig.megagroupSizeMax) { && count < serverConfig.megagroupSizeMax) {

View file

@ -453,7 +453,7 @@ void ChoosePeerBoxController::rowClicked(not_null<PeerListRow*> row) {
const auto onstack = callback; const auto onstack = callback;
onstack({ peer }); onstack({ peer });
}; };
if (const auto user = peer->asUser()) { if (peer->isUser()) {
done(); done();
} else { } else {
delegate()->peerListUiShow()->showBox( delegate()->peerListUiShow()->showBox(

View file

@ -689,7 +689,7 @@ UserData *ParticipantsAdditionalData::applyAdmin(
const auto user = _peer->owner().userLoaded(data.userId()); const auto user = _peer->owner().userLoaded(data.userId());
if (!user) { if (!user) {
return nullptr; return nullptr;
} else if (const auto chat = _peer->asChat()) { } else if (_peer->isChat()) {
// This can come from saveAdmin callback. // This can come from saveAdmin callback.
_admins.emplace(user); _admins.emplace(user);
return user; return user;
@ -733,7 +733,7 @@ UserData *ParticipantsAdditionalData::applyRegular(UserId userId) {
const auto user = _peer->owner().userLoaded(userId); const auto user = _peer->owner().userLoaded(userId);
if (!user) { if (!user) {
return nullptr; return nullptr;
} else if (const auto chat = _peer->asChat()) { } else if (_peer->isChat()) {
// This can come from saveAdmin or saveRestricted callback. // This can come from saveAdmin or saveRestricted callback.
_admins.erase(user); _admins.erase(user);
return user; return user;
@ -913,7 +913,7 @@ void ParticipantsBoxController::setupListChangeViewers() {
return; return;
} }
} }
if (const auto row = delegate()->peerListFindRow(user->id.value)) { if (delegate()->peerListFindRow(user->id.value)) {
delegate()->peerListPartitionRows([&](const PeerListRow &row) { delegate()->peerListPartitionRows([&](const PeerListRow &row) {
return (row.peer() == user); return (row.peer() == user);
}); });

View file

@ -1793,7 +1793,7 @@ void SendGiftBox(
ShowSentToast(window, details.descriptor, details); ShowSentToast(window, details.descriptor, details);
} }
if (const auto strong = weak.data()) { if (const auto strong = weak.data()) {
box->closeBox(); strong->closeBox();
} }
}; };
SendGift(window, peer, api, details, done); SendGift(window, peer, api, details, done);

View file

@ -1510,7 +1510,7 @@ void StickerSetBox::Inner::fillDeleteStickerBox(
sticker->paintRequest( sticker->paintRequest(
) | rpl::start_with_next([=] { ) | rpl::start_with_next([=] {
auto p = Painter(sticker); auto p = Painter(sticker);
if (const auto strong = weak.data()) { if ([[maybe_unused]] const auto strong = weak.data()) {
const auto paused = On(PowerSaving::kStickersPanel) const auto paused = On(PowerSaving::kStickersPanel)
|| show->paused(ChatHelpers::PauseReason::Layer); || show->paused(ChatHelpers::PauseReason::Layer);
paintSticker(p, index, QPoint(), paused, crl::now()); paintSticker(p, index, QPoint(), paused, crl::now());
@ -1564,7 +1564,7 @@ void StickerSetBox::Inner::fillDeleteStickerBox(
Data::StickersType::Stickers); Data::StickersType::Stickers);
}, [](const auto &) { }, [](const auto &) {
}); });
if (const auto strong = weak.data()) { if ([[maybe_unused]] const auto strong = weak.data()) {
applySet(result); applySet(result);
} }
if (const auto strongBox = weakBox.data()) { if (const auto strongBox = weakBox.data()) {

View file

@ -144,7 +144,7 @@ void UrlAuthBox::Request(
const auto callback = [=](Result result) { const auto callback = [=](Result result) {
if (result == Result::None) { if (result == Result::None) {
finishWithUrl(url); finishWithUrl(url);
} else if (const auto msg = session->data().message(itemId)) { } else if (session->data().message(itemId)) {
const auto allowWrite = (result == Result::AuthAndAllowWrite); const auto allowWrite = (result == Result::AuthAndAllowWrite);
using Flag = MTPmessages_AcceptUrlAuth::Flag; using Flag = MTPmessages_AcceptUrlAuth::Flag;
const auto flags = (allowWrite ? Flag::f_write_allowed : Flag(0)) const auto flags = (allowWrite ? Flag::f_write_allowed : Flag(0))

View file

@ -611,7 +611,7 @@ void BoxController::receivedCalls(const QVector<MTPMessage> &result) {
for (const auto &message : result) { for (const auto &message : result) {
const auto msgId = IdFromMessage(message); const auto msgId = IdFromMessage(message);
const auto peerId = PeerFromMessage(message); const auto peerId = PeerFromMessage(message);
if (const auto peer = session().data().peerLoaded(peerId)) { if (session().data().peerLoaded(peerId)) {
const auto item = session().data().addNewMessage( const auto item = session().data().addNewMessage(
message, message,
MessageFlags(), MessageFlags(),

View file

@ -2104,7 +2104,7 @@ void EmojiListWidget::colorChosen(EmojiChosen data) {
const auto emoji = data.emoji; const auto emoji = data.emoji;
auto &settings = Core::App().settings(); auto &settings = Core::App().settings();
if (const auto button = std::get_if<OverButton>(&_pickerSelected)) { if (v::is<OverButton>(_pickerSelected)) {
settings.saveAllEmojiVariants(emoji); settings.saveAllEmojiVariants(emoji);
for (auto section = int(Section::People) for (auto section = int(Section::People)
; section < _staticCount ; section < _staticCount
@ -2425,7 +2425,7 @@ Ui::Text::CustomEmoji *EmojiListWidget::resolveCustomRecent(
const auto &data = customId.data; const auto &data = customId.data;
if (const auto document = std::get_if<RecentEmojiDocument>(&data)) { if (const auto document = std::get_if<RecentEmojiDocument>(&data)) {
return resolveCustomRecent(document->id); return resolveCustomRecent(document->id);
} else if (const auto emoji = std::get_if<EmojiPtr>(&data)) { } else if (v::is<EmojiPtr>(data)) {
return nullptr; return nullptr;
} }
Unexpected("Custom recent emoji id."); Unexpected("Custom recent emoji id.");

View file

@ -765,7 +765,7 @@ InlineBotQuery ParseInlineBotQuery(
result.username = username.toString(); result.username = username.toString();
if (const auto peer = session->data().peerByUsername(result.username)) { if (const auto peer = session->data().peerByUsername(result.username)) {
if (const auto user = peer->asUser()) { if (const auto user = peer->asUser()) {
result.bot = peer->asUser(); result.bot = user;
} else { } else {
result.bot = nullptr; result.bot = nullptr;
} }

View file

@ -25,7 +25,7 @@ Ui::LocationPicker *LocationPickers::lookup(const Api::SendAction &action) {
for (auto i = begin(_pickers); i != end(_pickers);) { for (auto i = begin(_pickers); i != end(_pickers);) {
if (const auto strong = i->picker.get()) { if (const auto strong = i->picker.get()) {
if (i->action == action) { if (i->action == action) {
return i->picker.get(); return strong;
} }
++i; ++i;
} else { } else {
@ -41,4 +41,4 @@ void LocationPickers::emplace(
_pickers.push_back({ action, picker }); _pickers.push_back({ action, picker });
} }
} // namespace Data } // namespace Data

View file

@ -956,7 +956,7 @@ QString ChannelData::invitePeekHash() const {
} }
void ChannelData::privateErrorReceived() { void ChannelData::privateErrorReceived() {
if (const auto expires = invitePeekExpires()) { if (invitePeekExpires()) {
const auto hash = invitePeekHash(); const auto hash = invitePeekHash();
for (const auto &window : session().windows()) { for (const auto &window : session().windows()) {
clearInvitePeek(); clearInvitePeek();

View file

@ -347,7 +347,7 @@ bool ChatFilter::contains(
: user->isContact() : user->isContact()
? Flag::Contacts ? Flag::Contacts
: Flag::NonContacts; : Flag::NonContacts;
} else if (const auto chat = peer->asChat()) { } else if (peer->isChat()) {
return Flag::Groups; return Flag::Groups;
} else if (const auto channel = peer->asChannel()) { } else if (const auto channel = peer->asChannel()) {
if (channel->isBroadcast()) { if (channel->isBroadcast()) {

View file

@ -238,7 +238,7 @@ void CloudThemes::showPreview(
void CloudThemes::showPreview( void CloudThemes::showPreview(
not_null<Window::Controller*> controller, not_null<Window::Controller*> controller,
const CloudTheme &cloud) { const CloudTheme &cloud) {
if (const auto documentId = cloud.documentId) { if (cloud.documentId) {
previewFromDocument(controller, cloud); previewFromDocument(controller, cloud);
} else if (cloud.createdBy == _session->userId()) { } else if (cloud.createdBy == _session->userId()) {
controller->show(Box( controller->show(Box(

View file

@ -1111,7 +1111,7 @@ ItemPreview MediaFile::toPreview(ToPreviewOptions options) const {
return toGroupPreview(group->items, options); return toGroupPreview(group->items, options);
} }
} }
if (const auto sticker = _document->sticker()) { if (_document->sticker()) {
return Media::toPreview(options); return Media::toPreview(options);
} }
auto images = std::vector<ItemPreviewImage>(); auto images = std::vector<ItemPreviewImage>();
@ -1178,7 +1178,7 @@ ItemPreview MediaFile::toPreview(ToPreviewOptions options) const {
} }
TextWithEntities MediaFile::notificationText() const { TextWithEntities MediaFile::notificationText() const {
if (const auto sticker = _document->sticker()) { if (_document->sticker()) {
const auto text = _emoji.isEmpty() const auto text = _emoji.isEmpty()
? tr::lng_in_dlg_sticker(tr::now) ? tr::lng_in_dlg_sticker(tr::now)
: tr::lng_in_dlg_sticker_emoji(tr::now, lt_emoji, _emoji); : tr::lng_in_dlg_sticker_emoji(tr::now, lt_emoji, _emoji);
@ -1210,7 +1210,7 @@ TextWithEntities MediaFile::notificationText() const {
} }
QString MediaFile::pinnedTextSubstring() const { QString MediaFile::pinnedTextSubstring() const {
if (const auto sticker = _document->sticker()) { if (_document->sticker()) {
if (!_emoji.isEmpty()) { if (!_emoji.isEmpty()) {
return tr::lng_action_pinned_media_emoji_sticker( return tr::lng_action_pinned_media_emoji_sticker(
tr::now, tr::now,

View file

@ -703,7 +703,7 @@ bool PeerData::canTransferGifts() const {
bool PeerData::canEditMessagesIndefinitely() const { bool PeerData::canEditMessagesIndefinitely() const {
if (const auto user = asUser()) { if (const auto user = asUser()) {
return user->isSelf(); return user->isSelf();
} else if (const auto chat = asChat()) { } else if (isChat()) {
return false; return false;
} else if (const auto channel = asChannel()) { } else if (const auto channel = asChannel()) {
return channel->isMegagroup() return channel->isMegagroup()
@ -1410,7 +1410,7 @@ Data::ForumTopic *PeerData::forumTopicFor(MsgId rootId) const {
} }
bool PeerData::allowsForwarding() const { bool PeerData::allowsForwarding() const {
if (const auto user = asUser()) { if (isUser()) {
return true; return true;
} else if (const auto channel = asChannel()) { } else if (const auto channel = asChannel()) {
return channel->allowsForwarding(); return channel->allowsForwarding();

View file

@ -599,7 +599,7 @@ rpl::producer<int> UniqueReactionsLimitValue(
) | rpl::map([config = &peer->session().appConfig()] { ) | rpl::map([config = &peer->session().appConfig()] {
return UniqueReactionsLimit(config); return UniqueReactionsLimit(config);
}) | rpl::distinct_until_changed(); }) | rpl::distinct_until_changed();
if (const auto channel = peer->asChannel()) { if (peer->isChannel()) {
return rpl::combine( return rpl::combine(
PeerAllowedReactionsValue(peer), PeerAllowedReactionsValue(peer),
std::move(configValue) std::move(configValue)
@ -608,7 +608,7 @@ rpl::producer<int> UniqueReactionsLimitValue(
? allowedReactions.maxCount ? allowedReactions.maxCount
: limit; : limit;
}); });
} else if (const auto chat = peer->asChat()) { } else if (peer->isChat()) {
return rpl::combine( return rpl::combine(
PeerAllowedReactionsValue(peer), PeerAllowedReactionsValue(peer),
std::move(configValue) std::move(configValue)

View file

@ -65,13 +65,13 @@ QByteArray PhotoMedia::imageBytes(PhotoSize size) const {
auto PhotoMedia::resolveLoadedImage(PhotoSize size) const auto PhotoMedia::resolveLoadedImage(PhotoSize size) const
-> const PhotoImage * { -> const PhotoImage * {
const auto &original = _images[PhotoSizeIndex(size)]; const auto &original = _images[PhotoSizeIndex(size)];
if (const auto image = original.data.get()) { if (original.data) {
if (original.goodFor >= size) { if (original.goodFor >= size) {
return &original; return &original;
} }
} }
const auto &valid = _images[_owner->validSizeIndex(size)]; const auto &valid = _images[_owner->validSizeIndex(size)];
if (const auto image = valid.data.get()) { if (valid.data.get()) {
if (valid.goodFor >= size) { if (valid.goodFor >= size) {
return &valid; return &valid;
} }

View file

@ -366,7 +366,7 @@ bool RepliesList::buildFromData(not_null<Viewer*> viewer) {
const auto around = [&] { const auto around = [&] {
if (viewer->around != ShowAtUnreadMsgId) { if (viewer->around != ShowAtUnreadMsgId) {
return viewer->around; return viewer->around;
} else if (const auto item = lookupRoot()) { } else if (lookupRoot()) {
return computeInboxReadTillFull(); return computeInboxReadTillFull();
} else if (_owningTopic) { } else if (_owningTopic) {
// Somehow we don't want always to jump to computed inboxReadTill // Somehow we don't want always to jump to computed inboxReadTill

View file

@ -2231,7 +2231,7 @@ void Session::applyDialog(
} }
bool Session::pinnedCanPin(not_null<Dialogs::Entry*> entry) const { bool Session::pinnedCanPin(not_null<Dialogs::Entry*> entry) const {
if (const auto sublist = entry->asSublist()) { if ([[maybe_unused]] const auto sublist = entry->asSublist()) {
const auto saved = &savedMessages(); const auto saved = &savedMessages();
return pinnedChatsOrder(saved).size() < pinnedChatsLimit(saved); return pinnedChatsOrder(saved).size() < pinnedChatsLimit(saved);
} else if (const auto topic = entry->asTopic()) { } else if (const auto topic = entry->asTopic()) {

View file

@ -4756,7 +4756,7 @@ bool InnerWidget::chooseRow(
} }
if (!chosen.message.fullId) { if (!chosen.message.fullId) {
if (const auto history = chosen.key.history()) { if (const auto history = chosen.key.history()) {
if (const auto forum = history->peer->forum()) { if (history->peer->forum()) {
if (pressedTopicRootId) { if (pressedTopicRootId) {
chosen.message.fullId = { chosen.message.fullId = {
history->peer->id, history->peer->id,

View file

@ -806,7 +806,7 @@ void Widget::setupSwipeBack() {
} }
return Ui::Controls::DefaultSwipeBackHandlerFinishData([=] { return Ui::Controls::DefaultSwipeBackHandlerFinishData([=] {
_swipeBackData = {}; _swipeBackData = {};
if (const auto forum = controller()->shownForum().current()) { if (controller()->shownForum().current()) {
controller()->closeForum(); controller()->closeForum();
} }
}); });

View file

@ -952,7 +952,7 @@ void MyChannelsController::prepare() {
const auto add = [&](not_null<Dialogs::MainList*> list) { const auto add = [&](not_null<Dialogs::MainList*> list) {
for (const auto &row : list->indexed()->all()) { for (const auto &row : list->indexed()->all()) {
if (const auto history = row->history()) { if (const auto history = row->history()) {
if (const auto channel = history->peer->asBroadcast()) { if (history->peer->isBroadcast()) {
_channels.push_back(history); _channels.push_back(history);
} }
} }
@ -981,7 +981,7 @@ void MyChannelsController::prepare() {
const auto list = owner->chatsList(folder); const auto list = owner->chatsList(folder);
for (const auto &row : list->indexed()->all()) { for (const auto &row : list->indexed()->all()) {
if (const auto history = row->history()) { if (const auto history = row->history()) {
if (const auto channel = history->peer->asBroadcast()) { if (history->peer->isBroadcast()) {
if (ranges::contains(_channels, not_null(history))) { if (ranges::contains(_channels, not_null(history))) {
_channels.push_back(history); _channels.push_back(history);
} }

View file

@ -1724,9 +1724,9 @@ File &Message::file() {
} else if (const auto photo = std::get_if<ActionSuggestProfilePhoto>( } else if (const auto photo = std::get_if<ActionSuggestProfilePhoto>(
content)) { content)) {
return photo->photo.image.file; return photo->photo.image.file;
} else if (const auto wallpaper = std::get_if<ActionSetChatWallPaper>( // } else if (const auto wallpaper = std::get_if<ActionSetChatWallPaper>(
content)) { // content)) {
// #TODO wallpapers // #TODO wallpapers
} }
return media.file(); return media.file();
} }
@ -1738,9 +1738,9 @@ const File &Message::file() const {
} else if (const auto photo = std::get_if<ActionSuggestProfilePhoto>( } else if (const auto photo = std::get_if<ActionSuggestProfilePhoto>(
content)) { content)) {
return photo->photo.image.file; return photo->photo.image.file;
} else if (const auto wallpaper = std::get_if<ActionSetChatWallPaper>( // } else if (const auto wallpaper = std::get_if<ActionSetChatWallPaper>(
content)) { // content)) {
// #TODO wallpapers // #TODO wallpapers
} }
return media.file(); return media.file();
} }

View file

@ -190,7 +190,7 @@ void History::itemVanished(not_null<HistoryItem*> item) {
setUnreadCount(unreadCount() - 1); setUnreadCount(unreadCount() - 1);
} }
if (const auto media = item->media()) { if (const auto media = item->media()) {
if (const auto gift = media->gift()) { if (media->gift()) {
using GiftAction = Data::GiftUpdate::Action; using GiftAction = Data::GiftUpdate::Action;
owner().notifyGiftUpdate({ owner().notifyGiftUpdate({
.id = Data::SavedStarGiftId::User(item->id), .id = Data::SavedStarGiftId::User(item->id),
@ -1160,7 +1160,7 @@ void History::applyServiceChanges(
auto paid = std::optional<Payments::PaidInvoice>(); auto paid = std::optional<Payments::PaidInvoice>();
if (const auto message = payment->msg) { if (const auto message = payment->msg) {
if (const auto media = message->media()) { if (const auto media = message->media()) {
if (const auto invoice = media->invoice()) { if (media->invoice()) {
paid = Payments::CheckoutProcess::InvoicePaid( paid = Payments::CheckoutProcess::InvoicePaid(
message); message);
} }
@ -2555,7 +2555,7 @@ auto History::computeChatListMessageFromLast() const
if (!last || !last->isGroupMigrate()) { if (!last || !last->isGroupMigrate()) {
return _lastMessage; return _lastMessage;
} }
if (const auto chat = peer->asChat()) { if (peer->isChat()) {
// In chats we try to take the item before the 'last', which // In chats we try to take the item before the 'last', which
// is the empty-displayed migration message. // is the empty-displayed migration message.
if (!loadedAtBottom()) { if (!loadedAtBottom()) {
@ -2633,7 +2633,7 @@ void History::setFakeChatListMessage() {
} }
} }
return; return;
} else if (const auto chat = peer->asChat()) { } else if (peer->isChat()) {
// In chats we try to take the item before the 'last', which // In chats we try to take the item before the 'last', which
// is the empty-displayed migration message. // is the empty-displayed migration message.
owner().histories().requestFakeChatListMessage(this); owner().histories().requestFakeChatListMessage(this);
@ -2876,10 +2876,8 @@ void History::dialogEntryApplied() {
addOlderSlice(QVector<MTPMessage>()); addOlderSlice(QVector<MTPMessage>());
if (const auto channel = peer->asChannel()) { if (const auto channel = peer->asChannel()) {
const auto inviter = channel->inviter; const auto inviter = channel->inviter;
if (inviter && channel->amIn()) { if (inviter && channel->amIn() && owner().userLoaded(inviter)) {
if (const auto from = owner().userLoaded(inviter)) { insertJoinedMessage();
insertJoinedMessage();
}
} }
} }
return; return;
@ -2890,10 +2888,9 @@ void History::dialogEntryApplied() {
const auto inviter = channel->inviter; const auto inviter = channel->inviter;
if (inviter if (inviter
&& chatListTimeId() <= channel->inviteDate && chatListTimeId() <= channel->inviteDate
&& channel->amIn()) { && channel->amIn()
if (const auto from = owner().userLoaded(inviter)) { && owner().userLoaded(inviter)) {
insertJoinedMessage(); insertJoinedMessage();
}
} }
} }
} }

View file

@ -2495,9 +2495,12 @@ void HistoryInner::showContextMenu(QContextMenuEvent *e, bool showFromTouch) {
const auto itemId = item->fullId(); const auto itemId = item->fullId();
_menu->addAction(tr::lng_context_select_msg(tr::now), [=] { _menu->addAction(tr::lng_context_select_msg(tr::now), [=] {
if (const auto item = session->data().message(itemId)) { if (const auto item = session->data().message(itemId)) {
if (const auto view = viewByItem(item)) { if ([[maybe_unused]] const auto view = viewByItem(item)) {
if (asGroup) { if (asGroup) {
changeSelectionAsGroup(&_selected, item, SelectAction::Select); changeSelectionAsGroup(
&_selected,
item,
SelectAction::Select);
} else { } else {
changeSelection(&_selected, item, SelectAction::Select); changeSelection(&_selected, item, SelectAction::Select);
} }
@ -4628,7 +4631,7 @@ void HistoryInner::reportAsGroup(FullMsgId itemId) {
} }
void HistoryInner::blockSenderItem(FullMsgId itemId) { void HistoryInner::blockSenderItem(FullMsgId itemId) {
if (const auto item = session().data().message(itemId)) { if ([[maybe_unused]] const auto item = session().data().message(itemId)) {
_controller->show(Box( _controller->show(Box(
Window::BlockSenderFromRepliesBox, Window::BlockSenderFromRepliesBox,
_controller, _controller,

View file

@ -2263,7 +2263,7 @@ void HistoryItem::setRealId(MsgId newId) {
_history->owner().groups().refreshMessage(this); _history->owner().groups().refreshMessage(this);
_history->owner().requestItemResize(this); _history->owner().requestItemResize(this);
if (const auto reply = Get<HistoryMessageReply>()) { if (Has<HistoryMessageReply>()) {
incrementReplyToTopCounter(); incrementReplyToTopCounter();
} }
@ -2440,7 +2440,7 @@ bool HistoryItem::canDeleteForEveryone(TimeId now) const {
bool HistoryItem::suggestReport() const { bool HistoryItem::suggestReport() const {
if (out() || isService() || !isRegular()) { if (out() || isService() || !isRegular()) {
return false; return false;
} else if (const auto channel = _history->peer->asChannel()) { } else if (_history->peer->isChannel()) {
return true; return true;
} else if (const auto user = _history->peer->asUser()) { } else if (const auto user = _history->peer->asUser()) {
return user->isBot(); return user->isBot();
@ -3731,7 +3731,7 @@ void HistoryItem::createComponents(CreateConfig &&config) {
if (const auto via = Get<HistoryMessageVia>()) { if (const auto via = Get<HistoryMessageVia>()) {
via->create(&_history->owner(), config.viaBotId); via->create(&_history->owner(), config.viaBotId);
} }
if (const auto views = Get<HistoryMessageViews>()) { if (Has<HistoryMessageViews>()) {
changeViewsCount(config.viewsCount); changeViewsCount(config.viewsCount);
if (config.replies.isNull if (config.replies.isNull
&& isSending() && isSending()

View file

@ -1208,7 +1208,7 @@ void ClearMediaAsExpired(not_null<HistoryItem*> item) {
? tr::lng_ttl_round_expired ? tr::lng_ttl_round_expired
: tr::lng_message_empty)(tr::now, Ui::Text::WithEntities); : tr::lng_message_empty)(tr::now, Ui::Text::WithEntities);
item->updateServiceText(PreparedServiceText{ std::move(text) }); item->updateServiceText(PreparedServiceText{ std::move(text) });
} else if (const auto photo = media->photo()) { } else if (media->photo()) {
item->applyEditionToHistoryCleared(); item->applyEditionToHistoryCleared();
item->updateServiceText(PreparedServiceText{ item->updateServiceText(PreparedServiceText{
tr::lng_ttl_photo_expired(tr::now, Ui::Text::WithEntities) tr::lng_ttl_photo_expired(tr::now, Ui::Text::WithEntities)

View file

@ -7416,7 +7416,7 @@ bool HistoryWidget::showSlowmodeError() {
Ui::FormatDurationWordsSlowmode(left)); Ui::FormatDurationWordsSlowmode(left));
} else if (_peer->slowmodeApplied()) { } else if (_peer->slowmodeApplied()) {
if (const auto item = _history->latestSendingMessage()) { if (const auto item = _history->latestSendingMessage()) {
if (const auto view = item->mainView()) { if (item->mainView()) {
animatedScrollToItem(item->id); animatedScrollToItem(item->id);
enqueueMessageHighlight({ item }); enqueueMessageHighlight({ item });
} }

View file

@ -102,7 +102,7 @@ void ForwardPanel::checkTexts() {
for (const auto item : _data.items) { for (const auto item : _data.items) {
if (const auto from = item->originalSender()) { if (const auto from = item->originalSender()) {
version += from->nameVersion(); version += from->nameVersion();
} else if (const auto info = item->originalHiddenSenderInfo()) { } else if (item->originalHiddenSenderInfo()) {
++version; ++version;
} else { } else {
Unexpected("Corrupt forwarded information in message."); Unexpected("Corrupt forwarded information in message.");

View file

@ -198,7 +198,7 @@ ClickHandlerPtr BottomInfo::replayEffectLink(
const auto weak = base::make_weak(view); const auto weak = base::make_weak(view);
return std::make_shared<LambdaClickHandler>([=](ClickContext context) { return std::make_shared<LambdaClickHandler>([=](ClickContext context) {
const auto my = context.other.value<ClickHandlerContext>(); const auto my = context.other.value<ClickHandlerContext>();
if (const auto controller = my.sessionWindow.get()) { if ([[maybe_unused]] const auto controller = my.sessionWindow.get()) {
if (const auto strong = weak.get()) { if (const auto strong = weak.get()) {
strong->delegate()->elementStartEffect(strong, nullptr); strong->delegate()->elementStartEffect(strong, nullptr);
} }

View file

@ -1440,11 +1440,11 @@ void AddSaveSoundForNotifications(
return; return;
} else if (int(ringtones.list().size()) >= ringtones.maxSavedCount()) { } else if (int(ringtones.list().size()) >= ringtones.maxSavedCount()) {
return; return;
} else if (const auto song = document->song()) { } else if (document->song()) {
if (document->duration() > ringtones.maxDuration()) { if (document->duration() > ringtones.maxDuration()) {
return; return;
} }
} else if (const auto voice = document->voice()) { } else if (document->voice()) {
if (document->duration() > ringtones.maxDuration()) { if (document->duration() > ringtones.maxDuration()) {
return; return;
} }

View file

@ -1489,7 +1489,7 @@ void ListWidget::cancelSelection() {
void ListWidget::selectItem(not_null<HistoryItem*> item) { void ListWidget::selectItem(not_null<HistoryItem*> item) {
if (hasSelectRestriction()) { if (hasSelectRestriction()) {
return; return;
} else if (const auto view = viewForItem(item)) { } else if ([[maybe_unused]] const auto view = viewForItem(item)) {
clearTextSelection(); clearTextSelection();
changeSelection( changeSelection(
_selected, _selected,
@ -1502,7 +1502,7 @@ void ListWidget::selectItem(not_null<HistoryItem*> item) {
void ListWidget::selectItemAsGroup(not_null<HistoryItem*> item) { void ListWidget::selectItemAsGroup(not_null<HistoryItem*> item) {
if (hasSelectRestriction()) { if (hasSelectRestriction()) {
return; return;
} else if (const auto view = viewForItem(item)) { } else if ([[maybe_unused]] const auto view = viewForItem(item)) {
clearTextSelection(); clearTextSelection();
changeSelectionAsGroup( changeSelectionAsGroup(
_selected, _selected,

View file

@ -2477,7 +2477,7 @@ bool Message::hasFromPhoto() const {
return true; return true;
} else if (item->history()->peer->isVerifyCodes()) { } else if (item->history()->peer->isVerifyCodes()) {
return !hasOutLayout(); return !hasOutLayout();
} else if (const auto forwarded = item->Get<HistoryMessageForwarded>()) { } else if (item->Has<HistoryMessageForwarded>()) {
const auto peer = item->history()->peer; const auto peer = item->history()->peer;
if (peer->isSelf() || peer->isRepliesChat()) { if (peer->isSelf() || peer->isRepliesChat()) {
return !hasOutLayout(); return !hasOutLayout();
@ -3136,7 +3136,7 @@ void Message::updatePressed(QPoint point) {
if (const auto reply = Get<Reply>()) { if (const auto reply = Get<Reply>()) {
trect.setTop(trect.top() + reply->height()); trect.setTop(trect.top() + reply->height());
} }
if (const auto via = item->Get<HistoryMessageVia>()) { if (item->Has<HistoryMessageVia>()) {
if (!displayFromName() && !displayForwardedFrom()) { if (!displayFromName() && !displayForwardedFrom()) {
trect.setTop(trect.top() + st::msgNameFont->height); trect.setTop(trect.top() + st::msgNameFont->height);
} }
@ -4447,7 +4447,7 @@ Ui::BubbleRounding Message::countMessageRounding() const {
Ui::BubbleRounding Message::countBubbleRounding( Ui::BubbleRounding Message::countBubbleRounding(
Ui::BubbleRounding messageRounding) const { Ui::BubbleRounding messageRounding) const {
if (const auto keyboard = data()->inlineReplyKeyboard()) { if ([[maybe_unused]] const auto _ = data()->inlineReplyKeyboard()) {
messageRounding.bottomLeft messageRounding.bottomLeft
= messageRounding.bottomRight = messageRounding.bottomRight
= Ui::BubbleCornerRounding::Small; = Ui::BubbleCornerRounding::Small;

View file

@ -738,7 +738,7 @@ void TopBarWidget::infoClicked() {
return; return;
} else if (const auto topic = key.topic()) { } else if (const auto topic = key.topic()) {
_controller->showSection(std::make_shared<Info::Memento>(topic)); _controller->showSection(std::make_shared<Info::Memento>(topic));
} else if (const auto sublist = key.sublist()) { } else if ([[maybe_unused]] const auto sublist = key.sublist()) {
_controller->showSection(std::make_shared<Info::Memento>( _controller->showSection(std::make_shared<Info::Memento>(
_controller->session().user(), _controller->session().user(),
Info::Section(Storage::SharedMediaType::Photo))); Info::Section(Storage::SharedMediaType::Photo)));

View file

@ -271,10 +271,10 @@ void PaintWaveform(
}; };
add(FormatDownloadText(document->size, document->size)); add(FormatDownloadText(document->size, document->size));
const auto duration = document->duration() / 1000; const auto duration = document->duration() / 1000;
if (const auto song = document->song()) { if (document->song()) {
add(FormatPlayedText(duration, duration)); add(FormatPlayedText(duration, duration));
add(FormatDurationAndSizeText(duration, document->size)); add(FormatDurationAndSizeText(duration, document->size));
} else if (const auto voice = document->voice() ? document->voice() : document->round()) { } else if (document->voice() ? document->voice() : document->round()) {
add(FormatPlayedText(duration, duration)); add(FormatPlayedText(duration, duration));
add(FormatDurationAndSizeText(duration, document->size)); add(FormatDurationAndSizeText(duration, document->size));
} else if (document->isVideoFile()) { } else if (document->isVideoFile()) {

View file

@ -448,7 +448,7 @@ void StickerInBubblePart::ensureCreated(Element *replacing) const {
return; return;
} else if (const auto data = _lookup()) { } else if (const auto data = _lookup()) {
const auto sticker = data.sticker; const auto sticker = data.sticker;
if (const auto info = sticker->sticker()) { if (sticker->sticker()) {
const auto skipPremiumEffect = true; const auto skipPremiumEffect = true;
_link = data.link; _link = data.link;
_skipTop = data.skipTop; _skipTop = data.skipTop;

View file

@ -411,7 +411,7 @@ void PremiumGift::ensureStickerCreated() const {
const auto count = credits(); const auto count = credits();
const auto months = count ? packs.monthsForStars(count) : _data.count; const auto months = count ? packs.monthsForStars(count) : _data.count;
if (const auto document = packs.lookup(months)) { if (const auto document = packs.lookup(months)) {
if (const auto sticker = document->sticker()) { if (document->sticker()) {
const auto skipPremiumEffect = false; const auto skipPremiumEffect = false;
_sticker.emplace(_parent, document, skipPremiumEffect, _parent); _sticker.emplace(_parent, document, skipPremiumEffect, _parent);
_sticker->setPlayingOnce(true); _sticker->setPlayingOnce(true);

View file

@ -751,7 +751,7 @@ void InnerWidget::setupEnd() {
*sent = false; *sent = false;
if (!success) { if (!success) {
return; return;
} else if (const auto strong = weak.data()) { } else if ([[maybe_unused]] const auto strong = weak.data()) {
_controller->showBackFromStack(); _controller->showBackFromStack();
window->showToast({ window->showToast({
.title = tr::lng_star_ref_ended_title(tr::now), .title = tr::lng_star_ref_ended_title(tr::now),

View file

@ -861,7 +861,7 @@ rpl::producer<uint64> AddCurrencyAction(
) | rpl::start_with_error_done([=](const QString &error) { ) | rpl::start_with_error_done([=](const QString &error) {
currencyLoadLifetime->destroy(); currencyLoadLifetime->destroy();
}, [=] { }, [=] {
if (const auto strong = weak.data()) { if ([[maybe_unused]] const auto strong = weak.data()) {
state->balance = currencyLoad->data().currentBalance; state->balance = currencyLoad->data().currentBalance;
currencyLoadLifetime->destroy(); currencyLoadLifetime->destroy();
} }

View file

@ -100,7 +100,7 @@ void Widget::setInnerFocus() {
} }
rpl::producer<QString> Widget::title() { rpl::producer<QString> Widget::title() {
if (const auto topic = controller()->key().topic()) { if (controller()->key().topic()) {
return tr::lng_info_topic_title(); return tr::lng_info_topic_title();
} }
const auto peer = controller()->key().peer(); const auto peer = controller()->key().peer();

View file

@ -1582,11 +1582,11 @@ TextState Game::getState(
} }
void Game::prepareThumbnail(QSize size) const { void Game::prepareThumbnail(QSize size) const {
if (const auto document = getResultDocument()) { if ([[maybe_unused]] const auto document = getResultDocument()) {
Assert(_documentMedia != nullptr); Assert(_documentMedia != nullptr);
validateThumbnail(_documentMedia->thumbnail(), size, true); validateThumbnail(_documentMedia->thumbnail(), size, true);
validateThumbnail(_documentMedia->thumbnailInline(), size, false); validateThumbnail(_documentMedia->thumbnailInline(), size, false);
} else if (const auto photo = getResultPhoto()) { } else if ([[maybe_unused]] const auto photo = getResultPhoto()) {
using Data::PhotoSize; using Data::PhotoSize;
Assert(_photoMedia != nullptr); Assert(_photoMedia != nullptr);
validateThumbnail(_photoMedia->image(PhotoSize::Thumbnail), size, true); validateThumbnail(_photoMedia->image(PhotoSize::Thumbnail), size, true);

View file

@ -1166,7 +1166,7 @@ float64 MainWidget::chatBackgroundProgress() const {
if (_background) { if (_background) {
if (_background->generating) { if (_background->generating) {
return 1.; return 1.;
} else if (const auto document = _background->data.document()) { } else if (_background->data.document()) {
return _background->dataMedia->progress(); return _background->dataMedia->progress();
} }
} }
@ -2602,7 +2602,7 @@ auto MainWidget::thirdSectionForCurrentMainSection(
return std::make_shared<Info::Memento>( return std::make_shared<Info::Memento>(
peer, peer,
Info::Memento::DefaultSection(peer)); Info::Memento::DefaultSection(peer));
} else if (const auto sublist = key.sublist()) { } else if (key.sublist()) {
return std::make_shared<Info::Memento>( return std::make_shared<Info::Memento>(
session().user(), session().user(),
Info::Memento::DefaultSection(session().user())); Info::Memento::DefaultSection(session().user()));

View file

@ -642,7 +642,7 @@ void Widget::updateTimeText(const TrackState &state) {
display = state.position; display = state.position;
} else if (state.length) { } else if (state.length) {
display = state.length; display = state.length;
} else if (const auto song = document->song()) { } else if (document->song()) {
display = (document->duration() * frequency) / 1000; display = (document->duration() * frequency) / 1000;
} }

View file

@ -905,8 +905,7 @@ bool ReplyArea::showSlowmodeError() {
lt_left, lt_left,
Ui::FormatDurationWordsSlowmode(left)); Ui::FormatDurationWordsSlowmode(left));
} else if (peer->slowmodeApplied()) { } else if (peer->slowmodeApplied()) {
const auto history = peer->owner().history(peer); if (peer->owner().history(peer)->latestSendingMessage()) {
if (const auto item = history->latestSendingMessage()) {
return tr::lng_slowmode_no_many(tr::now); return tr::lng_slowmode_no_many(tr::now);
} }
} }

View file

@ -1017,7 +1017,7 @@ const style::RoundCheckbox &Voice::checkboxStyle() const {
} }
void Voice::updateName() { void Voice::updateName() {
if (const auto forwarded = parent()->Get<HistoryMessageForwarded>()) { if (parent()->Has<HistoryMessageForwarded>()) {
const auto info = parent()->originalHiddenSenderInfo(); const auto info = parent()->originalHiddenSenderInfo();
const auto name = info const auto name = info
? tr::lng_forwarded(tr::now, lt_user, info->nameText().toString()) ? tr::lng_forwarded(tr::now, lt_user, info->nameText().toString())

View file

@ -1895,7 +1895,7 @@ void GenericCreditsEntryBox(
ProcessReceivedSubscriptions(weak, session); ProcessReceivedSubscriptions(weak, session);
}; };
const auto fail = [=, show = box->uiShow()](const QString &e) { const auto fail = [=, show = box->uiShow()](const QString &e) {
if (const auto strong = weak.data()) { if ([[maybe_unused]] const auto strong = weak.data()) {
state->confirmButtonBusy = false; state->confirmButtonBusy = false;
} }
show->showToast(e); show->showToast(e);

View file

@ -911,7 +911,7 @@ void SetupTagContent(
const auto send = [=, weak = Ui::MakeWeak(tagsButton)](bool checked) { const auto send = [=, weak = Ui::MakeWeak(tagsButton)](bool checked) {
session->data().chatsFilters().requestToggleTags(checked, [=] { session->data().chatsFilters().requestToggleTags(checked, [=] {
if (const auto strong = weak.data()) { if ([[maybe_unused]] const auto strong = weak.data()) {
state->tagsTurnOff.fire(!checked); state->tagsTurnOff.fire(!checked);
} }
}); });

View file

@ -418,7 +418,7 @@ void WebLoadManager::failed(
} }
void WebLoadManager::failed(int id, not_null<QNetworkReply*> reply) { void WebLoadManager::failed(int id, not_null<QNetworkReply*> reply) {
if (const auto sent = findSent(id, reply)) { if ([[maybe_unused]] const auto sent = findSent(id, reply)) {
removeSent(id); removeSent(id);
queueFailedUpdate(id); queueFailedUpdate(id);
} }

View file

@ -319,7 +319,7 @@ void PrepareDetails(PreparedFile &file, int previewWidth, int sideLimit) {
file.preview.setDevicePixelRatio(style::DevicePixelRatio()); file.preview.setDevicePixelRatio(style::DevicePixelRatio());
file.type = PreparedFile::Type::Video; file.type = PreparedFile::Type::Video;
} }
} else if (const auto song = std::get_if<Song>(&file.information->media)) { } else if (v::is<Song>(file.information->media)) {
file.type = PreparedFile::Type::Music; file.type = PreparedFile::Type::Music;
} }
} }

View file

@ -241,7 +241,7 @@ void GroupCallUserpics::sendRandomLevels() {
for (auto &userpic : _list) { for (auto &userpic : _list) {
if (const auto blobs = userpic.blobsAnimation.get()) { if (const auto blobs = userpic.blobsAnimation.get()) {
const auto value = 30 + base::RandomIndex(70); const auto value = 30 + base::RandomIndex(70);
userpic.blobsAnimation->blobs.setLevel(float64(value) / 100.); blobs->blobs.setLevel(float64(value) / 100.);
} }
} }
} }

View file

@ -385,10 +385,10 @@ int ReactionFlyAnimation::computeParabolicTop(
void ReactionFlyAnimation::startAnimations() { void ReactionFlyAnimation::startAnimations() {
if (const auto center = _center.get()) { if (const auto center = _center.get()) {
_center->animate(callback()); center->animate(callback());
} }
if (const auto effect = _effect.get()) { if (const auto effect = _effect.get()) {
_effect->animate(callback()); effect->animate(callback());
} else if (_scaleOutDuration > 0) { } else if (_scaleOutDuration > 0) {
_noEffectScaleStarted = true; _noEffectScaleStarted = true;
_noEffectScaleAnimation.start(callback(), 1, 0, _scaleOutDuration); _noEffectScaleAnimation.start(callback(), 1, 0, _scaleOutDuration);

View file

@ -378,7 +378,7 @@ void ChatsFiltersTabs::setHorizontalShift(int index, int shift) {
Expects(index >= 0 && index < _sections.size()); Expects(index >= 0 && index < _sections.size());
auto &section = _sections[index]; auto &section = _sections[index];
if (const auto delta = shift - section.horizontalShift) { if (shift - section.horizontalShift) {
section.horizontalShift = shift; section.horizontalShift = shift;
update(); update();
} }

View file

@ -585,7 +585,7 @@ void Filler::addStoryArchive() {
const auto controller = _controller; const auto controller = _controller;
const auto weak = base::make_weak(_thread); const auto weak = base::make_weak(_thread);
_addAction(tr::lng_stories_archive_button(tr::now), [=] { _addAction(tr::lng_stories_archive_button(tr::now), [=] {
if (const auto strong = weak.get()) { if ([[maybe_unused]] const auto strong = weak.get()) {
controller->showSection(Info::Stories::Make( controller->showSection(Info::Stories::Make(
channel, channel,
Info::Stories::Tab::Archive)); Info::Stories::Tab::Archive));
@ -1096,7 +1096,7 @@ void Filler::addViewStatistics() {
= (channel->flags() & Flag::CanViewCreditsRevenue); = (channel->flags() & Flag::CanViewCreditsRevenue);
if (canGetStats) { if (canGetStats) {
_addAction(tr::lng_stats_title(tr::now), [=] { _addAction(tr::lng_stats_title(tr::now), [=] {
if (const auto strong = weak.get()) { if ([[maybe_unused]] const auto strong = weak.get()) {
using namespace Info; using namespace Info;
controller->showSection(Statistics::Make(peer, {}, {})); controller->showSection(Statistics::Make(peer, {}, {}));
} }
@ -1106,14 +1106,14 @@ void Filler::addViewStatistics() {
|| channel->amCreator() || channel->amCreator()
|| channel->canPostStories()) { || channel->canPostStories()) {
_addAction(tr::lng_boosts_title(tr::now), [=] { _addAction(tr::lng_boosts_title(tr::now), [=] {
if (const auto strong = weak.get()) { if ([[maybe_unused]] const auto strong = weak.get()) {
controller->showSection(Info::Boosts::Make(peer)); controller->showSection(Info::Boosts::Make(peer));
} }
}, &st::menuIconBoosts); }, &st::menuIconBoosts);
} }
if (canViewEarn || canViewCreditsEarn) { if (canViewEarn || canViewCreditsEarn) {
_addAction(tr::lng_channel_earn_title(tr::now), [=] { _addAction(tr::lng_channel_earn_title(tr::now), [=] {
if (const auto strong = weak.get()) { if ([[maybe_unused]] const auto strong = weak.get()) {
controller->showSection(Info::ChannelEarn::Make(peer)); controller->showSection(Info::ChannelEarn::Make(peer));
} }
}, &st::menuIconEarn); }, &st::menuIconEarn);