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

@ -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 {

View file

@ -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);
}

View file

@ -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<SendingAlbum*> 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<MTPInputSingleMedia>();

View file

@ -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)

View file

@ -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();

View file

@ -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<OverSet>(&pressed)) {
Assert(set->section >= 0 && set->section < sets.size());

View file

@ -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);

View file

@ -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());

View file

@ -177,7 +177,7 @@ void SponsoredMessages::inject(
}
bool SponsoredMessages::canHaveFor(not_null<History*> history) const {
auto settings = &AyuSettings::getInstance();
auto settings = &AyuSettings::getInstance();
return settings->enableAds && history->peer->isChannel();
}

View file

@ -479,48 +479,53 @@ not_null<HistoryItem*> History::insertItem(
void History::destroyMessage(not_null<HistoryItem*> 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()) {

View file

@ -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<HistoryMessageSigned>();
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);
}

View file

@ -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;

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 });
};
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<ListenWrap>(
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();
}
}
}

View file

@ -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(

View file

@ -1079,24 +1079,28 @@ base::unique_qptr<Ui::PopupMenu> FillContextMenu(
}
}
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);
}
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);
}
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);

View file

@ -287,7 +287,7 @@ bool SetClickContext(
}
object_ptr<Ui::RpWidget> DetailsFiller::setupInfo() {
auto settings = &AyuSettings::getInstance();
auto settings = &AyuSettings::getInstance();
auto result = object_ptr<Ui::VerticalLayout>(_wrap);
auto tracker = Ui::MultiSlideTracker();

View file

@ -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();

View file

@ -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<AyuUi::ConfirmationBox>(controller);
Ui::show(std::move(box));
});
settings->set_sendReadPackets(prev);
});
addAction(
rpl::single(QString("SRead Messages")),
{&st::settingsIconForward, kIconPurple}
)->setClickedCallback([=]
{
auto box = Box<AyuUi::ConfirmationBox>(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<bool> darkMode) {