mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +02:00
fix: reformat with resharper
This commit is contained in:
parent
ee5ade56d7
commit
f72e7178f5
18 changed files with 425 additions and 366 deletions
|
@ -115,12 +115,13 @@ void SendProgressManager::send(const Key &key, int progress) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// AyuGram sendUploadProgress
|
// AyuGram sendUploadProgress
|
||||||
const auto settings = &AyuSettings::getInstance();
|
const auto settings = &AyuSettings::getInstance();
|
||||||
if (!settings->sendUploadProgress) {
|
if (!settings->sendUploadProgress)
|
||||||
DEBUG_LOG(("[AyuGram] Don't send upload progress"));
|
{
|
||||||
return;
|
DEBUG_LOG(("[AyuGram] Don't send upload progress"));
|
||||||
}
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
using Type = SendProgressType;
|
using Type = SendProgressType;
|
||||||
const auto action = [&]() -> MTPsendMessageAction {
|
const auto action = [&]() -> MTPsendMessageAction {
|
||||||
|
|
|
@ -901,16 +901,17 @@ void Updates::updateOnline(crl::time lastNonIdleTime, bool gotOtherOffline) {
|
||||||
Core::App().checkAutoLock(lastNonIdleTime);
|
Core::App().checkAutoLock(lastNonIdleTime);
|
||||||
});
|
});
|
||||||
|
|
||||||
// AyuGram sendOnlinePackets
|
// AyuGram sendOnlinePackets
|
||||||
const auto settings = &AyuSettings::getInstance();
|
const auto settings = &AyuSettings::getInstance();
|
||||||
const auto &config = _session->serverConfig();
|
const auto& config = _session->serverConfig();
|
||||||
bool isOnlineOrig = Core::App().hasActiveWindow(&session());
|
bool isOnlineOrig = Core::App().hasActiveWindow(&session());
|
||||||
bool isOnline = settings->sendOnlinePackets && isOnlineOrig;
|
bool isOnline = settings->sendOnlinePackets && isOnlineOrig;
|
||||||
|
|
||||||
// AyuGram sendOfflinePacketAfterOnline
|
// AyuGram sendOfflinePacketAfterOnline
|
||||||
if (settings->sendOfflinePacketAfterOnline && _lastWasOnline) {
|
if (settings->sendOfflinePacketAfterOnline && _lastWasOnline)
|
||||||
isOnline = false;
|
{
|
||||||
}
|
isOnline = false;
|
||||||
|
}
|
||||||
|
|
||||||
int updateIn = config.onlineUpdatePeriod;
|
int updateIn = config.onlineUpdatePeriod;
|
||||||
Assert(updateIn >= 0);
|
Assert(updateIn >= 0);
|
||||||
|
@ -965,20 +966,22 @@ void Updates::updateOnline(crl::time lastNonIdleTime, bool gotOtherOffline) {
|
||||||
Assert(updateIn >= 0);
|
Assert(updateIn >= 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
// AyuGram sendOfflinePacketAfterOnline
|
// AyuGram sendOfflinePacketAfterOnline
|
||||||
if (settings->sendOfflinePacketAfterOnline) {
|
if (settings->sendOfflinePacketAfterOnline)
|
||||||
session().api().requestFullPeer(session().user());
|
{
|
||||||
if (session().user()->onlineTill > base::unixtime::now()) {
|
session().api().requestFullPeer(session().user());
|
||||||
DEBUG_LOG(("[AyuGram] User likely appeared online"));
|
if (session().user()->onlineTill > base::unixtime::now())
|
||||||
|
{
|
||||||
|
DEBUG_LOG(("[AyuGram] User likely appeared online"));
|
||||||
|
|
||||||
_onlineRequest = api().request(MTPaccount_UpdateStatus(
|
_onlineRequest = api().request(MTPaccount_UpdateStatus(
|
||||||
MTP_bool(true)
|
MTP_bool(true)
|
||||||
)).send();
|
)).send();
|
||||||
}
|
}
|
||||||
|
|
||||||
DEBUG_LOG(("[AyuGram] Decreasing updateIn because of enabled features"));
|
DEBUG_LOG(("[AyuGram] Decreasing updateIn because of enabled features"));
|
||||||
updateIn = 1250;
|
updateIn = 1250;
|
||||||
}
|
}
|
||||||
|
|
||||||
_onlineTimer.callOnce(updateIn);
|
_onlineTimer.callOnce(updateIn);
|
||||||
}
|
}
|
||||||
|
|
|
@ -3485,13 +3485,14 @@ void ApiWrap::sendUploadedPhoto(
|
||||||
Api::RemoteFileInfo info,
|
Api::RemoteFileInfo info,
|
||||||
Api::SendOptions options) {
|
Api::SendOptions options) {
|
||||||
if (const auto item = _session->data().message(localId)) {
|
if (const auto item = _session->data().message(localId)) {
|
||||||
// AyuGram useScheduledMessages
|
// AyuGram useScheduledMessages
|
||||||
const auto settings = &AyuSettings::getInstance();
|
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();
|
DEBUG_LOG(("[AyuGram] Scheduling message"));
|
||||||
options.scheduled = current + 18; // using 18 seconds because photo can be big
|
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));
|
const auto media = Api::PrepareUploadedPhoto(item, std::move(info));
|
||||||
if (const auto groupId = item->groupId()) {
|
if (const auto groupId = item->groupId()) {
|
||||||
|
@ -3511,13 +3512,14 @@ void ApiWrap::sendUploadedDocument(
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// AyuGram useScheduledMessages
|
// AyuGram useScheduledMessages
|
||||||
const auto settings = &AyuSettings::getInstance();
|
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();
|
DEBUG_LOG(("[AyuGram] Scheduling message"));
|
||||||
options.scheduled = current + 60; // well, a document can be really big...
|
auto current = base::unixtime::now();
|
||||||
}
|
options.scheduled = current + 60; // well, a document can be really big...
|
||||||
|
}
|
||||||
|
|
||||||
const auto media = Api::PrepareUploadedDocument(
|
const auto media = Api::PrepareUploadedDocument(
|
||||||
item,
|
item,
|
||||||
|
@ -3930,13 +3932,14 @@ void ApiWrap::sendMediaWithRandomId(
|
||||||
const MTPInputMedia &media,
|
const MTPInputMedia &media,
|
||||||
Api::SendOptions options,
|
Api::SendOptions options,
|
||||||
uint64 randomId) {
|
uint64 randomId) {
|
||||||
// AyuGram useScheduledMessages
|
// AyuGram useScheduledMessages
|
||||||
const auto settings = &AyuSettings::getInstance();
|
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();
|
DEBUG_LOG(("[AyuGram] Scheduling message"));
|
||||||
options.scheduled = current + 12;
|
auto current = base::unixtime::now();
|
||||||
}
|
options.scheduled = current + 12;
|
||||||
|
}
|
||||||
|
|
||||||
const auto history = item->history();
|
const auto history = item->history();
|
||||||
const auto replyTo = item->replyToId();
|
const auto replyTo = item->replyToId();
|
||||||
|
@ -4031,13 +4034,14 @@ void ApiWrap::sendAlbumIfReady(not_null<SendingAlbum*> album) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// AyuGram useScheduledMessages
|
// AyuGram useScheduledMessages
|
||||||
const auto settings = &AyuSettings::getInstance();
|
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();
|
DEBUG_LOG(("[AyuGram] Scheduling message"));
|
||||||
album->options.scheduled = current + 12;
|
auto current = base::unixtime::now();
|
||||||
}
|
album->options.scheduled = current + 12;
|
||||||
|
}
|
||||||
|
|
||||||
auto sample = (HistoryItem*)nullptr;
|
auto sample = (HistoryItem*)nullptr;
|
||||||
auto medias = QVector<MTPInputSingleMedia>();
|
auto medias = QVector<MTPInputSingleMedia>();
|
||||||
|
|
|
@ -1338,13 +1338,14 @@ bool SendFilesBox::validateLength(const QString &text) const {
|
||||||
void SendFilesBox::send(
|
void SendFilesBox::send(
|
||||||
Api::SendOptions options,
|
Api::SendOptions options,
|
||||||
bool ctrlShiftEnter) {
|
bool ctrlShiftEnter) {
|
||||||
// AyuGram useScheduledMessages
|
// AyuGram useScheduledMessages
|
||||||
const auto settings = &AyuSettings::getInstance();
|
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();
|
DEBUG_LOG(("[AyuGram] Scheduling files"));
|
||||||
options.scheduled = current + 60; // well, files can be really big...
|
auto current = base::unixtime::now();
|
||||||
}
|
options.scheduled = current + 60; // well, files can be really big...
|
||||||
|
}
|
||||||
|
|
||||||
if ((_sendType == Api::SendType::Scheduled
|
if ((_sendType == Api::SendType::Scheduled
|
||||||
|| _sendType == Api::SendType::ScheduledToUser)
|
|| _sendType == Api::SendType::ScheduledToUser)
|
||||||
|
|
|
@ -484,25 +484,28 @@ void GifsListWidget::selectInlineResult(
|
||||||
const auto media = document->activeMediaView();
|
const auto media = document->activeMediaView();
|
||||||
const auto preview = Data::VideoPreviewState(media.get());
|
const auto preview = Data::VideoPreviewState(media.get());
|
||||||
if (forceSend || (media && preview.loaded())) {
|
if (forceSend || (media && preview.loaded())) {
|
||||||
auto settings = &AyuSettings::getInstance();
|
auto settings = &AyuSettings::getInstance();
|
||||||
auto sendGIFCallback = [=, this] {
|
auto sendGIFCallback = [=, this]
|
||||||
_fileChosen.fire({
|
{
|
||||||
.document = document,
|
_fileChosen.fire({
|
||||||
.options = options,
|
.document = document,
|
||||||
.messageSendingFrom = messageSendingFrom(),
|
.options = options,
|
||||||
});
|
.messageSendingFrom = messageSendingFrom(),
|
||||||
};
|
});
|
||||||
|
};
|
||||||
|
|
||||||
if (settings->GIFConfirmation) {
|
if (settings->GIFConfirmation)
|
||||||
Ui::show(Ui::MakeConfirmBox({
|
{
|
||||||
.text = rpl::single(QString("Do you want to send this GIF?")),
|
Ui::show(Ui::MakeConfirmBox({
|
||||||
.confirmed = sendGIFCallback,
|
.text = rpl::single(QString("Do you want to send this GIF?")),
|
||||||
.confirmText = rpl::single(QString("Send")),
|
.confirmed = sendGIFCallback,
|
||||||
}));
|
.confirmText = rpl::single(QString("Send")),
|
||||||
}
|
}));
|
||||||
else {
|
}
|
||||||
sendGIFCallback();
|
else
|
||||||
}
|
{
|
||||||
|
sendGIFCallback();
|
||||||
|
}
|
||||||
} else if (!preview.usingThumbnail()) {
|
} else if (!preview.usingThumbnail()) {
|
||||||
if (preview.loading()) {
|
if (preview.loading()) {
|
||||||
document->cancel();
|
document->cancel();
|
||||||
|
|
|
@ -1710,36 +1710,39 @@ void StickersListWidget::mouseReleaseEvent(QMouseEvent *e) {
|
||||||
if (e->modifiers() & Qt::ControlModifier) {
|
if (e->modifiers() & Qt::ControlModifier) {
|
||||||
showStickerSetBox(document);
|
showStickerSetBox(document);
|
||||||
} else {
|
} else {
|
||||||
auto settings = &AyuSettings::getInstance();
|
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;
|
// it is necessary to store it here, because section & index can be changed by cursor position (guess)
|
||||||
int currentIndex = sticker->index;
|
int currentSection = sticker->section;
|
||||||
auto sendStickerCallback = [=, this] {
|
int currentIndex = sticker->index;
|
||||||
_chosen.fire({
|
auto sendStickerCallback = [=, this]
|
||||||
.document = document,
|
{
|
||||||
.messageSendingFrom = messageSentAnimationInfo(
|
_chosen.fire({
|
||||||
currentSection,
|
.document = document,
|
||||||
currentIndex,
|
.messageSendingFrom = messageSentAnimationInfo(
|
||||||
document),
|
currentSection,
|
||||||
});
|
currentIndex,
|
||||||
};
|
document),
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
Ui::show(Ui::MakeConfirmBox({
|
Ui::show(Ui::MakeConfirmBox({
|
||||||
.text = rpl::single(QString("Do you want to send this sticker?")),
|
.text = rpl::single(QString("Do you want to send this sticker?")),
|
||||||
.confirmed = sendStickerCallback,
|
.confirmed = sendStickerCallback,
|
||||||
.confirmText = rpl::single(QString("Send")),
|
.confirmText = rpl::single(QString("Send")),
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
else {
|
else
|
||||||
_chosen.fire({
|
{
|
||||||
.document = document,
|
_chosen.fire({
|
||||||
.messageSendingFrom = messageSentAnimationInfo(
|
.document = document,
|
||||||
sticker->section,
|
.messageSendingFrom = messageSentAnimationInfo(
|
||||||
sticker->index,
|
sticker->section,
|
||||||
document),
|
sticker->index,
|
||||||
});
|
document),
|
||||||
}
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else if (auto set = std::get_if<OverSet>(&pressed)) {
|
} else if (auto set = std::get_if<OverSet>(&pressed)) {
|
||||||
Assert(set->section >= 0 && set->section < sets.size());
|
Assert(set->section >= 0 && set->section < sets.size());
|
||||||
|
|
|
@ -180,14 +180,15 @@ void Histories::readInboxTill(
|
||||||
|
|
||||||
AyuSync::getInstance().syncRead(history, tillId);
|
AyuSync::getInstance().syncRead(history, tillId);
|
||||||
|
|
||||||
// AyuGram sendReadPackets
|
// AyuGram sendReadPackets
|
||||||
const auto settings = &AyuSettings::getInstance();
|
const auto settings = &AyuSettings::getInstance();
|
||||||
auto allow = settings->sendReadPackets;
|
auto allow = settings->sendReadPackets;
|
||||||
auto reallyAllow = AyuState::getAllowSendPacket(); // will return true if `allow`
|
auto reallyAllow = AyuState::getAllowSendPacket(); // will return true if `allow`
|
||||||
if (!reallyAllow) {
|
if (!reallyAllow)
|
||||||
DEBUG_LOG(("[AyuGram] Don't read messages"));
|
{
|
||||||
return;
|
DEBUG_LOG(("[AyuGram] Don't read messages"));
|
||||||
}
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
const auto needsRequest = history->readInboxTillNeedsRequest(tillId);
|
const auto needsRequest = history->readInboxTillNeedsRequest(tillId);
|
||||||
if (!needsRequest && !force) {
|
if (!needsRequest && !force) {
|
||||||
|
@ -210,8 +211,9 @@ void Histories::readInboxTill(
|
||||||
sendPendingReadInbox(history);
|
sendPendingReadInbox(history);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
} else if (!needsRequest && (allow != reallyAllow && !force)
|
} else if (!needsRequest && (allow != reallyAllow && !force)
|
||||||
&& (!maybeState || !maybeState->willReadTill)) {
|
&& (!maybeState || !maybeState->willReadTill))
|
||||||
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const auto stillUnread = history->countStillUnreadLocal(tillId);
|
const auto stillUnread = history->countStillUnreadLocal(tillId);
|
||||||
|
|
|
@ -2164,99 +2164,115 @@ void Session::updateEditedMessage(const MTPMessage &data) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// AyuGram keepMessagesHistory
|
// AyuGram keepMessagesHistory
|
||||||
const auto settings = &AyuSettings::getInstance();
|
const auto settings = &AyuSettings::getInstance();
|
||||||
HistoryMessageEdition edit;
|
HistoryMessageEdition edit;
|
||||||
|
|
||||||
if (data.type() != mtpc_message) {
|
if (data.type() != mtpc_message)
|
||||||
goto proceed;
|
{
|
||||||
}
|
goto proceed;
|
||||||
edit = HistoryMessageEdition(_session, data.c_message());
|
}
|
||||||
if (settings->keepMessagesHistory && !existing->isLocal() && !existing->author()->isSelf() && !edit.isEditHide) {
|
edit = HistoryMessageEdition(_session, data.c_message());
|
||||||
const auto history = existing->history();
|
if (settings->keepMessagesHistory && !existing->isLocal() && !existing->author()->isSelf() && !edit.isEditHide)
|
||||||
const auto msg = existing->originalText();
|
{
|
||||||
|
const auto history = existing->history();
|
||||||
|
const auto msg = existing->originalText();
|
||||||
|
|
||||||
const auto media = existing->media();
|
const auto media = existing->media();
|
||||||
|
|
||||||
if (edit.textWithEntities == msg) {
|
if (edit.textWithEntities == msg)
|
||||||
// check if media changed
|
{
|
||||||
|
// check if media changed
|
||||||
|
|
||||||
if (!edit.mtpMedia) {
|
if (!edit.mtpMedia)
|
||||||
goto proceed;
|
{
|
||||||
}
|
goto proceed;
|
||||||
|
}
|
||||||
|
|
||||||
if (edit.mtpMedia->type() == mtpc_messageMediaPhoto
|
if (edit.mtpMedia->type() == mtpc_messageMediaPhoto
|
||||||
&& media->photo()
|
&& 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()
|
||||||
goto proceed;
|
.c_inputPhoto().vaccess_hash())
|
||||||
}
|
{
|
||||||
|
goto proceed;
|
||||||
|
}
|
||||||
|
|
||||||
if (edit.mtpMedia->type() == mtpc_messageMediaDocument
|
if (edit.mtpMedia->type() == mtpc_messageMediaDocument
|
||||||
&& media->document()
|
&& 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()
|
||||||
goto proceed;
|
->mtpInput().c_inputDocument().vaccess_hash())
|
||||||
}
|
{
|
||||||
}
|
goto proceed;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
auto flags = MessageFlag::HasFromId
|
auto flags = MessageFlag::HasFromId
|
||||||
| MessageFlag::HasReplyInfo
|
| MessageFlag::HasReplyInfo
|
||||||
| MessageFlag::HasPostAuthor;
|
| MessageFlag::HasPostAuthor;
|
||||||
|
|
||||||
if (existing->isPost()) {
|
if (existing->isPost())
|
||||||
flags |= MessageFlag::Post;
|
{
|
||||||
}
|
flags |= MessageFlag::Post;
|
||||||
|
}
|
||||||
|
|
||||||
// adding msg data to local ayu db (table:editedMessage)
|
// adding msg data to local ayu db (table:editedMessage)
|
||||||
auto userId = existing->displayFrom()->id.value;
|
auto userId = existing->displayFrom()->id.value;
|
||||||
auto dialogId = history->peer->id.value;
|
auto dialogId = history->peer->id.value;
|
||||||
auto msgId = existing->id.bare;
|
auto msgId = existing->id.bare;
|
||||||
bool isDocument = media && media->document();
|
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())) {
|
if (!media || !(media->photo() || media->document()))
|
||||||
// history->addNewLocalMessage(
|
{
|
||||||
// history->nextNonHistoryEntryId(),
|
// history->addNewLocalMessage(
|
||||||
// flags,
|
// history->nextNonHistoryEntryId(),
|
||||||
// UserId(),
|
// flags,
|
||||||
// existing->id,
|
// UserId(),
|
||||||
// base::unixtime::now(),
|
// existing->id,
|
||||||
// existing->author()->id,
|
// base::unixtime::now(),
|
||||||
// "AyuGram"_q,
|
// existing->author()->id,
|
||||||
// msg,
|
// "AyuGram"_q,
|
||||||
// MTP_messageMediaEmpty(),
|
// msg,
|
||||||
// HistoryMessageMarkupData(),
|
// MTP_messageMediaEmpty(),
|
||||||
// existing->groupId().empty() ? 0 : existing->groupId().value);
|
// HistoryMessageMarkupData(),
|
||||||
} else {
|
// existing->groupId().empty() ? 0 : existing->groupId().value);
|
||||||
if (media->photo()) {
|
}
|
||||||
// history->addNewLocalMessage(
|
else
|
||||||
// history->nextNonHistoryEntryId(),
|
{
|
||||||
// flags,
|
if (media->photo())
|
||||||
// UserId(),
|
{
|
||||||
// existing->id,
|
// history->addNewLocalMessage(
|
||||||
// base::unixtime::now(),
|
// history->nextNonHistoryEntryId(),
|
||||||
// existing->author()->id,
|
// flags,
|
||||||
// "AyuGram"_q,
|
// UserId(),
|
||||||
// media->photo(),
|
// existing->id,
|
||||||
// existing->originalText(),
|
// base::unixtime::now(),
|
||||||
// HistoryMessageMarkupData());
|
// existing->author()->id,
|
||||||
} else if (media->document()) {
|
// "AyuGram"_q,
|
||||||
// history->addNewLocalMessage(
|
// media->photo(),
|
||||||
// history->nextNonHistoryEntryId(),
|
// existing->originalText(),
|
||||||
// flags,
|
// HistoryMessageMarkupData());
|
||||||
// UserId(),
|
}
|
||||||
// existing->id,
|
else if (media->document())
|
||||||
// base::unixtime::now(),
|
{
|
||||||
// existing->author()->id,
|
// history->addNewLocalMessage(
|
||||||
// "AyuGram"_q,
|
// history->nextNonHistoryEntryId(),
|
||||||
// media->document(),
|
// flags,
|
||||||
// existing->originalText(),
|
// UserId(),
|
||||||
// HistoryMessageMarkupData());
|
// existing->id,
|
||||||
}
|
// base::unixtime::now(),
|
||||||
}
|
// existing->author()->id,
|
||||||
}
|
// "AyuGram"_q,
|
||||||
|
// media->document(),
|
||||||
|
// existing->originalText(),
|
||||||
|
// HistoryMessageMarkupData());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
proceed:
|
proceed:
|
||||||
|
|
||||||
if (existing->isLocalUpdateMedia() && data.type() == mtpc_message) {
|
if (existing->isLocalUpdateMedia() && data.type() == mtpc_message) {
|
||||||
updateExistingMessage(data.c_message());
|
updateExistingMessage(data.c_message());
|
||||||
|
|
|
@ -177,7 +177,7 @@ void SponsoredMessages::inject(
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SponsoredMessages::canHaveFor(not_null<History*> history) const {
|
bool SponsoredMessages::canHaveFor(not_null<History*> history) const {
|
||||||
auto settings = &AyuSettings::getInstance();
|
auto settings = &AyuSettings::getInstance();
|
||||||
return settings->enableAds && history->peer->isChannel();
|
return settings->enableAds && history->peer->isChannel();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -479,48 +479,53 @@ not_null<HistoryItem*> History::insertItem(
|
||||||
void History::destroyMessage(not_null<HistoryItem*> item) {
|
void History::destroyMessage(not_null<HistoryItem*> item) {
|
||||||
Expects(item->isHistoryEntry() || !item->mainView());
|
Expects(item->isHistoryEntry() || !item->mainView());
|
||||||
|
|
||||||
// AyuGram keepDeletedMessages
|
// AyuGram keepDeletedMessages
|
||||||
const auto settings = &AyuSettings::getInstance();
|
const auto settings = &AyuSettings::getInstance();
|
||||||
if (settings->keepDeletedMessages && item->isRegular() && !item->isGroupMigrate()) {
|
if (settings->keepDeletedMessages && item->isRegular() && !item->isGroupMigrate())
|
||||||
if (!item->isService()) {
|
{
|
||||||
item->setPostAuthor(settings->deletedMark);
|
if (!item->isService())
|
||||||
} else {
|
{
|
||||||
const auto msg = TextWithEntities{
|
item->setPostAuthor(settings->deletedMark);
|
||||||
"Message deleted",
|
}
|
||||||
{
|
else
|
||||||
EntityInText(
|
{
|
||||||
EntityType::Italic,
|
const auto msg = TextWithEntities{
|
||||||
0,
|
"Message deleted",
|
||||||
15,
|
{
|
||||||
"Message deleted"
|
EntityInText(
|
||||||
)
|
EntityType::Italic,
|
||||||
}
|
0,
|
||||||
};
|
15,
|
||||||
|
"Message deleted"
|
||||||
|
)
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
auto flags = MessageFlag::HasFromId
|
auto flags = MessageFlag::HasFromId
|
||||||
| MessageFlag::HasReplyInfo
|
| MessageFlag::HasReplyInfo
|
||||||
| MessageFlag::HasPostAuthor;
|
| MessageFlag::HasPostAuthor;
|
||||||
|
|
||||||
if (item->isPost()) {
|
if (item->isPost())
|
||||||
flags |= MessageFlag::Post;
|
{
|
||||||
}
|
flags |= MessageFlag::Post;
|
||||||
|
}
|
||||||
|
|
||||||
addNewLocalMessage(
|
addNewLocalMessage(
|
||||||
session().data().nextLocalMessageId(),
|
session().data().nextLocalMessageId(),
|
||||||
flags,
|
flags,
|
||||||
UserId(),
|
UserId(),
|
||||||
item->id,
|
item->id,
|
||||||
base::unixtime::now(),
|
base::unixtime::now(),
|
||||||
item->author()->id,
|
item->author()->id,
|
||||||
"AyuGram"_q,
|
"AyuGram"_q,
|
||||||
msg,
|
msg,
|
||||||
MTP_messageMediaEmpty(),
|
MTP_messageMediaEmpty(),
|
||||||
HistoryMessageMarkupData(),
|
HistoryMessageMarkupData(),
|
||||||
uint64(0));
|
uint64(0));
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const auto peerId = peer->id;
|
const auto peerId = peer->id;
|
||||||
if (item->isHistoryEntry()) {
|
if (item->isHistoryEntry()) {
|
||||||
|
|
|
@ -2388,10 +2388,11 @@ void HistoryItem::setForwardsCount(int count) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void HistoryItem::setPostAuthor(const QString &author) {
|
void HistoryItem::setPostAuthor(const QString &author) {
|
||||||
const auto settings = &AyuSettings::getInstance();
|
const auto settings = &AyuSettings::getInstance();
|
||||||
if (settings->keepDeletedMessages && !(_flags & MessageFlag::HasPostAuthor)) {
|
if (settings->keepDeletedMessages && !(_flags & MessageFlag::HasPostAuthor))
|
||||||
_flags |= MessageFlag::HasPostAuthor;
|
{
|
||||||
}
|
_flags |= MessageFlag::HasPostAuthor;
|
||||||
|
}
|
||||||
|
|
||||||
auto msgsigned = Get<HistoryMessageSigned>();
|
auto msgsigned = Get<HistoryMessageSigned>();
|
||||||
if (author.isEmpty()) {
|
if (author.isEmpty()) {
|
||||||
|
@ -2412,9 +2413,10 @@ void HistoryItem::setPostAuthor(const QString &author) {
|
||||||
msgsigned->isAnonymousRank = !isDiscussionPost()
|
msgsigned->isAnonymousRank = !isDiscussionPost()
|
||||||
&& this->author()->isMegagroup();
|
&& this->author()->isMegagroup();
|
||||||
|
|
||||||
if (settings->keepDeletedMessages) {
|
if (settings->keepDeletedMessages)
|
||||||
history()->owner().requestItemViewRefresh(this);
|
{
|
||||||
}
|
history()->owner().requestItemViewRefresh(this);
|
||||||
|
}
|
||||||
|
|
||||||
history()->owner().requestItemResize(this);
|
history()->owner().requestItemResize(this);
|
||||||
}
|
}
|
||||||
|
|
|
@ -3866,18 +3866,20 @@ Api::SendAction HistoryWidget::prepareSendAction(
|
||||||
}
|
}
|
||||||
|
|
||||||
void HistoryWidget::send(Api::SendOptions options) {
|
void HistoryWidget::send(Api::SendOptions options) {
|
||||||
// AyuGram useScheduledMessages
|
// AyuGram useScheduledMessages
|
||||||
const auto settings = &AyuSettings::getInstance();
|
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();
|
DEBUG_LOG(("[AyuGram] Scheduling message"));
|
||||||
options.scheduled = current + 12;
|
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());
|
AyuState::setAllowSendReadPacket(true);
|
||||||
}
|
_history->session().data().histories().readInboxOnNewMessage(_history->lastMessage());
|
||||||
|
}
|
||||||
|
|
||||||
if (!_history) {
|
if (!_history) {
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -1431,24 +1431,27 @@ void VoiceRecordBar::stopRecording(StopType type) {
|
||||||
window()->raise();
|
window()->raise();
|
||||||
window()->activateWindow();
|
window()->activateWindow();
|
||||||
const auto duration = Duration(data.samples);
|
const auto duration = Duration(data.samples);
|
||||||
auto settings = &AyuSettings::getInstance();
|
|
||||||
|
|
||||||
if (type == StopType::Send) {
|
auto settings = &AyuSettings::getInstance();
|
||||||
auto sendVoiceCallback = [=, this] {
|
if (type == StopType::Send)
|
||||||
_sendVoiceRequests.fire({ data.bytes, data.waveform, duration });
|
{
|
||||||
};
|
auto sendVoiceCallback = [=, this]
|
||||||
|
{
|
||||||
if (settings->voiceConfirmation) {
|
_sendVoiceRequests.fire({data.bytes, data.waveform, duration});
|
||||||
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();
|
||||||
|
}
|
||||||
} else if (type == StopType::Listen) {
|
} else if (type == StopType::Listen) {
|
||||||
_listen = std::make_unique<ListenWrap>(
|
_listen = std::make_unique<ListenWrap>(
|
||||||
this,
|
this,
|
||||||
|
@ -1521,27 +1524,30 @@ void VoiceRecordBar::drawMessage(Painter &p, float64 recordActive) {
|
||||||
void VoiceRecordBar::requestToSendWithOptions(Api::SendOptions options) {
|
void VoiceRecordBar::requestToSendWithOptions(Api::SendOptions options) {
|
||||||
if (isListenState()) {
|
if (isListenState()) {
|
||||||
const auto data = _listen->data();
|
const auto data = _listen->data();
|
||||||
auto settings = &AyuSettings::getInstance();
|
auto settings = &AyuSettings::getInstance();
|
||||||
|
|
||||||
auto sendVoiceCallback = [=, this] {
|
auto sendVoiceCallback = [=, this]
|
||||||
_sendVoiceRequests.fire({
|
{
|
||||||
data->bytes,
|
_sendVoiceRequests.fire({
|
||||||
data->waveform,
|
data->bytes,
|
||||||
Duration(data->samples),
|
data->waveform,
|
||||||
options
|
Duration(data->samples),
|
||||||
});
|
options
|
||||||
};
|
});
|
||||||
|
};
|
||||||
|
|
||||||
if (settings->voiceConfirmation) {
|
if (settings->voiceConfirmation)
|
||||||
Ui::show(AyuUi::MakeConfirmBox({
|
{
|
||||||
.text = rpl::single(QString("Do you want to send voice message?")),
|
Ui::show(AyuUi::MakeConfirmBox({
|
||||||
.confirmed = sendVoiceCallback,
|
.text = rpl::single(QString("Do you want to send voice message?")),
|
||||||
.confirmText = rpl::single(QString("Send"))
|
.confirmed = sendVoiceCallback,
|
||||||
}));
|
.confirmText = rpl::single(QString("Send"))
|
||||||
}
|
}));
|
||||||
else {
|
}
|
||||||
sendVoiceCallback();
|
else
|
||||||
}
|
{
|
||||||
|
sendVoiceCallback();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -463,11 +463,11 @@ void BottomInfo::layout() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void BottomInfo::layoutDateText() {
|
void BottomInfo::layoutDateText() {
|
||||||
const auto settings = &AyuSettings::getInstance();
|
const auto settings = &AyuSettings::getInstance();
|
||||||
|
|
||||||
const auto edited = (_data.flags & Data::Flag::Edited)
|
const auto edited = (_data.flags & Data::Flag::Edited)
|
||||||
? (settings->editedMark + ' ')
|
? (settings->editedMark + ' ')
|
||||||
: QString();
|
: QString();
|
||||||
const auto author = _data.author;
|
const auto author = _data.author;
|
||||||
const auto prefix = !author.isEmpty() ? (author == settings->deletedMark ? u" "_q : u", "_q) : QString();
|
const auto prefix = !author.isEmpty() ? (author == settings->deletedMark ? u" "_q : u", "_q) : QString();
|
||||||
const auto date = edited + QLocale().toString(
|
const auto date = edited + QLocale().toString(
|
||||||
|
|
|
@ -1079,24 +1079,28 @@ base::unique_qptr<Ui::PopupMenu> FillContextMenu(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (item != nullptr) {
|
if (item != nullptr)
|
||||||
if (AyuDatabase::editedMessagesTableExists() && !((AyuDatabase::getEditedMessages(item)).empty())) {
|
{
|
||||||
result->addAction(QString("History"), [=] {
|
if (AyuDatabase::editedMessagesTableExists() && !((AyuDatabase::getEditedMessages(item)).empty()))
|
||||||
auto box = Box<AyuUi::MessageHistoryBox>(item);
|
{
|
||||||
Ui::show(std::move(box));
|
result->addAction(QString("History"), [=]
|
||||||
}, &st::menuIconInfo);
|
{
|
||||||
}
|
auto box = Box<AyuUi::MessageHistoryBox>(item);
|
||||||
|
Ui::show(std::move(box));
|
||||||
|
}, &st::menuIconInfo);
|
||||||
|
}
|
||||||
|
|
||||||
const auto settings = &AyuSettings::getInstance();
|
const auto settings = &AyuSettings::getInstance();
|
||||||
const auto history = item->history();
|
const auto history = item->history();
|
||||||
result->addAction(QString("Hide"), [=]() {
|
result->addAction(QString("Hide"), [=]()
|
||||||
const auto initKeepDeleted = settings->keepDeletedMessages;
|
{
|
||||||
|
const auto initKeepDeleted = settings->keepDeletedMessages;
|
||||||
|
|
||||||
settings->set_keepDeletedMessages(false);
|
settings->set_keepDeletedMessages(false);
|
||||||
history->destroyMessage(item);
|
history->destroyMessage(item);
|
||||||
settings->set_keepDeletedMessages(initKeepDeleted);
|
settings->set_keepDeletedMessages(initKeepDeleted);
|
||||||
}, &st::menuIconClear);
|
}, &st::menuIconClear);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!view || !list->hasCopyRestriction(view->data())) {
|
if (!view || !list->hasCopyRestriction(view->data())) {
|
||||||
AddCopyLinkAction(result, link);
|
AddCopyLinkAction(result, link);
|
||||||
|
|
|
@ -287,7 +287,7 @@ bool SetClickContext(
|
||||||
}
|
}
|
||||||
|
|
||||||
object_ptr<Ui::RpWidget> DetailsFiller::setupInfo() {
|
object_ptr<Ui::RpWidget> DetailsFiller::setupInfo() {
|
||||||
auto settings = &AyuSettings::getInstance();
|
auto settings = &AyuSettings::getInstance();
|
||||||
|
|
||||||
auto result = object_ptr<Ui::VerticalLayout>(_wrap);
|
auto result = object_ptr<Ui::VerticalLayout>(_wrap);
|
||||||
auto tracker = Ui::MultiSlideTracker();
|
auto tracker = Ui::MultiSlideTracker();
|
||||||
|
|
|
@ -90,32 +90,35 @@ void Tray::rebuildMenu() {
|
||||||
[=] { toggleSoundNotifications(); });
|
[=] { toggleSoundNotifications(); });
|
||||||
}
|
}
|
||||||
|
|
||||||
auto turnGhostModeText = _textUpdates.events(
|
auto turnGhostModeText = _textUpdates.events(
|
||||||
) | rpl::map([=] {
|
) | rpl::map([=]
|
||||||
bool ghostModeEnabled = AyuSettings::get_ghostModeEnabled();
|
{
|
||||||
|
bool ghostModeEnabled = AyuSettings::get_ghostModeEnabled();
|
||||||
|
|
||||||
return ghostModeEnabled
|
return ghostModeEnabled
|
||||||
? tr::ayu_DisableGhostMode(tr::now)
|
? tr::ayu_DisableGhostMode(tr::now)
|
||||||
: tr::ayu_EnableGhostMode(tr::now);
|
: tr::ayu_EnableGhostMode(tr::now);
|
||||||
});
|
});
|
||||||
|
|
||||||
_tray.addAction(std::move(turnGhostModeText), [=] {
|
_tray.addAction(std::move(turnGhostModeText), [=]
|
||||||
auto settings = &AyuSettings::getInstance();
|
{
|
||||||
bool ghostMode = !AyuSettings::get_ghostModeEnabled();
|
auto settings = &AyuSettings::getInstance();
|
||||||
|
bool ghostMode = !AyuSettings::get_ghostModeEnabled();
|
||||||
|
|
||||||
settings->set_sendReadPackets(!ghostMode);
|
settings->set_sendReadPackets(!ghostMode);
|
||||||
settings->set_sendOnlinePackets(!ghostMode);
|
settings->set_sendOnlinePackets(!ghostMode);
|
||||||
settings->set_sendUploadProgress(!ghostMode);
|
settings->set_sendUploadProgress(!ghostMode);
|
||||||
|
|
||||||
settings->set_sendOfflinePacketAfterOnline(ghostMode);
|
settings->set_sendOfflinePacketAfterOnline(ghostMode);
|
||||||
|
|
||||||
AyuSettings::save();
|
AyuSettings::save();
|
||||||
});
|
});
|
||||||
|
|
||||||
auto quitText = _textUpdates.events(
|
auto quitText = _textUpdates.events(
|
||||||
) | rpl::map([=] {
|
) | rpl::map([=]
|
||||||
return tr::lng_quit_from_tray(tr::now).replace("Telegram", "AyuGram");
|
{
|
||||||
});
|
return tr::lng_quit_from_tray(tr::now).replace("Telegram", "AyuGram");
|
||||||
|
});
|
||||||
_tray.addAction(std::move(quitText), [] { Core::Quit(); });
|
_tray.addAction(std::move(quitText), [] { Core::Quit(); });
|
||||||
|
|
||||||
updateMenuText();
|
updateMenuText();
|
||||||
|
|
|
@ -765,26 +765,28 @@ void MainMenu::setupMenu() {
|
||||||
)->setClickedCallback([=] {
|
)->setClickedCallback([=] {
|
||||||
controller->showPeerHistory(controller->session().user());
|
controller->showPeerHistory(controller->session().user());
|
||||||
});
|
});
|
||||||
addAction(
|
addAction(
|
||||||
rpl::single(QString("LRead Messages")),
|
rpl::single(QString("LRead Messages")),
|
||||||
{ &st::settingsIconForward, kIconPurple }
|
{&st::settingsIconForward, kIconPurple}
|
||||||
)->setClickedCallback([=] {
|
)->setClickedCallback([=]
|
||||||
auto settings = &AyuSettings::getInstance();
|
{
|
||||||
auto prev = settings->sendReadPackets;
|
auto settings = &AyuSettings::getInstance();
|
||||||
settings->set_sendReadPackets(false);
|
auto prev = settings->sendReadPackets;
|
||||||
|
settings->set_sendReadPackets(false);
|
||||||
|
|
||||||
auto chats = controller->session().data().chatsList();
|
auto chats = controller->session().data().chatsList();
|
||||||
MarkAsReadChatListHack(chats);
|
MarkAsReadChatListHack(chats);
|
||||||
|
|
||||||
settings->set_sendReadPackets(prev);
|
settings->set_sendReadPackets(prev);
|
||||||
});
|
});
|
||||||
addAction(
|
addAction(
|
||||||
rpl::single(QString("SRead Messages")),
|
rpl::single(QString("SRead Messages")),
|
||||||
{ &st::settingsIconForward, kIconPurple }
|
{&st::settingsIconForward, kIconPurple}
|
||||||
)->setClickedCallback([=] {
|
)->setClickedCallback([=]
|
||||||
auto box = Box<AyuUi::ConfirmationBox>(controller);
|
{
|
||||||
Ui::show(std::move(box));
|
auto box = Box<AyuUi::ConfirmationBox>(controller);
|
||||||
});
|
Ui::show(std::move(box));
|
||||||
|
});
|
||||||
} else {
|
} else {
|
||||||
addAction(
|
addAction(
|
||||||
tr::lng_profile_add_contact(),
|
tr::lng_profile_add_contact(),
|
||||||
|
@ -846,24 +848,26 @@ void MainMenu::setupMenu() {
|
||||||
toggle);
|
toggle);
|
||||||
}, _nightThemeToggle->lifetime());
|
}, _nightThemeToggle->lifetime());
|
||||||
|
|
||||||
const auto settings = &AyuSettings::getInstance();
|
const auto settings = &AyuSettings::getInstance();
|
||||||
if (settings->showGhostToggleInDrawer) {
|
if (settings->showGhostToggleInDrawer)
|
||||||
_ghostModeToggle = addAction(
|
{
|
||||||
tr::ayu_DrawerGhostModeToggle(),
|
_ghostModeToggle = addAction(
|
||||||
{&st::ayuGhostIcon, kIconPurple}
|
tr::ayu_DrawerGhostModeToggle(),
|
||||||
)->toggleOn(AyuSettings::get_ghostModeEnabledReactive());
|
{&st::ayuGhostIcon, kIconPurple}
|
||||||
|
)->toggleOn(AyuSettings::get_ghostModeEnabledReactive());
|
||||||
|
|
||||||
_ghostModeToggle->toggledChanges(
|
_ghostModeToggle->toggledChanges(
|
||||||
) | rpl::start_with_next([=](bool ghostMode) {
|
) | rpl::start_with_next([=](bool ghostMode)
|
||||||
settings->set_sendReadPackets(!ghostMode);
|
{
|
||||||
settings->set_sendOnlinePackets(!ghostMode);
|
settings->set_sendReadPackets(!ghostMode);
|
||||||
settings->set_sendUploadProgress(!ghostMode);
|
settings->set_sendOnlinePackets(!ghostMode);
|
||||||
|
settings->set_sendUploadProgress(!ghostMode);
|
||||||
|
|
||||||
settings->set_sendOfflinePacketAfterOnline(ghostMode);
|
settings->set_sendOfflinePacketAfterOnline(ghostMode);
|
||||||
|
|
||||||
AyuSettings::save();
|
AyuSettings::save();
|
||||||
}, _ghostModeToggle->lifetime());
|
}, _ghostModeToggle->lifetime());
|
||||||
}
|
}
|
||||||
|
|
||||||
Core::App().settings().systemDarkModeValue(
|
Core::App().settings().systemDarkModeValue(
|
||||||
) | rpl::start_with_next([=](std::optional<bool> darkMode) {
|
) | rpl::start_with_next([=](std::optional<bool> darkMode) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue