fix: reformat with resharper

This commit is contained in:
ZavaruKitsu 2023-07-10 14:30:23 +00:00
parent ee5ade56d7
commit f72e7178f5
18 changed files with 425 additions and 366 deletions

View file

@ -117,7 +117,8 @@ void SendProgressManager::send(const Key &key, int progress) {
// AyuGram sendUploadProgress
const auto settings = &AyuSettings::getInstance();
if (!settings->sendUploadProgress) {
if (!settings->sendUploadProgress)
{
DEBUG_LOG(("[AyuGram] Don't send upload progress"));
return;
}

View file

@ -903,12 +903,13 @@ void Updates::updateOnline(crl::time lastNonIdleTime, bool gotOtherOffline) {
// AyuGram sendOnlinePackets
const auto settings = &AyuSettings::getInstance();
const auto &config = _session->serverConfig();
const auto& config = _session->serverConfig();
bool isOnlineOrig = Core::App().hasActiveWindow(&session());
bool isOnline = settings->sendOnlinePackets && isOnlineOrig;
// AyuGram sendOfflinePacketAfterOnline
if (settings->sendOfflinePacketAfterOnline && _lastWasOnline) {
if (settings->sendOfflinePacketAfterOnline && _lastWasOnline)
{
isOnline = false;
}
@ -966,9 +967,11 @@ void Updates::updateOnline(crl::time lastNonIdleTime, bool gotOtherOffline) {
}
// AyuGram sendOfflinePacketAfterOnline
if (settings->sendOfflinePacketAfterOnline) {
if (settings->sendOfflinePacketAfterOnline)
{
session().api().requestFullPeer(session().user());
if (session().user()->onlineTill > base::unixtime::now()) {
if (session().user()->onlineTill > base::unixtime::now())
{
DEBUG_LOG(("[AyuGram] User likely appeared online"));
_onlineRequest = api().request(MTPaccount_UpdateStatus(

View file

@ -3487,7 +3487,8 @@ void ApiWrap::sendUploadedPhoto(
if (const auto item = _session->data().message(localId)) {
// AyuGram useScheduledMessages
const auto settings = &AyuSettings::getInstance();
if (settings->useScheduledMessages && !options.scheduled) {
if (settings->useScheduledMessages && !options.scheduled)
{
DEBUG_LOG(("[AyuGram] Scheduling message"));
auto current = base::unixtime::now();
options.scheduled = current + 18; // using 18 seconds because photo can be big
@ -3513,7 +3514,8 @@ void ApiWrap::sendUploadedDocument(
// AyuGram useScheduledMessages
const auto settings = &AyuSettings::getInstance();
if (settings->useScheduledMessages && !options.scheduled) {
if (settings->useScheduledMessages && !options.scheduled)
{
DEBUG_LOG(("[AyuGram] Scheduling message"));
auto current = base::unixtime::now();
options.scheduled = current + 60; // well, a document can be really big...
@ -3932,7 +3934,8 @@ void ApiWrap::sendMediaWithRandomId(
uint64 randomId) {
// AyuGram useScheduledMessages
const auto settings = &AyuSettings::getInstance();
if (settings->useScheduledMessages && !options.scheduled) {
if (settings->useScheduledMessages && !options.scheduled)
{
DEBUG_LOG(("[AyuGram] Scheduling message"));
auto current = base::unixtime::now();
options.scheduled = current + 12;
@ -4033,7 +4036,8 @@ void ApiWrap::sendAlbumIfReady(not_null<SendingAlbum*> album) {
// AyuGram useScheduledMessages
const auto settings = &AyuSettings::getInstance();
if (settings->useScheduledMessages && !album->options.scheduled) {
if (settings->useScheduledMessages && !album->options.scheduled)
{
DEBUG_LOG(("[AyuGram] Scheduling message"));
auto current = base::unixtime::now();
album->options.scheduled = current + 12;

View file

@ -1340,7 +1340,8 @@ void SendFilesBox::send(
bool ctrlShiftEnter) {
// AyuGram useScheduledMessages
const auto settings = &AyuSettings::getInstance();
if (settings->useScheduledMessages && !options.scheduled) {
if (settings->useScheduledMessages && !options.scheduled)
{
DEBUG_LOG(("[AyuGram] Scheduling files"));
auto current = base::unixtime::now();
options.scheduled = current + 60; // well, files can be really big...

View file

@ -485,7 +485,8 @@ void GifsListWidget::selectInlineResult(
const auto preview = Data::VideoPreviewState(media.get());
if (forceSend || (media && preview.loaded())) {
auto settings = &AyuSettings::getInstance();
auto sendGIFCallback = [=, this] {
auto sendGIFCallback = [=, this]
{
_fileChosen.fire({
.document = document,
.options = options,
@ -493,14 +494,16 @@ void GifsListWidget::selectInlineResult(
});
};
if (settings->GIFConfirmation) {
if (settings->GIFConfirmation)
{
Ui::show(Ui::MakeConfirmBox({
.text = rpl::single(QString("Do you want to send this GIF?")),
.confirmed = sendGIFCallback,
.confirmText = rpl::single(QString("Send")),
}));
}
else {
else
{
sendGIFCallback();
}
} else if (!preview.usingThumbnail()) {

View file

@ -1711,11 +1711,13 @@ void StickersListWidget::mouseReleaseEvent(QMouseEvent *e) {
showStickerSetBox(document);
} else {
auto settings = &AyuSettings::getInstance();
if (settings->stickerConfirmation) {
if (settings->stickerConfirmation)
{
// it is necessary to store it here, because section & index can be changed by cursor position (guess)
int currentSection = sticker->section;
int currentIndex = sticker->index;
auto sendStickerCallback = [=, this] {
auto sendStickerCallback = [=, this]
{
_chosen.fire({
.document = document,
.messageSendingFrom = messageSentAnimationInfo(
@ -1731,7 +1733,8 @@ void StickersListWidget::mouseReleaseEvent(QMouseEvent *e) {
.confirmText = rpl::single(QString("Send")),
}));
}
else {
else
{
_chosen.fire({
.document = document,
.messageSendingFrom = messageSentAnimationInfo(

View file

@ -184,7 +184,8 @@ void Histories::readInboxTill(
const auto settings = &AyuSettings::getInstance();
auto allow = settings->sendReadPackets;
auto reallyAllow = AyuState::getAllowSendPacket(); // will return true if `allow`
if (!reallyAllow) {
if (!reallyAllow)
{
DEBUG_LOG(("[AyuGram] Don't read messages"));
return;
}
@ -211,7 +212,8 @@ void Histories::readInboxTill(
}
return;
} else if (!needsRequest && (allow != reallyAllow && !force)
&& (!maybeState || !maybeState->willReadTill)) {
&& (!maybeState || !maybeState->willReadTill))
{
return;
}
const auto stillUnread = history->countStillUnreadLocal(tillId);

View file

@ -2168,32 +2168,40 @@ void Session::updateEditedMessage(const MTPMessage &data) {
const auto settings = &AyuSettings::getInstance();
HistoryMessageEdition edit;
if (data.type() != mtpc_message) {
if (data.type() != mtpc_message)
{
goto proceed;
}
edit = HistoryMessageEdition(_session, data.c_message());
if (settings->keepMessagesHistory && !existing->isLocal() && !existing->author()->isSelf() && !edit.isEditHide) {
if (settings->keepMessagesHistory && !existing->isLocal() && !existing->author()->isSelf() && !edit.isEditHide)
{
const auto history = existing->history();
const auto msg = existing->originalText();
const auto media = existing->media();
if (edit.textWithEntities == msg) {
if (edit.textWithEntities == msg)
{
// check if media changed
if (!edit.mtpMedia) {
if (!edit.mtpMedia)
{
goto proceed;
}
if (edit.mtpMedia->type() == mtpc_messageMediaPhoto
&& media->photo()
&& edit.mtpMedia->c_messageMediaPhoto().vphoto()->c_photo().vaccess_hash() == media->photo()->mtpInput().c_inputPhoto().vaccess_hash()) {
&& edit.mtpMedia->c_messageMediaPhoto().vphoto()->c_photo().vaccess_hash() == media->photo()->mtpInput()
.c_inputPhoto().vaccess_hash())
{
goto proceed;
}
if (edit.mtpMedia->type() == mtpc_messageMediaDocument
&& media->document()
&& edit.mtpMedia->c_messageMediaDocument().vdocument()->c_document().vaccess_hash() == media->document()->mtpInput().c_inputDocument().vaccess_hash()) {
&& edit.mtpMedia->c_messageMediaDocument().vdocument()->c_document().vaccess_hash() == media->document()
->mtpInput().c_inputDocument().vaccess_hash())
{
goto proceed;
}
}
@ -2202,7 +2210,8 @@ void Session::updateEditedMessage(const MTPMessage &data) {
| MessageFlag::HasReplyInfo
| MessageFlag::HasPostAuthor;
if (existing->isPost()) {
if (existing->isPost())
{
flags |= MessageFlag::Post;
}
@ -2212,51 +2221,58 @@ void Session::updateEditedMessage(const MTPMessage &data) {
auto msgId = existing->id.bare;
bool isDocument = media && media->document();
AyuDatabase::addEditedMessage((long) userId, (long) dialogId, (long) msgId, msg.text, isDocument, QString(""), (long) crl::now());
AyuDatabase::addEditedMessage((long)userId, (long)dialogId, (long)msgId, msg.text, isDocument, QString(""),
(long)crl::now());
if (!media || !(media->photo() || media->document())) {
// history->addNewLocalMessage(
// history->nextNonHistoryEntryId(),
// flags,
// UserId(),
// existing->id,
// base::unixtime::now(),
// existing->author()->id,
// "AyuGram"_q,
// msg,
// MTP_messageMediaEmpty(),
// HistoryMessageMarkupData(),
// existing->groupId().empty() ? 0 : existing->groupId().value);
} else {
if (media->photo()) {
// history->addNewLocalMessage(
// history->nextNonHistoryEntryId(),
// flags,
// UserId(),
// existing->id,
// base::unixtime::now(),
// existing->author()->id,
// "AyuGram"_q,
// media->photo(),
// existing->originalText(),
// HistoryMessageMarkupData());
} else if (media->document()) {
// history->addNewLocalMessage(
// history->nextNonHistoryEntryId(),
// flags,
// UserId(),
// existing->id,
// base::unixtime::now(),
// existing->author()->id,
// "AyuGram"_q,
// media->document(),
// existing->originalText(),
// HistoryMessageMarkupData());
if (!media || !(media->photo() || media->document()))
{
// history->addNewLocalMessage(
// history->nextNonHistoryEntryId(),
// flags,
// UserId(),
// existing->id,
// base::unixtime::now(),
// existing->author()->id,
// "AyuGram"_q,
// msg,
// MTP_messageMediaEmpty(),
// HistoryMessageMarkupData(),
// existing->groupId().empty() ? 0 : existing->groupId().value);
}
else
{
if (media->photo())
{
// history->addNewLocalMessage(
// history->nextNonHistoryEntryId(),
// flags,
// UserId(),
// existing->id,
// base::unixtime::now(),
// existing->author()->id,
// "AyuGram"_q,
// media->photo(),
// existing->originalText(),
// HistoryMessageMarkupData());
}
else if (media->document())
{
// history->addNewLocalMessage(
// history->nextNonHistoryEntryId(),
// flags,
// UserId(),
// existing->id,
// base::unixtime::now(),
// existing->author()->id,
// "AyuGram"_q,
// media->document(),
// existing->originalText(),
// HistoryMessageMarkupData());
}
}
}
proceed:
proceed:
if (existing->isLocalUpdateMedia() && data.type() == mtpc_message) {
updateExistingMessage(data.c_message());

View file

@ -481,10 +481,14 @@ void History::destroyMessage(not_null<HistoryItem*> item) {
// AyuGram keepDeletedMessages
const auto settings = &AyuSettings::getInstance();
if (settings->keepDeletedMessages && item->isRegular() && !item->isGroupMigrate()) {
if (!item->isService()) {
if (settings->keepDeletedMessages && item->isRegular() && !item->isGroupMigrate())
{
if (!item->isService())
{
item->setPostAuthor(settings->deletedMark);
} else {
}
else
{
const auto msg = TextWithEntities{
"Message deleted",
{
@ -501,7 +505,8 @@ void History::destroyMessage(not_null<HistoryItem*> item) {
| MessageFlag::HasReplyInfo
| MessageFlag::HasPostAuthor;
if (item->isPost()) {
if (item->isPost())
{
flags |= MessageFlag::Post;
}

View file

@ -2389,7 +2389,8 @@ void HistoryItem::setForwardsCount(int count) {
void HistoryItem::setPostAuthor(const QString &author) {
const auto settings = &AyuSettings::getInstance();
if (settings->keepDeletedMessages && !(_flags & MessageFlag::HasPostAuthor)) {
if (settings->keepDeletedMessages && !(_flags & MessageFlag::HasPostAuthor))
{
_flags |= MessageFlag::HasPostAuthor;
}
@ -2412,7 +2413,8 @@ void HistoryItem::setPostAuthor(const QString &author) {
msgsigned->isAnonymousRank = !isDiscussionPost()
&& this->author()->isMegagroup();
if (settings->keepDeletedMessages) {
if (settings->keepDeletedMessages)
{
history()->owner().requestItemViewRefresh(this);
}

View file

@ -3868,13 +3868,15 @@ Api::SendAction HistoryWidget::prepareSendAction(
void HistoryWidget::send(Api::SendOptions options) {
// AyuGram useScheduledMessages
const auto settings = &AyuSettings::getInstance();
if (settings->useScheduledMessages && !options.scheduled) {
if (settings->useScheduledMessages && !options.scheduled)
{
DEBUG_LOG(("[AyuGram] Scheduling message"));
auto current = base::unixtime::now();
options.scheduled = current + 12;
}
if (!settings->sendReadPackets && settings->markReadAfterSend) {
if (!settings->sendReadPackets && settings->markReadAfterSend)
{
AyuState::setAllowSendReadPacket(true);
_history->session().data().histories().readInboxOnNewMessage(_history->lastMessage());
}

View file

@ -1431,24 +1431,27 @@ void VoiceRecordBar::stopRecording(StopType type) {
window()->raise();
window()->activateWindow();
const auto duration = Duration(data.samples);
auto settings = &AyuSettings::getInstance();
if (type == StopType::Send) {
auto sendVoiceCallback = [=, this] {
_sendVoiceRequests.fire({ data.bytes, data.waveform, duration });
auto settings = &AyuSettings::getInstance();
if (type == StopType::Send)
{
auto sendVoiceCallback = [=, this]
{
_sendVoiceRequests.fire({data.bytes, data.waveform, duration});
};
if (settings->voiceConfirmation) {
if (settings->voiceConfirmation)
{
Ui::show(AyuUi::MakeConfirmBox({
.text = rpl::single(QString("Do you want to send voice message?")),
.confirmed = sendVoiceCallback,
.confirmText = rpl::single(QString("Send"))
}));
}
else {
else
{
sendVoiceCallback();
}
} else if (type == StopType::Listen) {
_listen = std::make_unique<ListenWrap>(
this,
@ -1523,7 +1526,8 @@ void VoiceRecordBar::requestToSendWithOptions(Api::SendOptions options) {
const auto data = _listen->data();
auto settings = &AyuSettings::getInstance();
auto sendVoiceCallback = [=, this] {
auto sendVoiceCallback = [=, this]
{
_sendVoiceRequests.fire({
data->bytes,
data->waveform,
@ -1532,14 +1536,16 @@ void VoiceRecordBar::requestToSendWithOptions(Api::SendOptions options) {
});
};
if (settings->voiceConfirmation) {
if (settings->voiceConfirmation)
{
Ui::show(AyuUi::MakeConfirmBox({
.text = rpl::single(QString("Do you want to send voice message?")),
.confirmed = sendVoiceCallback,
.confirmText = rpl::single(QString("Send"))
}));
}
else {
else
{
sendVoiceCallback();
}
}

View file

@ -1079,9 +1079,12 @@ base::unique_qptr<Ui::PopupMenu> FillContextMenu(
}
}
if (item != nullptr) {
if (AyuDatabase::editedMessagesTableExists() && !((AyuDatabase::getEditedMessages(item)).empty())) {
result->addAction(QString("History"), [=] {
if (item != nullptr)
{
if (AyuDatabase::editedMessagesTableExists() && !((AyuDatabase::getEditedMessages(item)).empty()))
{
result->addAction(QString("History"), [=]
{
auto box = Box<AyuUi::MessageHistoryBox>(item);
Ui::show(std::move(box));
}, &st::menuIconInfo);
@ -1089,7 +1092,8 @@ base::unique_qptr<Ui::PopupMenu> FillContextMenu(
const auto settings = &AyuSettings::getInstance();
const auto history = item->history();
result->addAction(QString("Hide"), [=]() {
result->addAction(QString("Hide"), [=]()
{
const auto initKeepDeleted = settings->keepDeletedMessages;
settings->set_keepDeletedMessages(false);

View file

@ -91,7 +91,8 @@ void Tray::rebuildMenu() {
}
auto turnGhostModeText = _textUpdates.events(
) | rpl::map([=] {
) | rpl::map([=]
{
bool ghostModeEnabled = AyuSettings::get_ghostModeEnabled();
return ghostModeEnabled
@ -99,7 +100,8 @@ void Tray::rebuildMenu() {
: tr::ayu_EnableGhostMode(tr::now);
});
_tray.addAction(std::move(turnGhostModeText), [=] {
_tray.addAction(std::move(turnGhostModeText), [=]
{
auto settings = &AyuSettings::getInstance();
bool ghostMode = !AyuSettings::get_ghostModeEnabled();
@ -113,7 +115,8 @@ void Tray::rebuildMenu() {
});
auto quitText = _textUpdates.events(
) | rpl::map([=] {
) | rpl::map([=]
{
return tr::lng_quit_from_tray(tr::now).replace("Telegram", "AyuGram");
});
_tray.addAction(std::move(quitText), [] { Core::Quit(); });

View file

@ -767,8 +767,9 @@ void MainMenu::setupMenu() {
});
addAction(
rpl::single(QString("LRead Messages")),
{ &st::settingsIconForward, kIconPurple }
)->setClickedCallback([=] {
{&st::settingsIconForward, kIconPurple}
)->setClickedCallback([=]
{
auto settings = &AyuSettings::getInstance();
auto prev = settings->sendReadPackets;
settings->set_sendReadPackets(false);
@ -780,8 +781,9 @@ void MainMenu::setupMenu() {
});
addAction(
rpl::single(QString("SRead Messages")),
{ &st::settingsIconForward, kIconPurple }
)->setClickedCallback([=] {
{&st::settingsIconForward, kIconPurple}
)->setClickedCallback([=]
{
auto box = Box<AyuUi::ConfirmationBox>(controller);
Ui::show(std::move(box));
});
@ -847,14 +849,16 @@ void MainMenu::setupMenu() {
}, _nightThemeToggle->lifetime());
const auto settings = &AyuSettings::getInstance();
if (settings->showGhostToggleInDrawer) {
if (settings->showGhostToggleInDrawer)
{
_ghostModeToggle = addAction(
tr::ayu_DrawerGhostModeToggle(),
{&st::ayuGhostIcon, kIconPurple}
)->toggleOn(AyuSettings::get_ghostModeEnabledReactive());
_ghostModeToggle->toggledChanges(
) | rpl::start_with_next([=](bool ghostMode) {
) | rpl::start_with_next([=](bool ghostMode)
{
settings->set_sendReadPackets(!ghostMode);
settings->set_sendOnlinePackets(!ghostMode);
settings->set_sendUploadProgress(!ghostMode);