diff --git a/Telegram/SourceFiles/api/api_send_progress.cpp b/Telegram/SourceFiles/api/api_send_progress.cpp index 614a78455..556c43c50 100644 --- a/Telegram/SourceFiles/api/api_send_progress.cpp +++ b/Telegram/SourceFiles/api/api_send_progress.cpp @@ -115,12 +115,13 @@ void SendProgressManager::send(const Key &key, int progress) { return; } - // AyuGram sendUploadProgress - const auto settings = &AyuSettings::getInstance(); - if (!settings->sendUploadProgress) { - DEBUG_LOG(("[AyuGram] Don't send upload progress")); - return; - } + // AyuGram sendUploadProgress + const auto settings = &AyuSettings::getInstance(); + if (!settings->sendUploadProgress) + { + DEBUG_LOG(("[AyuGram] Don't send upload progress")); + return; + } using Type = SendProgressType; const auto action = [&]() -> MTPsendMessageAction { diff --git a/Telegram/SourceFiles/api/api_updates.cpp b/Telegram/SourceFiles/api/api_updates.cpp index 592b3ca53..f78a5d9d1 100644 --- a/Telegram/SourceFiles/api/api_updates.cpp +++ b/Telegram/SourceFiles/api/api_updates.cpp @@ -901,16 +901,17 @@ void Updates::updateOnline(crl::time lastNonIdleTime, bool gotOtherOffline) { Core::App().checkAutoLock(lastNonIdleTime); }); - // AyuGram sendOnlinePackets - const auto settings = &AyuSettings::getInstance(); - const auto &config = _session->serverConfig(); - bool isOnlineOrig = Core::App().hasActiveWindow(&session()); - bool isOnline = settings->sendOnlinePackets && isOnlineOrig; + // AyuGram sendOnlinePackets + const auto settings = &AyuSettings::getInstance(); + const auto& config = _session->serverConfig(); + bool isOnlineOrig = Core::App().hasActiveWindow(&session()); + bool isOnline = settings->sendOnlinePackets && isOnlineOrig; - // AyuGram sendOfflinePacketAfterOnline - if (settings->sendOfflinePacketAfterOnline && _lastWasOnline) { - isOnline = false; - } + // AyuGram sendOfflinePacketAfterOnline + if (settings->sendOfflinePacketAfterOnline && _lastWasOnline) + { + isOnline = false; + } int updateIn = config.onlineUpdatePeriod; Assert(updateIn >= 0); @@ -965,20 +966,22 @@ void Updates::updateOnline(crl::time lastNonIdleTime, bool gotOtherOffline) { Assert(updateIn >= 0); } - // AyuGram sendOfflinePacketAfterOnline - if (settings->sendOfflinePacketAfterOnline) { - session().api().requestFullPeer(session().user()); - if (session().user()->onlineTill > base::unixtime::now()) { - DEBUG_LOG(("[AyuGram] User likely appeared online")); + // AyuGram sendOfflinePacketAfterOnline + if (settings->sendOfflinePacketAfterOnline) + { + session().api().requestFullPeer(session().user()); + if (session().user()->onlineTill > base::unixtime::now()) + { + DEBUG_LOG(("[AyuGram] User likely appeared online")); - _onlineRequest = api().request(MTPaccount_UpdateStatus( - MTP_bool(true) - )).send(); - } + _onlineRequest = api().request(MTPaccount_UpdateStatus( + MTP_bool(true) + )).send(); + } - DEBUG_LOG(("[AyuGram] Decreasing updateIn because of enabled features")); - updateIn = 1250; - } + DEBUG_LOG(("[AyuGram] Decreasing updateIn because of enabled features")); + updateIn = 1250; + } _onlineTimer.callOnce(updateIn); } diff --git a/Telegram/SourceFiles/apiwrap.cpp b/Telegram/SourceFiles/apiwrap.cpp index 5d7b163e4..6348f1718 100644 --- a/Telegram/SourceFiles/apiwrap.cpp +++ b/Telegram/SourceFiles/apiwrap.cpp @@ -3485,13 +3485,14 @@ void ApiWrap::sendUploadedPhoto( Api::RemoteFileInfo info, Api::SendOptions options) { if (const auto item = _session->data().message(localId)) { - // AyuGram useScheduledMessages - const auto settings = &AyuSettings::getInstance(); - 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 - } + // AyuGram useScheduledMessages + const auto settings = &AyuSettings::getInstance(); + 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 + } const auto media = Api::PrepareUploadedPhoto(item, std::move(info)); if (const auto groupId = item->groupId()) { @@ -3511,13 +3512,14 @@ void ApiWrap::sendUploadedDocument( return; } - // AyuGram useScheduledMessages - const auto settings = &AyuSettings::getInstance(); - 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... - } + // AyuGram useScheduledMessages + const auto settings = &AyuSettings::getInstance(); + 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... + } const auto media = Api::PrepareUploadedDocument( item, @@ -3930,13 +3932,14 @@ void ApiWrap::sendMediaWithRandomId( const MTPInputMedia &media, Api::SendOptions options, uint64 randomId) { - // AyuGram useScheduledMessages - const auto settings = &AyuSettings::getInstance(); - if (settings->useScheduledMessages && !options.scheduled) { - DEBUG_LOG(("[AyuGram] Scheduling message")); - auto current = base::unixtime::now(); - options.scheduled = current + 12; - } + // AyuGram useScheduledMessages + const auto settings = &AyuSettings::getInstance(); + if (settings->useScheduledMessages && !options.scheduled) + { + DEBUG_LOG(("[AyuGram] Scheduling message")); + auto current = base::unixtime::now(); + options.scheduled = current + 12; + } const auto history = item->history(); const auto replyTo = item->replyToId(); @@ -4031,13 +4034,14 @@ void ApiWrap::sendAlbumIfReady(not_null album) { return; } - // AyuGram useScheduledMessages - const auto settings = &AyuSettings::getInstance(); - if (settings->useScheduledMessages && !album->options.scheduled) { - DEBUG_LOG(("[AyuGram] Scheduling message")); - auto current = base::unixtime::now(); - album->options.scheduled = current + 12; - } + // AyuGram useScheduledMessages + const auto settings = &AyuSettings::getInstance(); + if (settings->useScheduledMessages && !album->options.scheduled) + { + DEBUG_LOG(("[AyuGram] Scheduling message")); + auto current = base::unixtime::now(); + album->options.scheduled = current + 12; + } auto sample = (HistoryItem*)nullptr; auto medias = QVector(); diff --git a/Telegram/SourceFiles/boxes/send_files_box.cpp b/Telegram/SourceFiles/boxes/send_files_box.cpp index fba8d61bd..dd5a84e55 100644 --- a/Telegram/SourceFiles/boxes/send_files_box.cpp +++ b/Telegram/SourceFiles/boxes/send_files_box.cpp @@ -1338,13 +1338,14 @@ bool SendFilesBox::validateLength(const QString &text) const { void SendFilesBox::send( Api::SendOptions options, bool ctrlShiftEnter) { - // AyuGram useScheduledMessages - const auto settings = &AyuSettings::getInstance(); - 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... - } + // AyuGram useScheduledMessages + const auto settings = &AyuSettings::getInstance(); + 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... + } if ((_sendType == Api::SendType::Scheduled || _sendType == Api::SendType::ScheduledToUser) diff --git a/Telegram/SourceFiles/chat_helpers/gifs_list_widget.cpp b/Telegram/SourceFiles/chat_helpers/gifs_list_widget.cpp index 9ad5aa516..b772db1de 100644 --- a/Telegram/SourceFiles/chat_helpers/gifs_list_widget.cpp +++ b/Telegram/SourceFiles/chat_helpers/gifs_list_widget.cpp @@ -484,25 +484,28 @@ void GifsListWidget::selectInlineResult( const auto media = document->activeMediaView(); const auto preview = Data::VideoPreviewState(media.get()); if (forceSend || (media && preview.loaded())) { - auto settings = &AyuSettings::getInstance(); - auto sendGIFCallback = [=, this] { - _fileChosen.fire({ - .document = document, - .options = options, - .messageSendingFrom = messageSendingFrom(), - }); - }; + auto settings = &AyuSettings::getInstance(); + auto sendGIFCallback = [=, this] + { + _fileChosen.fire({ + .document = document, + .options = options, + .messageSendingFrom = messageSendingFrom(), + }); + }; - 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 { - sendGIFCallback(); - } + 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 + { + sendGIFCallback(); + } } else if (!preview.usingThumbnail()) { if (preview.loading()) { document->cancel(); diff --git a/Telegram/SourceFiles/chat_helpers/stickers_list_widget.cpp b/Telegram/SourceFiles/chat_helpers/stickers_list_widget.cpp index b0d591d69..dc7194fee 100644 --- a/Telegram/SourceFiles/chat_helpers/stickers_list_widget.cpp +++ b/Telegram/SourceFiles/chat_helpers/stickers_list_widget.cpp @@ -1710,36 +1710,39 @@ void StickersListWidget::mouseReleaseEvent(QMouseEvent *e) { if (e->modifiers() & Qt::ControlModifier) { showStickerSetBox(document); } else { - auto settings = &AyuSettings::getInstance(); - 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] { - _chosen.fire({ - .document = document, - .messageSendingFrom = messageSentAnimationInfo( - currentSection, - currentIndex, - document), - }); - }; + auto settings = &AyuSettings::getInstance(); + 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] + { + _chosen.fire({ + .document = document, + .messageSendingFrom = messageSentAnimationInfo( + currentSection, + currentIndex, + document), + }); + }; - Ui::show(Ui::MakeConfirmBox({ - .text = rpl::single(QString("Do you want to send this sticker?")), - .confirmed = sendStickerCallback, - .confirmText = rpl::single(QString("Send")), - })); - } - else { - _chosen.fire({ - .document = document, - .messageSendingFrom = messageSentAnimationInfo( - sticker->section, - sticker->index, - document), - }); - } + Ui::show(Ui::MakeConfirmBox({ + .text = rpl::single(QString("Do you want to send this sticker?")), + .confirmed = sendStickerCallback, + .confirmText = rpl::single(QString("Send")), + })); + } + else + { + _chosen.fire({ + .document = document, + .messageSendingFrom = messageSentAnimationInfo( + sticker->section, + sticker->index, + document), + }); + } } } else if (auto set = std::get_if(&pressed)) { Assert(set->section >= 0 && set->section < sets.size()); diff --git a/Telegram/SourceFiles/data/data_histories.cpp b/Telegram/SourceFiles/data/data_histories.cpp index 438c1a124..b6812b740 100644 --- a/Telegram/SourceFiles/data/data_histories.cpp +++ b/Telegram/SourceFiles/data/data_histories.cpp @@ -180,14 +180,15 @@ void Histories::readInboxTill( AyuSync::getInstance().syncRead(history, tillId); - // AyuGram sendReadPackets - const auto settings = &AyuSettings::getInstance(); - auto allow = settings->sendReadPackets; - auto reallyAllow = AyuState::getAllowSendPacket(); // will return true if `allow` - if (!reallyAllow) { - DEBUG_LOG(("[AyuGram] Don't read messages")); - return; - } + // AyuGram sendReadPackets + const auto settings = &AyuSettings::getInstance(); + auto allow = settings->sendReadPackets; + auto reallyAllow = AyuState::getAllowSendPacket(); // will return true if `allow` + if (!reallyAllow) + { + DEBUG_LOG(("[AyuGram] Don't read messages")); + return; + } const auto needsRequest = history->readInboxTillNeedsRequest(tillId); if (!needsRequest && !force) { @@ -210,8 +211,9 @@ void Histories::readInboxTill( sendPendingReadInbox(history); } return; - } else if (!needsRequest && (allow != reallyAllow && !force) - && (!maybeState || !maybeState->willReadTill)) { + } else if (!needsRequest && (allow != reallyAllow && !force) + && (!maybeState || !maybeState->willReadTill)) + { return; } const auto stillUnread = history->countStillUnreadLocal(tillId); diff --git a/Telegram/SourceFiles/data/data_session.cpp b/Telegram/SourceFiles/data/data_session.cpp index 9dde4ef86..229186458 100644 --- a/Telegram/SourceFiles/data/data_session.cpp +++ b/Telegram/SourceFiles/data/data_session.cpp @@ -2164,99 +2164,115 @@ void Session::updateEditedMessage(const MTPMessage &data) { return; } - // AyuGram keepMessagesHistory - const auto settings = &AyuSettings::getInstance(); - HistoryMessageEdition edit; + // AyuGram keepMessagesHistory + const auto settings = &AyuSettings::getInstance(); + HistoryMessageEdition edit; - if (data.type() != mtpc_message) { - goto proceed; - } - edit = HistoryMessageEdition(_session, data.c_message()); - if (settings->keepMessagesHistory && !existing->isLocal() && !existing->author()->isSelf() && !edit.isEditHide) { - const auto history = existing->history(); - const auto msg = existing->originalText(); + if (data.type() != mtpc_message) + { + goto proceed; + } + edit = HistoryMessageEdition(_session, data.c_message()); + 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(); + const auto media = existing->media(); - if (edit.textWithEntities == msg) { - // check if media changed + if (edit.textWithEntities == msg) + { + // check if media changed - if (!edit.mtpMedia) { - goto proceed; - } + 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()) { - 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()) + { + 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()) { - 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()) + { + goto proceed; + } + } - auto flags = MessageFlag::HasFromId - | MessageFlag::HasReplyInfo - | MessageFlag::HasPostAuthor; + auto flags = MessageFlag::HasFromId + | MessageFlag::HasReplyInfo + | MessageFlag::HasPostAuthor; - if (existing->isPost()) { - flags |= MessageFlag::Post; - } + if (existing->isPost()) + { + flags |= MessageFlag::Post; + } - // adding msg data to local ayu db (table:editedMessage) - auto userId = existing->displayFrom()->id.value; - auto dialogId = history->peer->id.value; - auto msgId = existing->id.bare; - bool isDocument = media && media->document(); + // adding msg data to local ayu db (table:editedMessage) + auto userId = existing->displayFrom()->id.value; + auto dialogId = history->peer->id.value; + 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()); diff --git a/Telegram/SourceFiles/data/data_sponsored_messages.cpp b/Telegram/SourceFiles/data/data_sponsored_messages.cpp index 5fb2b4fe3..418de9e51 100644 --- a/Telegram/SourceFiles/data/data_sponsored_messages.cpp +++ b/Telegram/SourceFiles/data/data_sponsored_messages.cpp @@ -177,7 +177,7 @@ void SponsoredMessages::inject( } bool SponsoredMessages::canHaveFor(not_null history) const { - auto settings = &AyuSettings::getInstance(); + auto settings = &AyuSettings::getInstance(); return settings->enableAds && history->peer->isChannel(); } diff --git a/Telegram/SourceFiles/history/history.cpp b/Telegram/SourceFiles/history/history.cpp index a009ee2e2..1800f2240 100644 --- a/Telegram/SourceFiles/history/history.cpp +++ b/Telegram/SourceFiles/history/history.cpp @@ -479,48 +479,53 @@ not_null History::insertItem( void History::destroyMessage(not_null item) { Expects(item->isHistoryEntry() || !item->mainView()); - // AyuGram keepDeletedMessages - const auto settings = &AyuSettings::getInstance(); - if (settings->keepDeletedMessages && item->isRegular() && !item->isGroupMigrate()) { - if (!item->isService()) { - item->setPostAuthor(settings->deletedMark); - } else { - const auto msg = TextWithEntities{ - "Message deleted", - { - EntityInText( - EntityType::Italic, - 0, - 15, - "Message deleted" - ) - } - }; + // AyuGram keepDeletedMessages + const auto settings = &AyuSettings::getInstance(); + if (settings->keepDeletedMessages && item->isRegular() && !item->isGroupMigrate()) + { + if (!item->isService()) + { + item->setPostAuthor(settings->deletedMark); + } + else + { + const auto msg = TextWithEntities{ + "Message deleted", + { + EntityInText( + EntityType::Italic, + 0, + 15, + "Message deleted" + ) + } + }; - auto flags = MessageFlag::HasFromId - | MessageFlag::HasReplyInfo - | MessageFlag::HasPostAuthor; + auto flags = MessageFlag::HasFromId + | MessageFlag::HasReplyInfo + | MessageFlag::HasPostAuthor; - if (item->isPost()) { - flags |= MessageFlag::Post; - } + if (item->isPost()) + { + flags |= MessageFlag::Post; + } - addNewLocalMessage( - session().data().nextLocalMessageId(), - flags, - UserId(), - item->id, - base::unixtime::now(), - item->author()->id, - "AyuGram"_q, - msg, - MTP_messageMediaEmpty(), - HistoryMessageMarkupData(), - uint64(0)); - } + addNewLocalMessage( + session().data().nextLocalMessageId(), + flags, + UserId(), + item->id, + base::unixtime::now(), + item->author()->id, + "AyuGram"_q, + msg, + MTP_messageMediaEmpty(), + HistoryMessageMarkupData(), + uint64(0)); + } - return; - } + return; + } const auto peerId = peer->id; if (item->isHistoryEntry()) { diff --git a/Telegram/SourceFiles/history/history_item.cpp b/Telegram/SourceFiles/history/history_item.cpp index 784c930bd..4fb753e5f 100644 --- a/Telegram/SourceFiles/history/history_item.cpp +++ b/Telegram/SourceFiles/history/history_item.cpp @@ -2388,10 +2388,11 @@ void HistoryItem::setForwardsCount(int count) { } void HistoryItem::setPostAuthor(const QString &author) { - const auto settings = &AyuSettings::getInstance(); - if (settings->keepDeletedMessages && !(_flags & MessageFlag::HasPostAuthor)) { - _flags |= MessageFlag::HasPostAuthor; - } + const auto settings = &AyuSettings::getInstance(); + if (settings->keepDeletedMessages && !(_flags & MessageFlag::HasPostAuthor)) + { + _flags |= MessageFlag::HasPostAuthor; + } auto msgsigned = Get(); if (author.isEmpty()) { @@ -2412,9 +2413,10 @@ void HistoryItem::setPostAuthor(const QString &author) { msgsigned->isAnonymousRank = !isDiscussionPost() && this->author()->isMegagroup(); - if (settings->keepDeletedMessages) { - history()->owner().requestItemViewRefresh(this); - } + if (settings->keepDeletedMessages) + { + history()->owner().requestItemViewRefresh(this); + } history()->owner().requestItemResize(this); } diff --git a/Telegram/SourceFiles/history/history_widget.cpp b/Telegram/SourceFiles/history/history_widget.cpp index fb59801b3..d3f09a32d 100644 --- a/Telegram/SourceFiles/history/history_widget.cpp +++ b/Telegram/SourceFiles/history/history_widget.cpp @@ -3866,18 +3866,20 @@ Api::SendAction HistoryWidget::prepareSendAction( } void HistoryWidget::send(Api::SendOptions options) { - // AyuGram useScheduledMessages - const auto settings = &AyuSettings::getInstance(); - if (settings->useScheduledMessages && !options.scheduled) { - DEBUG_LOG(("[AyuGram] Scheduling message")); - auto current = base::unixtime::now(); - options.scheduled = current + 12; - } + // AyuGram useScheduledMessages + const auto settings = &AyuSettings::getInstance(); + if (settings->useScheduledMessages && !options.scheduled) + { + DEBUG_LOG(("[AyuGram] Scheduling message")); + auto current = base::unixtime::now(); + options.scheduled = current + 12; + } - if (!settings->sendReadPackets && settings->markReadAfterSend) { - AyuState::setAllowSendReadPacket(true); - _history->session().data().histories().readInboxOnNewMessage(_history->lastMessage()); - } + if (!settings->sendReadPackets && settings->markReadAfterSend) + { + AyuState::setAllowSendReadPacket(true); + _history->session().data().histories().readInboxOnNewMessage(_history->lastMessage()); + } if (!_history) { return; diff --git a/Telegram/SourceFiles/history/view/controls/history_view_voice_record_bar.cpp b/Telegram/SourceFiles/history/view/controls/history_view_voice_record_bar.cpp index 562c0cc05..acf6e466a 100644 --- a/Telegram/SourceFiles/history/view/controls/history_view_voice_record_bar.cpp +++ b/Telegram/SourceFiles/history/view/controls/history_view_voice_record_bar.cpp @@ -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 }); - }; - - 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 { - sendVoiceCallback(); - } + auto settings = &AyuSettings::getInstance(); + if (type == StopType::Send) + { + auto sendVoiceCallback = [=, this] + { + _sendVoiceRequests.fire({data.bytes, data.waveform, duration}); + }; + 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 + { + sendVoiceCallback(); + } } else if (type == StopType::Listen) { _listen = std::make_unique( this, @@ -1521,27 +1524,30 @@ void VoiceRecordBar::drawMessage(Painter &p, float64 recordActive) { void VoiceRecordBar::requestToSendWithOptions(Api::SendOptions options) { if (isListenState()) { const auto data = _listen->data(); - auto settings = &AyuSettings::getInstance(); + auto settings = &AyuSettings::getInstance(); - auto sendVoiceCallback = [=, this] { - _sendVoiceRequests.fire({ - data->bytes, - data->waveform, - Duration(data->samples), - options - }); - }; + auto sendVoiceCallback = [=, this] + { + _sendVoiceRequests.fire({ + data->bytes, + data->waveform, + Duration(data->samples), + options + }); + }; - 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 { - sendVoiceCallback(); - } + 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 + { + sendVoiceCallback(); + } } } diff --git a/Telegram/SourceFiles/history/view/history_view_bottom_info.cpp b/Telegram/SourceFiles/history/view/history_view_bottom_info.cpp index aa7ea108b..0741cda29 100644 --- a/Telegram/SourceFiles/history/view/history_view_bottom_info.cpp +++ b/Telegram/SourceFiles/history/view/history_view_bottom_info.cpp @@ -463,11 +463,11 @@ void BottomInfo::layout() { } void BottomInfo::layoutDateText() { - const auto settings = &AyuSettings::getInstance(); + const auto settings = &AyuSettings::getInstance(); - const auto edited = (_data.flags & Data::Flag::Edited) - ? (settings->editedMark + ' ') - : QString(); + const auto edited = (_data.flags & Data::Flag::Edited) + ? (settings->editedMark + ' ') + : QString(); const auto author = _data.author; const auto prefix = !author.isEmpty() ? (author == settings->deletedMark ? u" "_q : u", "_q) : QString(); const auto date = edited + QLocale().toString( diff --git a/Telegram/SourceFiles/history/view/history_view_context_menu.cpp b/Telegram/SourceFiles/history/view/history_view_context_menu.cpp index 28480b4a9..7d69a7ecc 100644 --- a/Telegram/SourceFiles/history/view/history_view_context_menu.cpp +++ b/Telegram/SourceFiles/history/view/history_view_context_menu.cpp @@ -1079,24 +1079,28 @@ base::unique_qptr FillContextMenu( } } - if (item != nullptr) { - if (AyuDatabase::editedMessagesTableExists() && !((AyuDatabase::getEditedMessages(item)).empty())) { - result->addAction(QString("History"), [=] { - auto box = Box(item); - Ui::show(std::move(box)); - }, &st::menuIconInfo); - } + if (item != nullptr) + { + if (AyuDatabase::editedMessagesTableExists() && !((AyuDatabase::getEditedMessages(item)).empty())) + { + result->addAction(QString("History"), [=] + { + auto box = Box(item); + Ui::show(std::move(box)); + }, &st::menuIconInfo); + } - const auto settings = &AyuSettings::getInstance(); - const auto history = item->history(); - result->addAction(QString("Hide"), [=]() { - const auto initKeepDeleted = settings->keepDeletedMessages; + const auto settings = &AyuSettings::getInstance(); + const auto history = item->history(); + result->addAction(QString("Hide"), [=]() + { + const auto initKeepDeleted = settings->keepDeletedMessages; - settings->set_keepDeletedMessages(false); - history->destroyMessage(item); - settings->set_keepDeletedMessages(initKeepDeleted); - }, &st::menuIconClear); - } + settings->set_keepDeletedMessages(false); + history->destroyMessage(item); + settings->set_keepDeletedMessages(initKeepDeleted); + }, &st::menuIconClear); + } if (!view || !list->hasCopyRestriction(view->data())) { AddCopyLinkAction(result, link); diff --git a/Telegram/SourceFiles/info/profile/info_profile_actions.cpp b/Telegram/SourceFiles/info/profile/info_profile_actions.cpp index 8c788e07d..6995832bb 100644 --- a/Telegram/SourceFiles/info/profile/info_profile_actions.cpp +++ b/Telegram/SourceFiles/info/profile/info_profile_actions.cpp @@ -287,7 +287,7 @@ bool SetClickContext( } object_ptr DetailsFiller::setupInfo() { - auto settings = &AyuSettings::getInstance(); + auto settings = &AyuSettings::getInstance(); auto result = object_ptr(_wrap); auto tracker = Ui::MultiSlideTracker(); diff --git a/Telegram/SourceFiles/tray.cpp b/Telegram/SourceFiles/tray.cpp index 2928b69ef..10f7ce375 100644 --- a/Telegram/SourceFiles/tray.cpp +++ b/Telegram/SourceFiles/tray.cpp @@ -90,32 +90,35 @@ void Tray::rebuildMenu() { [=] { toggleSoundNotifications(); }); } - auto turnGhostModeText = _textUpdates.events( - ) | rpl::map([=] { - bool ghostModeEnabled = AyuSettings::get_ghostModeEnabled(); + auto turnGhostModeText = _textUpdates.events( + ) | rpl::map([=] + { + bool ghostModeEnabled = AyuSettings::get_ghostModeEnabled(); - return ghostModeEnabled - ? tr::ayu_DisableGhostMode(tr::now) - : tr::ayu_EnableGhostMode(tr::now); - }); + return ghostModeEnabled + ? tr::ayu_DisableGhostMode(tr::now) + : tr::ayu_EnableGhostMode(tr::now); + }); - _tray.addAction(std::move(turnGhostModeText), [=] { - auto settings = &AyuSettings::getInstance(); - bool ghostMode = !AyuSettings::get_ghostModeEnabled(); + _tray.addAction(std::move(turnGhostModeText), [=] + { + auto settings = &AyuSettings::getInstance(); + bool ghostMode = !AyuSettings::get_ghostModeEnabled(); - settings->set_sendReadPackets(!ghostMode); - settings->set_sendOnlinePackets(!ghostMode); - settings->set_sendUploadProgress(!ghostMode); + settings->set_sendReadPackets(!ghostMode); + settings->set_sendOnlinePackets(!ghostMode); + settings->set_sendUploadProgress(!ghostMode); - settings->set_sendOfflinePacketAfterOnline(ghostMode); + settings->set_sendOfflinePacketAfterOnline(ghostMode); - AyuSettings::save(); - }); + AyuSettings::save(); + }); - auto quitText = _textUpdates.events( - ) | rpl::map([=] { - return tr::lng_quit_from_tray(tr::now).replace("Telegram", "AyuGram"); - }); + auto quitText = _textUpdates.events( + ) | rpl::map([=] + { + return tr::lng_quit_from_tray(tr::now).replace("Telegram", "AyuGram"); + }); _tray.addAction(std::move(quitText), [] { Core::Quit(); }); updateMenuText(); diff --git a/Telegram/SourceFiles/window/window_main_menu.cpp b/Telegram/SourceFiles/window/window_main_menu.cpp index 6d474d8f3..b178c68f5 100644 --- a/Telegram/SourceFiles/window/window_main_menu.cpp +++ b/Telegram/SourceFiles/window/window_main_menu.cpp @@ -765,26 +765,28 @@ void MainMenu::setupMenu() { )->setClickedCallback([=] { controller->showPeerHistory(controller->session().user()); }); - addAction( - rpl::single(QString("LRead Messages")), - { &st::settingsIconForward, kIconPurple } - )->setClickedCallback([=] { - auto settings = &AyuSettings::getInstance(); - auto prev = settings->sendReadPackets; - settings->set_sendReadPackets(false); + addAction( + rpl::single(QString("LRead Messages")), + {&st::settingsIconForward, kIconPurple} + )->setClickedCallback([=] + { + auto settings = &AyuSettings::getInstance(); + auto prev = settings->sendReadPackets; + settings->set_sendReadPackets(false); - auto chats = controller->session().data().chatsList(); - MarkAsReadChatListHack(chats); + auto chats = controller->session().data().chatsList(); + MarkAsReadChatListHack(chats); - settings->set_sendReadPackets(prev); - }); - addAction( - rpl::single(QString("SRead Messages")), - { &st::settingsIconForward, kIconPurple } - )->setClickedCallback([=] { - auto box = Box(controller); - Ui::show(std::move(box)); - }); + settings->set_sendReadPackets(prev); + }); + addAction( + rpl::single(QString("SRead Messages")), + {&st::settingsIconForward, kIconPurple} + )->setClickedCallback([=] + { + auto box = Box(controller); + Ui::show(std::move(box)); + }); } else { addAction( tr::lng_profile_add_contact(), @@ -846,24 +848,26 @@ void MainMenu::setupMenu() { toggle); }, _nightThemeToggle->lifetime()); - const auto settings = &AyuSettings::getInstance(); - if (settings->showGhostToggleInDrawer) { - _ghostModeToggle = addAction( - tr::ayu_DrawerGhostModeToggle(), - {&st::ayuGhostIcon, kIconPurple} - )->toggleOn(AyuSettings::get_ghostModeEnabledReactive()); + const auto settings = &AyuSettings::getInstance(); + if (settings->showGhostToggleInDrawer) + { + _ghostModeToggle = addAction( + tr::ayu_DrawerGhostModeToggle(), + {&st::ayuGhostIcon, kIconPurple} + )->toggleOn(AyuSettings::get_ghostModeEnabledReactive()); - _ghostModeToggle->toggledChanges( - ) | rpl::start_with_next([=](bool ghostMode) { - settings->set_sendReadPackets(!ghostMode); - settings->set_sendOnlinePackets(!ghostMode); - settings->set_sendUploadProgress(!ghostMode); + _ghostModeToggle->toggledChanges( + ) | rpl::start_with_next([=](bool ghostMode) + { + settings->set_sendReadPackets(!ghostMode); + settings->set_sendOnlinePackets(!ghostMode); + settings->set_sendUploadProgress(!ghostMode); - settings->set_sendOfflinePacketAfterOnline(ghostMode); + settings->set_sendOfflinePacketAfterOnline(ghostMode); - AyuSettings::save(); - }, _ghostModeToggle->lifetime()); - } + AyuSettings::save(); + }, _ghostModeToggle->lifetime()); + } Core::App().settings().systemDarkModeValue( ) | rpl::start_with_next([=](std::optional darkMode) {