chore: sync database schema & refactor & reformat

This commit is contained in:
ZavaruKitsu 2024-02-04 20:41:21 +03:00
parent adb5abf4fb
commit d4a22a5110
49 changed files with 601 additions and 549 deletions

View file

@ -116,8 +116,8 @@ PRIVATE
ayu/utils/telegram_helpers.h ayu/utils/telegram_helpers.h
ayu/utils/windows_utils.cpp ayu/utils/windows_utils.cpp
ayu/utils/windows_utils.h ayu/utils/windows_utils.h
ayu/ui/ayu_assets.cpp ayu/ui/ayu_logo.cpp
ayu/ui/ayu_assets.h ayu/ui/ayu_logo.h
ayu/ui/utils/ayu_profile_values.cpp ayu/ui/utils/ayu_profile_values.cpp
ayu/ui/utils/ayu_profile_values.h ayu/ui/utils/ayu_profile_values.h
ayu/ui/settings/icon_picker.cpp ayu/ui/settings/icon_picker.cpp
@ -148,8 +148,6 @@ PRIVATE
ayu/ui/boxes/message_shot_box.h ayu/ui/boxes/message_shot_box.h
ayu/ui/components/image_view.cpp ayu/ui/components/image_view.cpp
ayu/ui/components/image_view.h ayu/ui/components/image_view.h
ayu/messages/ayu_messages_controller.cpp
ayu/messages/ayu_messages_controller.h
ayu/libs/json.hpp ayu/libs/json.hpp
ayu/libs/json_ext.hpp ayu/libs/json_ext.hpp
ayu/libs/sqlite/sqlite3.c ayu/libs/sqlite/sqlite3.c
@ -160,9 +158,11 @@ PRIVATE
ayu/features/streamer_mode/streamer_mode.h ayu/features/streamer_mode/streamer_mode.h
ayu/features/messageshot/message_shot.cpp ayu/features/messageshot/message_shot.cpp
ayu/features/messageshot/message_shot.h ayu/features/messageshot/message_shot.h
ayu/database/entities.h ayu/data/messages_storage.cpp
ayu/database/ayu_database.cpp ayu/data/messages_storage.h
ayu/database/ayu_database.h ayu/data/entities.h
ayu/data/ayu_database.cpp
ayu/data/ayu_database.h
api/api_attached_stickers.cpp api/api_attached_stickers.cpp
api/api_attached_stickers.h api/api_attached_stickers.h

View file

@ -9,7 +9,7 @@
#include "ayu_lang.h" #include "ayu_lang.h"
#include "ayu_worker.h" #include "ayu_worker.h"
#include "ayu/ayu_settings.h" #include "ayu/ayu_settings.h"
#include "ayu/database/ayu_database.h" #include "ayu/data/ayu_database.h"
#include "lang/lang_instance.h" #include "lang/lang_instance.h"
namespace AyuInfra { namespace AyuInfra {

View file

@ -6,7 +6,7 @@
// Copyright @Radolyn, 2023 // Copyright @Radolyn, 2023
#include "ayu_settings.h" #include "ayu_settings.h"
#include "ayu/ui/ayu_assets.h" #include "ayu/ui/ayu_logo.h"
#include "lang_auto.h" #include "lang_auto.h"
#include "core/application.h" #include "core/application.h"

View file

@ -14,7 +14,7 @@ void hide(PeerId peerId, MsgId messageId) {
hiddenMessages[peerId].insert(messageId); hiddenMessages[peerId].insert(messageId);
} }
void hide(not_null<HistoryItem *> item) { void hide(not_null<HistoryItem*> item) {
hide(item->history()->peer->id, item->id); hide(item->history()->peer->id, item->id);
} }
@ -26,7 +26,7 @@ bool isHidden(PeerId peerId, MsgId messageId) {
return false; return false;
} }
bool isHidden(not_null<HistoryItem *> item) { bool isHidden(not_null<HistoryItem*> item) {
return isHidden(item->history()->peer->id, item->id); return isHidden(item->history()->peer->id, item->id);
} }

View file

@ -12,8 +12,8 @@
namespace AyuState { namespace AyuState {
void hide(PeerId peerId, MsgId messageId); void hide(PeerId peerId, MsgId messageId);
void hide(not_null<HistoryItem *> item); void hide(not_null<HistoryItem*> item);
bool isHidden(PeerId peerId, MsgId messageId); bool isHidden(PeerId peerId, MsgId messageId);
bool isHidden(not_null<HistoryItem *> item); bool isHidden(not_null<HistoryItem*> item);
} }

View file

@ -11,7 +11,7 @@
#include "base/unixtime.h" #include "base/unixtime.h"
#include "core/application.h" #include "core/application.h"
#include "data/data_user.h" #include "data/data_user.h"
#include "database/entities.h" #include "data/entities.h"
#include "main/main_account.h" #include "main/main_account.h"
#include "main/main_domain.h" #include "main/main_domain.h"
#include "main/main_session.h" #include "main/main_session.h"
@ -20,7 +20,7 @@ namespace AyuWorker {
std::unordered_map<ID, bool> state; std::unordered_map<ID, bool> state;
void markAsOnline(not_null<Main::Session *> session) { void markAsOnline(not_null<Main::Session*> session) {
state[session->userId().bare] = true; state[session->userId().bare] = true;
} }

View file

@ -10,7 +10,7 @@
namespace AyuWorker { namespace AyuWorker {
void markAsOnline(not_null<Main::Session *> session); void markAsOnline(not_null<Main::Session*> session);
void initialize(); void initialize();
} }

View file

@ -0,0 +1,210 @@
// This is the source code of AyuGram for Desktop.
//
// We do not and cannot prevent the use of our code,
// but be respectful and credit the original author.
//
// Copyright @Radolyn, 2023
#include "ayu_database.h"
#include <ranges>
#include "entities.h"
#include "ayu/libs/sqlite/sqlite_orm.h"
#include "base/unixtime.h"
using namespace sqlite_orm;
auto storage = make_storage(
"./tdata/ayudata.db",
make_table(
"DeletedMessage",
make_column("fakeId", &DeletedMessage::fakeId, primary_key().autoincrement()),
make_column("userId", &DeletedMessage::userId),
make_column("dialogId", &DeletedMessage::dialogId),
make_column("groupedId", &DeletedMessage::groupedId),
make_column("peerId", &DeletedMessage::peerId),
make_column("fromId", &DeletedMessage::fromId),
make_column("topicId", &DeletedMessage::topicId),
make_column("messageId", &DeletedMessage::messageId),
make_column("date", &DeletedMessage::date),
make_column("flags", &DeletedMessage::flags),
make_column("editDate", &DeletedMessage::editDate),
make_column("views", &DeletedMessage::views),
make_column("fwdFlags", &DeletedMessage::fwdFlags),
make_column("fwdFromId", &DeletedMessage::fwdFromId),
make_column("fwdName", &DeletedMessage::fwdName),
make_column("fwdDate", &DeletedMessage::fwdDate),
make_column("fwdPostAuthor", &DeletedMessage::fwdPostAuthor),
make_column("replyFlags", &DeletedMessage::replyFlags),
make_column("replyMessageId", &DeletedMessage::replyMessageId),
make_column("replyPeerId", &DeletedMessage::replyPeerId),
make_column("replyTopId", &DeletedMessage::replyTopId),
make_column("replyForumTopic", &DeletedMessage::replyForumTopic),
make_column("replySerialized", &DeletedMessage::replySerialized),
make_column("entityCreateDate", &DeletedMessage::entityCreateDate),
make_column("text", &DeletedMessage::text),
make_column("textEntities", &DeletedMessage::textEntities),
make_column("mediaPath", &DeletedMessage::mediaPath),
make_column("hqThumbPath", &DeletedMessage::hqThumbPath),
make_column("documentType", &DeletedMessage::documentType),
make_column("documentSerialized", &DeletedMessage::documentSerialized),
make_column("thumbsSerialized", &DeletedMessage::thumbsSerialized),
make_column("documentAttributesSerialized", &DeletedMessage::documentAttributesSerialized),
make_column("mimeType", &DeletedMessage::mimeType)
),
make_table(
"EditedMessage",
make_column("fakeId", &EditedMessage::fakeId, primary_key().autoincrement()),
make_column("userId", &EditedMessage::userId),
make_column("dialogId", &EditedMessage::dialogId),
make_column("groupedId", &EditedMessage::groupedId),
make_column("peerId", &EditedMessage::peerId),
make_column("fromId", &EditedMessage::fromId),
make_column("topicId", &EditedMessage::topicId),
make_column("messageId", &EditedMessage::messageId),
make_column("date", &EditedMessage::date),
make_column("flags", &EditedMessage::flags),
make_column("editDate", &EditedMessage::editDate),
make_column("views", &EditedMessage::views),
make_column("fwdFlags", &EditedMessage::fwdFlags),
make_column("fwdFromId", &EditedMessage::fwdFromId),
make_column("fwdName", &EditedMessage::fwdName),
make_column("fwdDate", &EditedMessage::fwdDate),
make_column("fwdPostAuthor", &EditedMessage::fwdPostAuthor),
make_column("replyFlags", &EditedMessage::replyFlags),
make_column("replyMessageId", &EditedMessage::replyMessageId),
make_column("replyPeerId", &EditedMessage::replyPeerId),
make_column("replyTopId", &EditedMessage::replyTopId),
make_column("replyForumTopic", &EditedMessage::replyForumTopic),
make_column("replySerialized", &EditedMessage::replySerialized),
make_column("entityCreateDate", &EditedMessage::entityCreateDate),
make_column("text", &EditedMessage::text),
make_column("textEntities", &EditedMessage::textEntities),
make_column("mediaPath", &EditedMessage::mediaPath),
make_column("hqThumbPath", &EditedMessage::hqThumbPath),
make_column("documentType", &EditedMessage::documentType),
make_column("documentSerialized", &EditedMessage::documentSerialized),
make_column("thumbsSerialized", &EditedMessage::thumbsSerialized),
make_column("documentAttributesSerialized", &EditedMessage::documentAttributesSerialized),
make_column("mimeType", &EditedMessage::mimeType)
),
make_table(
"DeletedDialog",
make_column("fakeId", &DeletedDialog::fakeId, primary_key().autoincrement()),
make_column("userId", &DeletedDialog::userId),
make_column("dialogId", &DeletedDialog::dialogId),
make_column("peerId", &DeletedDialog::peerId),
make_column("folderId", &DeletedDialog::folderId),
make_column("topMessage", &DeletedDialog::topMessage),
make_column("lastMessageDate", &DeletedDialog::lastMessageDate),
make_column("flags", &DeletedDialog::flags),
make_column("entityCreateDate", &DeletedDialog::entityCreateDate)
),
make_table(
"RegexFilter",
make_column("id", &RegexFilter::id),
make_column("text", &RegexFilter::text),
make_column("enabled", &RegexFilter::enabled),
make_column("caseInsensitive", &RegexFilter::caseInsensitive),
make_column("dialogId", &RegexFilter::dialogId)
),
make_table(
"RegexFilterGlobalExclusion",
make_column("fakeId", &RegexFilterGlobalExclusion::fakeId, primary_key().autoincrement()),
make_column("dialogId", &RegexFilterGlobalExclusion::dialogId),
make_column("filterId", &RegexFilterGlobalExclusion::filterId)
),
make_table(
"SpyMessageRead",
make_column("fakeId", &SpyMessageRead::fakeId, primary_key().autoincrement()),
make_column("userId", &SpyMessageRead::userId),
make_column("dialogId", &SpyMessageRead::dialogId),
make_column("messageId", &SpyMessageRead::messageId),
make_column("entityCreateDate", &SpyMessageRead::entityCreateDate)
),
make_table(
"SpyMessageContentsRead",
make_column("fakeId", &SpyMessageContentsRead::fakeId, primary_key().autoincrement()),
make_column("userId", &SpyMessageContentsRead::userId),
make_column("dialogId", &SpyMessageContentsRead::dialogId),
make_column("messageId", &SpyMessageContentsRead::messageId),
make_column("entityCreateDate", &SpyMessageContentsRead::entityCreateDate)
)
);
namespace AyuDatabase {
void moveCurrentDatabase() {
auto time = base::unixtime::now();
if (std::filesystem::exists("./tdata/ayudata.db")) {
std::filesystem::rename("./tdata/ayudata.db", QString("./tdata/ayudata_%1.db").arg(time).toStdString());
}
if (std::filesystem::exists("./tdata/ayudata.db-shm")) {
std::filesystem::rename("./tdata/ayudata.db-shm",
QString("./tdata/ayudata_%1.db-shm").arg(time).toStdString());
}
if (std::filesystem::exists("./tdata/ayudata.db-wal")) {
std::filesystem::rename("./tdata/ayudata.db-wal",
QString("./tdata/ayudata_%1.db-wal").arg(time).toStdString());
}
}
void initialize() {
const auto res = storage.sync_schema_simulate(true);
auto movePrevious = false;
for (const auto val : res | std::views::values) {
if (val == sync_schema_result::dropped_and_recreated) {
movePrevious = true;
break;
}
}
if (movePrevious) {
moveCurrentDatabase();
}
try {
storage.sync_schema(true);
} catch (...) {
LOG(("Failed to sync database schema"));
LOG(("Moving current database just in case"));
moveCurrentDatabase();
storage.sync_schema();
}
storage.begin_transaction();
storage.commit();
}
void addEditedMessage(const EditedMessage &message) {
storage.begin_transaction();
storage.insert(message);
storage.commit();
}
std::vector<EditedMessage> getEditedMessages(ID userId, ID dialogId, ID messageId) {
return storage.get_all<EditedMessage>(
where(
c(&EditedMessage::userId) == userId and
c(&EditedMessage::dialogId) == dialogId and
c(&EditedMessage::messageId) == messageId
)
);
}
bool hasRevisions(ID userId, ID dialogId, ID messageId) {
return storage.count<EditedMessage>(
where(
c(&EditedMessage::userId) == userId and
c(&EditedMessage::dialogId) == dialogId and
c(&EditedMessage::messageId) == messageId
)
) > 0;
}
}

View file

@ -7,8 +7,6 @@
#pragma once #pragma once
#include "entities.h" #include "entities.h"
#include "history/history.h"
#include "history/history_item.h"
namespace AyuDatabase { namespace AyuDatabase {

View file

@ -36,6 +36,7 @@ public:
ID replyPeerId; ID replyPeerId;
int replyTopId; int replyTopId;
bool replyForumTopic; bool replyForumTopic;
std::vector<char> replySerialized;
int entityCreateDate; int entityCreateDate;
std::string text; std::string text;
std::vector<char> textEntities; std::vector<char> textEntities;
@ -49,6 +50,7 @@ public:
}; };
using DeletedMessage = AyuMessageBase<struct DeletedMessageTag>; using DeletedMessage = AyuMessageBase<struct DeletedMessageTag>;
using EditedMessage = AyuMessageBase<struct EditedMessageTag>; using EditedMessage = AyuMessageBase<struct EditedMessageTag>;
class DeletedDialog class DeletedDialog
@ -58,8 +60,47 @@ public:
ID userId; ID userId;
ID dialogId; ID dialogId;
ID peerId; ID peerId;
std::unique_ptr<int> folderId; // nullable
int topMessage; int topMessage;
int lastMessageDate; int lastMessageDate;
int flags; int flags;
int entityCreateDate; int entityCreateDate;
}; };
class RegexFilter
{
public:
std::vector<char> id;
std::string text;
bool enabled;
bool caseInsensitive;
std::unique_ptr<ID> dialogId; // nullable
};
class RegexFilterGlobalExclusion
{
public:
ID fakeId;
ID dialogId;
std::vector<char> filterId;
};
class SpyMessageRead
{
public:
ID fakeId;
ID userId;
ID dialogId;
int messageId;
int entityCreateDate;
};
class SpyMessageContentsRead
{
public:
ID fakeId;
ID userId;
ID dialogId;
int messageId;
int entityCreateDate;
};

View file

@ -4,10 +4,10 @@
// but be respectful and credit the original author. // but be respectful and credit the original author.
// //
// Copyright @Radolyn, 2023 // Copyright @Radolyn, 2023
#include "ayu_messages_controller.h" #include "messages_storage.h"
#include "ayu/ayu_constants.h" #include "ayu/ayu_constants.h"
#include "ayu/database/ayu_database.h" #include "ayu/data/ayu_database.h"
#include "ayu/utils/ayu_mapper.h" #include "ayu/utils/ayu_mapper.h"
#include "ayu/utils/telegram_helpers.h" #include "ayu/utils/telegram_helpers.h"
@ -24,22 +24,7 @@
namespace AyuMessages { namespace AyuMessages {
std::optional<AyuMessagesController> controller = std::nullopt; void map(HistoryMessageEdition &edition, not_null<HistoryItem*> item, EditedMessage &message) {
void initialize() {
if (controller.has_value()) {
return;
}
controller = AyuMessagesController();
}
AyuMessagesController &getInstance() {
initialize();
return controller.value();
}
void map(HistoryMessageEdition &edition, not_null<HistoryItem *> item, EditedMessage &message) {
message.userId = item->history()->owner().session().userId().bare; message.userId = item->history()->owner().session().userId().bare;
message.dialogId = getDialogIdFromPeer(item->history()->peer); message.dialogId = getDialogIdFromPeer(item->history()->peer);
message.groupedId = item->groupId().value; message.groupedId = item->groupId().value;
@ -61,11 +46,11 @@ void map(HistoryMessageEdition &edition, not_null<HistoryItem *> item, EditedMes
message.views = item->viewsCount(); message.views = item->viewsCount();
message.entityCreateDate = base::unixtime::now(); // todo: rework message.entityCreateDate = base::unixtime::now(); // todo: rework
auto serializedText = serializeTextWithEntities(item); auto serializedText = AyuMapper::serializeTextWithEntities(item);
message.text = serializedText.first; message.text = serializedText.first;
// message.textEntities = serializedText.second; message.textEntities = serializedText.second;
// todo: // todo: implement mapping
message.mediaPath = "/"; message.mediaPath = "/";
message.documentType = DOCUMENT_TYPE_NONE; message.documentType = DOCUMENT_TYPE_NONE;
@ -75,14 +60,14 @@ void map(HistoryMessageEdition &edition, not_null<HistoryItem *> item, EditedMes
// message.mimeType; // message.mimeType;
} }
void AyuMessagesController::addEditedMessage(HistoryMessageEdition &edition, not_null<HistoryItem *> item) { void addEditedMessage(HistoryMessageEdition &edition, not_null<HistoryItem*> item) {
EditedMessage message; EditedMessage message;
map(edition, item, message); map(edition, item, message);
AyuDatabase::addEditedMessage(message); AyuDatabase::addEditedMessage(message);
} }
std::vector<EditedMessage> AyuMessagesController::getEditedMessages(HistoryItem *item) { std::vector<EditedMessage> getEditedMessages(not_null<HistoryItem*> item) {
auto userId = item->history()->owner().session().userId().bare; auto userId = item->history()->owner().session().userId().bare;
auto dialogId = getDialogIdFromPeer(item->history()->peer); auto dialogId = getDialogIdFromPeer(item->history()->peer);
auto msgId = item->id.bare; auto msgId = item->id.bare;
@ -90,7 +75,7 @@ std::vector<EditedMessage> AyuMessagesController::getEditedMessages(HistoryItem
return AyuDatabase::getEditedMessages(userId, dialogId, msgId); return AyuDatabase::getEditedMessages(userId, dialogId, msgId);
} }
bool AyuMessagesController::hasRevisions(not_null<HistoryItem *> item) { bool hasRevisions(not_null<HistoryItem*> item) {
auto userId = item->history()->owner().session().userId().bare; auto userId = item->history()->owner().session().userId().bare;
auto dialogId = getDialogIdFromPeer(item->history()->peer); auto dialogId = getDialogIdFromPeer(item->history()->peer);
auto msgId = item->id.bare; auto msgId = item->id.bare;

View file

@ -0,0 +1,19 @@
// This is the source code of AyuGram for Desktop.
//
// We do not and cannot prevent the use of our code,
// but be respectful and credit the original author.
//
// Copyright @Radolyn, 2023
#pragma once
#include "entities.h"
#include "history/history_item_edition.h"
namespace AyuMessages {
void addEditedMessage(HistoryMessageEdition &edition, not_null<HistoryItem*> item);
std::vector<EditedMessage> getEditedMessages(not_null<HistoryItem*> item);
bool hasRevisions(not_null<HistoryItem*> item);
}

View file

@ -1,163 +0,0 @@
// This is the source code of AyuGram for Desktop.
//
// We do not and cannot prevent the use of our code,
// but be respectful and credit the original author.
//
// Copyright @Radolyn, 2023
#include "ayu_database.h"
#include "entities.h"
#include "ayu/libs/sqlite/sqlite_orm.h"
#include "base/unixtime.h"
using namespace sqlite_orm;
auto storage = make_storage("./tdata/ayudata.db",
make_table("DeletedMessage",
make_column("userId", &DeletedMessage::userId),
make_column("dialogId", &DeletedMessage::dialogId),
make_column("groupedId", &DeletedMessage::groupedId),
make_column("peerId", &DeletedMessage::peerId),
make_column("fromId", &DeletedMessage::fromId),
make_column("topicId", &DeletedMessage::topicId),
make_column("messageId", &DeletedMessage::messageId),
make_column("date", &DeletedMessage::date),
make_column("flags", &DeletedMessage::flags),
make_column("editDate", &DeletedMessage::editDate),
make_column("views", &DeletedMessage::views),
make_column("fwdFlags", &DeletedMessage::fwdFlags),
make_column("fwdFromId", &DeletedMessage::fwdFromId),
make_column("fwdName", &DeletedMessage::fwdName),
make_column("fwdDate", &DeletedMessage::fwdDate),
make_column("fwdPostAuthor", &DeletedMessage::fwdPostAuthor),
make_column("replyFlags", &DeletedMessage::replyFlags),
make_column("replyMessageId", &DeletedMessage::replyMessageId),
make_column("replyPeerId", &DeletedMessage::replyPeerId),
make_column("replyTopId", &DeletedMessage::replyTopId),
make_column("replyForumTopic", &DeletedMessage::replyForumTopic),
make_column("entityCreateDate", &DeletedMessage::entityCreateDate),
make_column("text", &DeletedMessage::text),
make_column("textEntities", &DeletedMessage::textEntities),
make_column("mediaPath", &DeletedMessage::mediaPath),
make_column("hqThumbPath", &DeletedMessage::hqThumbPath),
make_column("documentType", &DeletedMessage::documentType),
make_column("documentSerialized", &DeletedMessage::documentSerialized),
make_column("thumbsSerialized", &DeletedMessage::thumbsSerialized),
make_column("documentAttributesSerialized",
&DeletedMessage::documentAttributesSerialized),
make_column("mimeType", &DeletedMessage::mimeType)
),
make_table("EditedMessage",
make_column("userId", &EditedMessage::userId),
make_column("dialogId", &EditedMessage::dialogId),
make_column("groupedId", &EditedMessage::groupedId),
make_column("peerId", &EditedMessage::peerId),
make_column("fromId", &EditedMessage::fromId),
make_column("topicId", &EditedMessage::topicId),
make_column("messageId", &EditedMessage::messageId),
make_column("date", &EditedMessage::date),
make_column("flags", &EditedMessage::flags),
make_column("editDate", &EditedMessage::editDate),
make_column("views", &EditedMessage::views),
make_column("fwdFlags", &EditedMessage::fwdFlags),
make_column("fwdFromId", &EditedMessage::fwdFromId),
make_column("fwdName", &EditedMessage::fwdName),
make_column("fwdDate", &EditedMessage::fwdDate),
make_column("fwdPostAuthor", &EditedMessage::fwdPostAuthor),
make_column("replyFlags", &EditedMessage::replyFlags),
make_column("replyMessageId", &EditedMessage::replyMessageId),
make_column("replyPeerId", &EditedMessage::replyPeerId),
make_column("replyTopId", &EditedMessage::replyTopId),
make_column("replyForumTopic", &EditedMessage::replyForumTopic),
make_column("entityCreateDate", &EditedMessage::entityCreateDate),
make_column("text", &EditedMessage::text),
make_column("textEntities", &EditedMessage::textEntities),
make_column("mediaPath", &EditedMessage::mediaPath),
make_column("hqThumbPath", &EditedMessage::hqThumbPath),
make_column("documentType", &EditedMessage::documentType),
make_column("documentSerialized", &EditedMessage::documentSerialized),
make_column("thumbsSerialized", &EditedMessage::thumbsSerialized),
make_column("documentAttributesSerialized",
&EditedMessage::documentAttributesSerialized),
make_column("mimeType", &EditedMessage::mimeType)
),
make_table("DeletedDialog",
make_column("userId", &DeletedDialog::userId),
make_column("dialogId", &DeletedDialog::dialogId),
make_column("peerId", &DeletedDialog::peerId),
make_column("topMessage", &DeletedDialog::topMessage),
make_column("lastMessageDate", &DeletedDialog::lastMessageDate),
make_column("flags", &DeletedDialog::flags),
make_column("entityCreateDate", &DeletedDialog::entityCreateDate)
)
);
namespace AyuDatabase {
void initialize() {
// move to `tdata` from legacy version
if (std::filesystem::exists("ayugram.db")) {
try {
std::filesystem::rename("ayugram.db", "./tdata/ayudata.db");
} catch (std::filesystem::filesystem_error &e) {
LOG(("Failed to move database: %1").arg(e.what()));
}
}
try {
storage.sync_schema();
} catch (...) {
auto time = base::unixtime::now();
LOG(("Failed to sync database schema"));
LOG(("Moving current database just in case"));
if (std::filesystem::exists("./tdata/ayudata.db")) {
std::filesystem::rename("./tdata/ayudata.db", QString("./tdata/ayudata_%1.db").arg(time).toStdString());
}
if (std::filesystem::exists("./tdata/ayudata.db-shm")) {
std::filesystem::rename("./tdata/ayudata.db-shm",
QString("./tdata/ayudata_%1.db-shm").arg(time).toStdString());
}
if (std::filesystem::exists("./tdata/ayudata.db-wal")) {
std::filesystem::rename("./tdata/ayudata.db-wal",
QString("./tdata/ayudata_%1.db-wal").arg(time).toStdString());
}
storage.sync_schema();
}
storage.begin_transaction();
storage.commit();
}
void addEditedMessage(const EditedMessage &message) {
storage.begin_transaction();
storage.insert(message);
storage.commit();
}
std::vector<EditedMessage> getEditedMessages(ID userId, ID dialogId, ID messageId) {
return storage.get_all<EditedMessage>(
where(
c(&EditedMessage::userId) == userId and
c(&EditedMessage::dialogId) == dialogId and
c(&EditedMessage::messageId) == messageId
)
);
}
bool hasRevisions(ID userId, ID dialogId, ID messageId) {
return storage.count<EditedMessage>(
where(
c(&EditedMessage::userId) == userId and
c(&EditedMessage::dialogId) == dialogId and
c(&EditedMessage::messageId) == messageId
)
) > 0;
}
}

View file

@ -146,23 +146,23 @@ class MessageShotDelegate final : public HistoryView::DefaultElementDelegate
{ {
public: public:
MessageShotDelegate( MessageShotDelegate(
not_null<QWidget *> parent, not_null<QWidget*> parent,
not_null<Ui::ChatStyle *> st, not_null<Ui::ChatStyle*> st,
Fn<void()> update); Fn<void()> update);
bool elementAnimationsPaused() override; bool elementAnimationsPaused() override;
not_null<Ui::PathShiftGradient *> elementPathShiftGradient() override; not_null<Ui::PathShiftGradient*> elementPathShiftGradient() override;
HistoryView::Context elementContext() override; HistoryView::Context elementContext() override;
bool elementIsChatWide() override; bool elementIsChatWide() override;
private: private:
const not_null<QWidget *> _parent; const not_null<QWidget*> _parent;
const std::unique_ptr<Ui::PathShiftGradient> _pathGradient; const std::unique_ptr<Ui::PathShiftGradient> _pathGradient;
}; };
MessageShotDelegate::MessageShotDelegate( MessageShotDelegate::MessageShotDelegate(
not_null<QWidget *> parent, not_null<QWidget*> parent,
not_null<Ui::ChatStyle *> st, not_null<Ui::ChatStyle*> st,
Fn<void()> update) Fn<void()> update)
: _parent(parent) : _parent(parent)
, _pathGradient(HistoryView::MakePathShiftGradient(st, update)) { , _pathGradient(HistoryView::MakePathShiftGradient(st, update)) {
@ -173,7 +173,7 @@ bool MessageShotDelegate::elementAnimationsPaused() {
} }
auto MessageShotDelegate::elementPathShiftGradient() auto MessageShotDelegate::elementPathShiftGradient()
-> not_null<Ui::PathShiftGradient *> { -> not_null<Ui::PathShiftGradient*> {
return _pathGradient.get(); return _pathGradient.get();
} }
@ -234,7 +234,7 @@ QImage addPadding(const QImage &original, int padding) {
return paddedImage; return paddedImage;
} }
QImage Make(not_null<QWidget *> box, const ShotConfig &config) { QImage Make(not_null<QWidget*> box, const ShotConfig &config) {
const auto controller = config.controller; const auto controller = config.controller;
const auto st = config.st; const auto st = config.st;
const auto messages = config.messages; const auto messages = config.messages;
@ -252,13 +252,13 @@ QImage Make(not_null<QWidget *> box, const ShotConfig &config) {
box->update(); box->update();
}); });
std::unordered_map<not_null<HistoryItem *>, std::shared_ptr<HistoryView::Element>> createdViews; std::unordered_map<not_null<HistoryItem*>, std::shared_ptr<HistoryView::Element>> createdViews;
createdViews.reserve(messages.size()); createdViews.reserve(messages.size());
for (const auto &message : messages) { for (const auto &message : messages) {
createdViews.emplace(message, message->createView(delegate.get())); createdViews.emplace(message, message->createView(delegate.get()));
} }
auto getView = [=](not_null<HistoryItem *> msg) auto getView = [=](not_null<HistoryItem*> msg)
{ {
return createdViews.at(msg).get(); return createdViews.at(msg).get();
}; };
@ -357,7 +357,7 @@ QImage Make(not_null<QWidget *> box, const ShotConfig &config) {
return overlay; return overlay;
} }
void Wrapper(not_null<HistoryView::ListWidget *> widget) { void Wrapper(not_null<HistoryView::ListWidget*> widget) {
const auto items = widget->getSelectedIds(); const auto items = widget->getSelectedIds();
if (items.empty()) { if (items.empty()) {
return; return;

View file

@ -15,9 +15,9 @@ namespace AyuFeatures::MessageShot {
struct ShotConfig struct ShotConfig
{ {
not_null<Window::SessionController *> controller; not_null<Window::SessionController*> controller;
std::shared_ptr<Ui::ChatStyle> st; std::shared_ptr<Ui::ChatStyle> st;
std::vector<not_null<HistoryItem *>> messages; std::vector<not_null<HistoryItem*>> messages;
bool showDate; bool showDate;
bool showReactions; bool showReactions;
@ -63,8 +63,8 @@ rpl::producer<Data::CloudTheme> themeChosen();
void setPalette(style::palette &palette); void setPalette(style::palette &palette);
rpl::producer<style::palette> paletteChosen(); rpl::producer<style::palette> paletteChosen();
QImage Make(not_null<QWidget *> box, const ShotConfig &config); QImage Make(not_null<QWidget*> box, const ShotConfig &config);
void Wrapper(not_null<HistoryView::ListWidget *> widget); void Wrapper(not_null<HistoryView::ListWidget*> widget);
} }

View file

@ -1,25 +0,0 @@
// This is the source code of AyuGram for Desktop.
//
// We do not and cannot prevent the use of our code,
// but be respectful and credit the original author.
//
// Copyright @Radolyn, 2023
#pragma once
#include "ayu/database/entities.h"
#include "history/history_item_edition.h"
namespace AyuMessages {
class AyuMessagesController
{
public:
void addEditedMessage(HistoryMessageEdition &edition, not_null<HistoryItem *> item);
std::vector<EditedMessage> getEditedMessages(HistoryItem *item);
bool hasRevisions(not_null<HistoryItem *> item);
};
AyuMessagesController &getInstance();
}

View file

@ -4,7 +4,7 @@
// but be respectful and credit the original author. // but be respectful and credit the original author.
// //
// Copyright @Radolyn, 2023 // Copyright @Radolyn, 2023
#include "ayu_assets.h" #include "ayu_logo.h"
#include "ayu/ayu_settings.h" #include "ayu/ayu_settings.h"
static QString LAST_LOADED_NAME; static QString LAST_LOADED_NAME;

View file

@ -128,18 +128,18 @@ private:
Selection selected) const; Selection selected) const;
std::unique_ptr<Ui::RippleAnimation> &rippleBySelection( std::unique_ptr<Ui::RippleAnimation> &rippleBySelection(
not_null<Row *> row, not_null<Row*> row,
Selection selected); Selection selected);
[[maybe_unused]] const std::unique_ptr<Ui::RippleAnimation> &rippleBySelection( [[maybe_unused]] const std::unique_ptr<Ui::RippleAnimation> &rippleBySelection(
not_null<const Row *> row, not_null<const Row*> row,
Selection selected) const; Selection selected) const;
void addRipple(Selection selected, QPoint position); void addRipple(Selection selected, QPoint position);
void ensureRippleBySelection(Selection selected); void ensureRippleBySelection(Selection selected);
void ensureRippleBySelection(not_null<Row *> row, Selection selected); void ensureRippleBySelection(not_null<Row*> row, Selection selected);
int indexFromSelection(Selection selected) const; int indexFromSelection(Selection selected) const;
@ -153,16 +153,16 @@ private:
void repaint(const Row &row); void repaint(const Row &row);
void repaintChecked(not_null<const Row *> row); void repaintChecked(not_null<const Row*> row);
void activateByIndex(int index); void activateByIndex(int index);
void setForceRippled(not_null<Row *> row, bool rippled); void setForceRippled(not_null<Row*> row, bool rippled);
void restore(not_null<Row *> row); void restore(not_null<Row*> row);
std::vector<Row> _rows; std::vector<Row> _rows;
std::vector<not_null<Row *>> _filtered; std::vector<not_null<Row*>> _filtered;
Selection _selected; Selection _selected;
Selection _pressed; Selection _pressed;
QString _chosen; QString _chosen;
@ -312,7 +312,7 @@ void Rows::ensureRippleBySelection(Selection selected) {
ensureRippleBySelection(&rowBySelection(selected), selected); ensureRippleBySelection(&rowBySelection(selected), selected);
} }
void Rows::ensureRippleBySelection(not_null<Row *> row, Selection selected) { void Rows::ensureRippleBySelection(not_null<Row*> row, Selection selected) {
auto &ripple = rippleBySelection(row, selected); auto &ripple = rippleBySelection(row, selected);
if (ripple) { if (ripple) {
return; return;
@ -342,11 +342,11 @@ void Rows::mouseReleaseEvent(QMouseEvent *e) {
} }
} }
void Rows::restore(not_null<Row *> row) { void Rows::restore(not_null<Row*> row) {
row->removed = false; row->removed = false;
} }
void Rows::setForceRippled(not_null<Row *> row, bool rippled) { void Rows::setForceRippled(not_null<Row*> row, bool rippled) {
repaint(*row); repaint(*row);
} }
@ -483,7 +483,7 @@ void Rows::repaint(const Row &row) {
update(0, row.top, width(), row.height); update(0, row.top, width(), row.height);
} }
void Rows::repaintChecked(not_null<const Row *> row) { void Rows::repaintChecked(not_null<const Row*> row) {
const auto found = (ranges::find(_filtered, row) != end(_filtered)); const auto found = (ranges::find(_filtered, row) != end(_filtered));
if (_query.isEmpty() || found) { if (_query.isEmpty() || found) {
repaint(*row); repaint(*row);
@ -542,16 +542,16 @@ const std::unique_ptr<Ui::RippleAnimation> &Rows::rippleBySelection(
} }
std::unique_ptr<Ui::RippleAnimation> &Rows::rippleBySelection( std::unique_ptr<Ui::RippleAnimation> &Rows::rippleBySelection(
not_null<Row *> row, not_null<Row*> row,
Selection selected) { Selection selected) {
return row->ripple; return row->ripple;
} }
const std::unique_ptr<Ui::RippleAnimation> &Rows::rippleBySelection( const std::unique_ptr<Ui::RippleAnimation> &Rows::rippleBySelection(
not_null<const Row *> row, not_null<const Row*> row,
Selection selected) const { Selection selected) const {
return const_cast<Rows *>(this)->rippleBySelection( return const_cast<Rows*>(this)->rippleBySelection(
const_cast<Row *>(row.get()), const_cast<Row*>(row.get()),
selected); selected);
} }
@ -668,7 +668,7 @@ void Content::setupContent(
const auto add = [&](const std::vector<Font> &list) const auto add = [&](const std::vector<Font> &list)
{ {
if (list.empty()) { if (list.empty()) {
return (Rows *)nullptr; return (Rows*) nullptr;
} }
const auto wrap = content->add( const auto wrap = content->add(
object_ptr<Ui::SlideWrap<Ui::VerticalLayout>>( object_ptr<Ui::SlideWrap<Ui::VerticalLayout>>(
@ -964,7 +964,7 @@ void AyuUi::FontSelectorBox::prepare() {
}; };
} }
void AyuUi::FontSelectorBox::setupTop(not_null<Ui::VerticalLayout *> container) { void AyuUi::FontSelectorBox::setupTop(not_null<Ui::VerticalLayout*> container) {
if (!_controller) { if (!_controller) {
return; return;
} }

View file

@ -44,7 +44,7 @@ protected:
void keyPressEvent(QKeyEvent *e) override; void keyPressEvent(QKeyEvent *e) override;
private: private:
void setupTop(not_null<Ui::VerticalLayout *> container); void setupTop(not_null<Ui::VerticalLayout*> container);
[[nodiscard]] int rowsInPage() const; [[nodiscard]] int rowsInPage() const;
Window::SessionController *_controller = nullptr; Window::SessionController *_controller = nullptr;

View file

@ -18,7 +18,7 @@ namespace AyuUi {
ServerReadConfirmationBox::ServerReadConfirmationBox( ServerReadConfirmationBox::ServerReadConfirmationBox(
QWidget *, QWidget *,
not_null<Window::SessionController *> controller) not_null<Window::SessionController*> controller)
: _controller(controller) { : _controller(controller) {
// //
} }

View file

@ -14,7 +14,7 @@ namespace AyuUi {
class ServerReadConfirmationBox : public Ui::BoxContent class ServerReadConfirmationBox : public Ui::BoxContent
{ {
public: public:
ServerReadConfirmationBox(QWidget *, not_null<Window::SessionController *> controller); ServerReadConfirmationBox(QWidget *, not_null<Window::SessionController*> controller);
protected: protected:
void prepare() override; void prepare() override;
@ -24,7 +24,7 @@ protected:
private: private:
void ReadAllPeers(); void ReadAllPeers();
not_null<Window::SessionController *> _controller; not_null<Window::SessionController*> _controller;
object_ptr<Ui::FlatLabel> _text = {nullptr}; object_ptr<Ui::FlatLabel> _text = {nullptr};
}; };

View file

@ -26,7 +26,7 @@
ThemeSelectorBox::ThemeSelectorBox( ThemeSelectorBox::ThemeSelectorBox(
QWidget *parent, QWidget *parent,
not_null<Window::SessionController *> controller) not_null<Window::SessionController*> controller)
: _controller(controller) { : _controller(controller) {
} }

View file

@ -15,7 +15,7 @@ using Callback = Fn<void(style::palette &)>;
class ThemeSelectorBox : public Ui::BoxContent class ThemeSelectorBox : public Ui::BoxContent
{ {
public: public:
ThemeSelectorBox(QWidget *parent, not_null<Window::SessionController *> controller); ThemeSelectorBox(QWidget *parent, not_null<Window::SessionController*> controller);
rpl::producer<style::palette> paletteSelected(); rpl::producer<style::palette> paletteSelected();
rpl::producer<QString> themeNameChanged(); rpl::producer<QString> themeNameChanged();
@ -26,7 +26,7 @@ protected:
private: private:
void setupContent(); void setupContent();
not_null<Window::SessionController *> _controller; not_null<Window::SessionController*> _controller;
rpl::event_stream<style::palette> _palettes; rpl::event_stream<style::palette> _palettes;
rpl::event_stream<QString> _themeNames; rpl::event_stream<QString> _themeNames;

View file

@ -13,7 +13,7 @@
#include "mainwindow.h" #include "mainwindow.h"
#include "ayu/ayu_settings.h" #include "ayu/ayu_settings.h"
#include "ayu/ayu_state.h" #include "ayu/ayu_state.h"
#include "ayu/messages/ayu_messages_controller.h" #include "../../data/messages_storage.h"
#include "ayu/ui/context_menu/menu_item_subtext.h" #include "ayu/ui/context_menu/menu_item_subtext.h"
#include "ayu/utils/qt_key_modifiers_extended.h" #include "ayu/utils/qt_key_modifiers_extended.h"
#include "history/history_item_components.h" #include "history/history_item_components.h"
@ -36,8 +36,8 @@ bool needToShowItem(int state) {
return state == 1 || state == 2 && base::IsExtendedContextMenuModifierPressed(); return state == 1 || state == 2 && base::IsExtendedContextMenuModifierPressed();
} }
void AddHistoryAction(not_null<Ui::PopupMenu *> menu, HistoryItem *item) { void AddHistoryAction(not_null<Ui::PopupMenu*> menu, HistoryItem *item) {
if (AyuMessages::getInstance().hasRevisions(item)) { if (AyuMessages::hasRevisions(item)) {
menu->addAction(tr::ayu_EditsHistoryMenuText(tr::now), menu->addAction(tr::ayu_EditsHistoryMenuText(tr::now),
[=] [=]
{ {
@ -48,7 +48,7 @@ void AddHistoryAction(not_null<Ui::PopupMenu *> menu, HistoryItem *item) {
} }
} }
void AddHideMessageAction(not_null<Ui::PopupMenu *> menu, HistoryItem *item) { void AddHideMessageAction(not_null<Ui::PopupMenu*> menu, HistoryItem *item) {
const auto settings = &AyuSettings::getInstance(); const auto settings = &AyuSettings::getInstance();
if (!needToShowItem(settings->showHideMessageInContextMenu)) { if (!needToShowItem(settings->showHideMessageInContextMenu)) {
return; return;
@ -66,7 +66,7 @@ void AddHideMessageAction(not_null<Ui::PopupMenu *> menu, HistoryItem *item) {
&st::menuIconClear); &st::menuIconClear);
} }
void AddUserMessagesAction(not_null<Ui::PopupMenu *> menu, HistoryItem *item) { void AddUserMessagesAction(not_null<Ui::PopupMenu*> menu, HistoryItem *item) {
const auto settings = &AyuSettings::getInstance(); const auto settings = &AyuSettings::getInstance();
if (!needToShowItem(settings->showUserMessagesInContextMenu)) { if (!needToShowItem(settings->showUserMessagesInContextMenu)) {
return; return;
@ -92,7 +92,7 @@ void AddUserMessagesAction(not_null<Ui::PopupMenu *> menu, HistoryItem *item) {
} }
} }
void AddMessageDetailsAction(not_null<Ui::PopupMenu *> menu, HistoryItem *item) { void AddMessageDetailsAction(not_null<Ui::PopupMenu*> menu, HistoryItem *item) {
const auto settings = &AyuSettings::getInstance(); const auto settings = &AyuSettings::getInstance();
if (!needToShowItem(settings->showMessageDetailsInContextMenu)) { if (!needToShowItem(settings->showMessageDetailsInContextMenu)) {
return; return;
@ -150,7 +150,7 @@ void AddMessageDetailsAction(not_null<Ui::PopupMenu *> menu, HistoryItem *item)
.text = tr::ayu_MessageDetailsPC(tr::now), .text = tr::ayu_MessageDetailsPC(tr::now),
.handler = nullptr, .handler = nullptr,
.icon = &st::menuIconInfo, .icon = &st::menuIconInfo,
.fillSubmenu = [&](not_null<Ui::PopupMenu *> menu2) .fillSubmenu = [&](not_null<Ui::PopupMenu*> menu2)
{ {
if (hasAnyPostField) { if (hasAnyPostField) {
if (!messageViews.isEmpty()) { if (!messageViews.isEmpty()) {
@ -278,7 +278,7 @@ void AddMessageDetailsAction(not_null<Ui::PopupMenu *> menu, HistoryItem *item)
}); });
} }
void AddReadUntilAction(not_null<Ui::PopupMenu *> menu, HistoryItem *item) { void AddReadUntilAction(not_null<Ui::PopupMenu*> menu, HistoryItem *item) {
if (item->isLocal()) { if (item->isLocal()) {
return; return;
} }

View file

@ -13,10 +13,10 @@ namespace AyuUi {
bool needToShowItem(int state); bool needToShowItem(int state);
void AddHistoryAction(not_null<Ui::PopupMenu *> menu, HistoryItem *item); void AddHistoryAction(not_null<Ui::PopupMenu*> menu, HistoryItem *item);
void AddHideMessageAction(not_null<Ui::PopupMenu *> menu, HistoryItem *item); void AddHideMessageAction(not_null<Ui::PopupMenu*> menu, HistoryItem *item);
void AddUserMessagesAction(not_null<Ui::PopupMenu *> menu, HistoryItem *item); void AddUserMessagesAction(not_null<Ui::PopupMenu*> menu, HistoryItem *item);
void AddMessageDetailsAction(not_null<Ui::PopupMenu *> menu, HistoryItem *item); void AddMessageDetailsAction(not_null<Ui::PopupMenu*> menu, HistoryItem *item);
void AddReadUntilAction(not_null<Ui::PopupMenu *> menu, HistoryItem *item); void AddReadUntilAction(not_null<Ui::PopupMenu*> menu, HistoryItem *item);
} }

View file

@ -10,7 +10,7 @@
#include "mainwindow.h" #include "mainwindow.h"
#include "qguiapplication.h" #include "qguiapplication.h"
#include "ayu/database/entities.h" #include "ayu/data/entities.h"
#include "ayu/utils/telegram_helpers.h" #include "ayu/utils/telegram_helpers.h"
#include "base/unixtime.h" #include "base/unixtime.h"
@ -30,7 +30,7 @@ class ActionWithSubText : public Menu::ItemBase
{ {
public: public:
ActionWithSubText( ActionWithSubText(
not_null<RpWidget *> parent, not_null<RpWidget*> parent,
const style::Menu &st, const style::Menu &st,
const style::icon &icon, const style::icon &icon,
Fn<void()> callback, Fn<void()> callback,
@ -38,9 +38,9 @@ public:
QString subtext); QString subtext);
bool isEnabled() const override; bool isEnabled() const override;
not_null<QAction *> action() const override; not_null<QAction*> action() const override;
void handleKeyPress(not_null<QKeyEvent *> e) override; void handleKeyPress(not_null<QKeyEvent*> e) override;
protected: protected:
QPoint prepareRippleStartPosition() const override; QPoint prepareRippleStartPosition() const override;
@ -51,7 +51,7 @@ protected:
void prepare(const QString &title); void prepare(const QString &title);
void paint(Painter &p); void paint(Painter &p);
const not_null<QAction *> _dummyAction; const not_null<QAction*> _dummyAction;
const style::Menu &_st; const style::Menu &_st;
const style::icon &_icon; const style::icon &_icon;
@ -65,10 +65,10 @@ protected:
class ActionStickerPackAuthor final : public ActionWithSubText class ActionStickerPackAuthor final : public ActionWithSubText
{ {
public: public:
ActionStickerPackAuthor(not_null<Menu::Menu *> menu, not_null<Main::Session *> session, ID authorId); ActionStickerPackAuthor(not_null<Menu::Menu*> menu, not_null<Main::Session*> session, ID authorId);
private: private:
not_null<Main::Session *> _session; not_null<Main::Session*> _session;
void searchAuthor(ID authorId); void searchAuthor(ID authorId);
}; };
@ -81,7 +81,7 @@ TextParseOptions MenuTextOptions = {
}; };
ActionWithSubText::ActionWithSubText( ActionWithSubText::ActionWithSubText(
not_null<RpWidget *> parent, not_null<RpWidget*> parent,
const style::Menu &st, const style::Menu &st,
const style::icon &icon, const style::icon &icon,
Fn<void()> callback, Fn<void()> callback,
@ -176,7 +176,7 @@ bool ActionWithSubText::isEnabled() const {
return true; return true;
} }
not_null<QAction *> ActionWithSubText::action() const { not_null<QAction*> ActionWithSubText::action() const {
return _dummyAction; return _dummyAction;
} }
@ -192,7 +192,7 @@ int ActionWithSubText::contentHeight() const {
return _height; return _height;
} }
void ActionWithSubText::handleKeyPress(not_null<QKeyEvent *> e) { void ActionWithSubText::handleKeyPress(not_null<QKeyEvent*> e) {
if (!isSelected()) { if (!isSelected()) {
return; return;
} }
@ -202,8 +202,8 @@ void ActionWithSubText::handleKeyPress(not_null<QKeyEvent *> e) {
} }
} }
ActionStickerPackAuthor::ActionStickerPackAuthor(not_null<Menu::Menu *> menu, ActionStickerPackAuthor::ActionStickerPackAuthor(not_null<Menu::Menu*> menu,
not_null<Main::Session *> session, not_null<Main::Session*> session,
ID authorId) ID authorId)
: ActionWithSubText(menu, : ActionWithSubText(menu,
menu->st(), menu->st(),
@ -273,7 +273,7 @@ void ActionStickerPackAuthor::searchAuthor(ID authorId) {
} // namespace } // namespace
base::unique_qptr<Menu::ItemBase> ContextActionWithSubText( base::unique_qptr<Menu::ItemBase> ContextActionWithSubText(
not_null<Menu::Menu *> menu, not_null<Menu::Menu*> menu,
const style::icon &icon, const style::icon &icon,
const QString &title, const QString &title,
const QString &subtext, const QString &subtext,
@ -295,8 +295,8 @@ base::unique_qptr<Menu::ItemBase> ContextActionWithSubText(
} }
base::unique_qptr<Menu::ItemBase> ContextActionStickerAuthor( base::unique_qptr<Menu::ItemBase> ContextActionStickerAuthor(
not_null<Menu::Menu *> menu, not_null<Menu::Menu*> menu,
not_null<Main::Session *> session, not_null<Main::Session*> session,
ID authorId) { ID authorId) {
return base::make_unique_q<ActionStickerPackAuthor>(menu, session, authorId); return base::make_unique_q<ActionStickerPackAuthor>(menu, session, authorId);
} }

View file

@ -6,7 +6,7 @@
// Copyright @Radolyn, 2023 // Copyright @Radolyn, 2023
#pragma once #pragma once
#include "ayu/database/entities.h" #include "ayu/data/entities.h"
#include "main/main_session.h" #include "main/main_session.h"
#include "base/unique_qptr.h" #include "base/unique_qptr.h"
@ -20,15 +20,15 @@ class ItemBase;
class PopupMenu; class PopupMenu;
[[nodiscard]] base::unique_qptr<Menu::ItemBase> ContextActionWithSubText( [[nodiscard]] base::unique_qptr<Menu::ItemBase> ContextActionWithSubText(
not_null<Menu::Menu *> menu, not_null<Menu::Menu*> menu,
const style::icon &icon, const style::icon &icon,
const QString &title, const QString &title,
const QString &subtext, const QString &subtext,
Fn<void()> callback = nullptr); Fn<void()> callback = nullptr);
[[nodiscard]] base::unique_qptr<Menu::ItemBase> ContextActionStickerAuthor( [[nodiscard]] base::unique_qptr<Menu::ItemBase> ContextActionStickerAuthor(
not_null<Menu::Menu *> menu, not_null<Menu::Menu*> menu,
not_null<Main::Session *> session, not_null<Main::Session*> session,
ID authorId); ID authorId);
} // namespace Ui } // namespace Ui

View file

@ -10,6 +10,7 @@
#include "mainwidget.h" #include "mainwidget.h"
#include "mainwindow.h" #include "mainwindow.h"
#include "api/api_attached_stickers.h" #include "api/api_attached_stickers.h"
#include "ayu/data/messages_storage.h"
#include "ayu/ui/sections/edited/edited_log_section.h" #include "ayu/ui/sections/edited/edited_log_section.h"
#include "base/call_delayed.h" #include "base/call_delayed.h"
#include "base/unixtime.h" #include "base/unixtime.h"
@ -53,7 +54,6 @@
#include "ui/widgets/popup_menu.h" #include "ui/widgets/popup_menu.h"
#include "window/window_session_controller.h" #include "window/window_session_controller.h"
#include <ayu/messages/ayu_messages_controller.h>
#include <QtGui/QClipboard> #include <QtGui/QClipboard>
#include <QtWidgets/QApplication> #include <QtWidgets/QApplication>
@ -157,7 +157,7 @@ void InnerWidget::enumerateUserpics(Method method) {
// -1 means we didn't find an attached to next message yet. // -1 means we didn't find an attached to next message yet.
int lowestAttachedItemTop = -1; int lowestAttachedItemTop = -1;
auto userpicCallback = [&](not_null<Element *> view, int itemtop, int itembottom) auto userpicCallback = [&](not_null<Element*> view, int itemtop, int itembottom)
{ {
// Skip all service messages. // Skip all service messages.
if (view->data()->isService()) { if (view->data()->isService()) {
@ -205,7 +205,7 @@ void InnerWidget::enumerateDates(Method method) {
// -1 means we didn't find a same-day with previous message yet. // -1 means we didn't find a same-day with previous message yet.
auto lowestInOneDayItemBottom = -1; auto lowestInOneDayItemBottom = -1;
auto dateCallback = [&](not_null<Element *> view, int itemtop, int itembottom) auto dateCallback = [&](not_null<Element*> view, int itemtop, int itembottom)
{ {
const auto item = view->data(); const auto item = view->data();
if (lowestInOneDayItemBottom < 0 && view->isInOneDayWithPrevious()) { if (lowestInOneDayItemBottom < 0 && view->isInOneDayWithPrevious()) {
@ -245,9 +245,9 @@ void InnerWidget::enumerateDates(Method method) {
InnerWidget::InnerWidget( InnerWidget::InnerWidget(
QWidget *parent, QWidget *parent,
not_null<Window::SessionController *> controller, not_null<Window::SessionController*> controller,
not_null<PeerData *> peer, not_null<PeerData*> peer,
not_null<HistoryItem *> item) not_null<HistoryItem*> item)
: RpWidget(parent), : RpWidget(parent),
_controller(controller), _controller(controller),
_peer(peer), _peer(peer),
@ -319,7 +319,7 @@ InnerWidget::InnerWidget(
}, },
lifetime()); lifetime());
session().data().itemDataChanges( session().data().itemDataChanges(
) | rpl::start_with_next([=](not_null<HistoryItem *> item) ) | rpl::start_with_next([=](not_null<HistoryItem*> item)
{ {
if (const auto view = viewForItem(item)) { if (const auto view = viewForItem(item)) {
view->itemDataChanged(); view->itemDataChanged();
@ -519,7 +519,7 @@ HistoryView::Context InnerWidget::elementContext() {
} }
bool InnerWidget::elementUnderCursor( bool InnerWidget::elementUnderCursor(
not_null<const HistoryView::Element *> view) { not_null<const HistoryView::Element*> view) {
return (Element::Hovered() == view); return (Element::Hovered() == view);
} }
@ -528,7 +528,7 @@ bool InnerWidget::elementInSelectionMode() {
} }
bool InnerWidget::elementIntersectsRange( bool InnerWidget::elementIntersectsRange(
not_null<const Element *> view, not_null<const Element*> view,
int from, int from,
int till) { int till) {
Expects(view->delegate() == this); Expects(view->delegate() == this);
@ -538,22 +538,22 @@ bool InnerWidget::elementIntersectsRange(
return (top < till && bottom > from); return (top < till && bottom > from);
} }
void InnerWidget::elementStartStickerLoop(not_null<const Element *> view) { void InnerWidget::elementStartStickerLoop(not_null<const Element*> view) {
} }
void InnerWidget::elementShowPollResults( void InnerWidget::elementShowPollResults(
not_null<PollData *> poll, not_null<PollData*> poll,
FullMsgId context) { FullMsgId context) {
} }
void InnerWidget::elementOpenPhoto( void InnerWidget::elementOpenPhoto(
not_null<PhotoData *> photo, not_null<PhotoData*> photo,
FullMsgId context) { FullMsgId context) {
_controller->openPhoto(photo, {context}); _controller->openPhoto(photo, {context});
} }
void InnerWidget::elementOpenDocument( void InnerWidget::elementOpenDocument(
not_null<DocumentData *> document, not_null<DocumentData*> document,
FullMsgId context, FullMsgId context,
bool showInMediaView) { bool showInMediaView) {
_controller->openDocument(document, showInMediaView, {context}); _controller->openDocument(document, showInMediaView, {context});
@ -574,11 +574,11 @@ bool InnerWidget::elementAnimationsPaused() {
return _controller->isGifPausedAtLeastFor(Window::GifPauseReason::Any); return _controller->isGifPausedAtLeastFor(Window::GifPauseReason::Any);
} }
bool InnerWidget::elementHideReply(not_null<const Element *> view) { bool InnerWidget::elementHideReply(not_null<const Element*> view) {
return true; return true;
} }
bool InnerWidget::elementShownUnread(not_null<const Element *> view) { bool InnerWidget::elementShownUnread(not_null<const Element*> view) {
return false; return false;
} }
@ -592,36 +592,36 @@ void InnerWidget::elementSearchInList(
const FullMsgId &context) { const FullMsgId &context) {
} }
void InnerWidget::elementHandleViaClick(not_null<UserData *> bot) { void InnerWidget::elementHandleViaClick(not_null<UserData*> bot) {
} }
bool InnerWidget::elementIsChatWide() { bool InnerWidget::elementIsChatWide() {
return _isChatWide; return _isChatWide;
} }
not_null<Ui::PathShiftGradient *> InnerWidget::elementPathShiftGradient() { not_null<Ui::PathShiftGradient*> InnerWidget::elementPathShiftGradient() {
return _pathGradient.get(); return _pathGradient.get();
} }
void InnerWidget::elementReplyTo(const FullReplyTo &to) { void InnerWidget::elementReplyTo(const FullReplyTo &to) {
} }
void InnerWidget::elementStartInteraction(not_null<const Element *> view) { void InnerWidget::elementStartInteraction(not_null<const Element*> view) {
} }
void InnerWidget::elementStartPremium( void InnerWidget::elementStartPremium(
not_null<const Element *> view, not_null<const Element*> view,
Element *replacing) { Element *replacing) {
} }
void InnerWidget::elementCancelPremium(not_null<const Element *> view) { void InnerWidget::elementCancelPremium(not_null<const Element*> view) {
} }
QString InnerWidget::elementAuthorRank(not_null<const Element *> view) { QString InnerWidget::elementAuthorRank(not_null<const Element*> view) {
return {}; return {};
} }
void InnerWidget::saveState(not_null<SectionMemento *> memento) { void InnerWidget::saveState(not_null<SectionMemento*> memento) {
if (!_filterChanged) { if (!_filterChanged) {
for (auto &item : _items) { for (auto &item : _items) {
item.clearView(); item.clearView();
@ -636,7 +636,7 @@ void InnerWidget::saveState(not_null<SectionMemento *> memento) {
_upLoaded = _downLoaded = true; // Don't load or handle anything anymore. _upLoaded = _downLoaded = true; // Don't load or handle anything anymore.
} }
void InnerWidget::restoreState(not_null<SectionMemento *> memento) { void InnerWidget::restoreState(not_null<SectionMemento*> memento) {
_items = memento->takeItems(); _items = memento->takeItems();
for (auto &item : _items) { for (auto &item : _items) {
item.refreshView(this); item.refreshView(this);
@ -650,7 +650,7 @@ void InnerWidget::restoreState(not_null<SectionMemento *> memento) {
} }
void InnerWidget::addEvents(Direction direction) { void InnerWidget::addEvents(Direction direction) {
auto messages = AyuMessages::getInstance().getEditedMessages(_item); auto messages = AyuMessages::getEditedMessages(_item);
if (messages.empty()) { if (messages.empty()) {
return; return;
} }
@ -803,7 +803,7 @@ void InnerWidget::paintEvent(QPaintEvent *e) {
context.translate(0, top); context.translate(0, top);
p.translate(0, -top); p.translate(0, -top);
enumerateUserpics([&](not_null<Element *> view, int userpicTop) enumerateUserpics([&](not_null<Element*> view, int userpicTop)
{ {
// stop the enumeration if the userpic is below the painted rect // stop the enumeration if the userpic is below the painted rect
if (userpicTop >= clip.top() + clip.height()) { if (userpicTop >= clip.top() + clip.height()) {
@ -826,7 +826,7 @@ void InnerWidget::paintEvent(QPaintEvent *e) {
auto dateHeight = st::msgServicePadding.bottom() + st::msgServiceFont->height + st::msgServicePadding.top(); auto dateHeight = st::msgServicePadding.bottom() + st::msgServiceFont->height + st::msgServicePadding.top();
auto scrollDateOpacity = _scrollDateOpacity.value(_scrollDateShown ? 1. : 0.); auto scrollDateOpacity = _scrollDateOpacity.value(_scrollDateShown ? 1. : 0.);
enumerateDates([&](not_null<Element *> view, int itemtop, int dateTop) enumerateDates([&](not_null<Element*> view, int itemtop, int dateTop)
{ {
// stop the enumeration if the date is above the painted rect // stop the enumeration if the date is above the painted rect
if (dateTop + dateHeight <= clip.top()) { if (dateTop + dateHeight <= clip.top()) {
@ -883,7 +883,7 @@ auto InnerWidget::viewForItem(const HistoryItem *item) -> Element * {
return nullptr; return nullptr;
} }
void InnerWidget::paintEmpty(Painter &p, not_null<const Ui::ChatStyle *> st) { void InnerWidget::paintEmpty(Painter &p, not_null<const Ui::ChatStyle*> st) {
auto rectWidth = st::historyAdminLogEmptyWidth; auto rectWidth = st::historyAdminLogEmptyWidth;
auto innerWidth = rectWidth - st::historyAdminLogEmptyPadding.left() - st::historyAdminLogEmptyPadding.right(); auto innerWidth = rectWidth - st::historyAdminLogEmptyPadding.left() - st::historyAdminLogEmptyPadding.right();
auto rectHeight = st::historyAdminLogEmptyPadding.top() + _emptyText.countHeight(innerWidth) auto rectHeight = st::historyAdminLogEmptyPadding.top() + _emptyText.countHeight(innerWidth)
@ -987,11 +987,11 @@ void InnerWidget::showContextMenu(QContextMenuEvent *e, bool showFromTouch) {
? Element::Hovered() ? Element::Hovered()
: Element::HoveredLink(); : Element::HoveredLink();
const auto lnkPhoto = link const auto lnkPhoto = link
? reinterpret_cast<PhotoData *>( ? reinterpret_cast<PhotoData*>(
link->property(kPhotoLinkMediaProperty).toULongLong()) link->property(kPhotoLinkMediaProperty).toULongLong())
: nullptr; : nullptr;
const auto lnkDocument = link const auto lnkDocument = link
? reinterpret_cast<DocumentData *>( ? reinterpret_cast<DocumentData*>(
link->property(kDocumentLinkMediaProperty).toULongLong()) link->property(kDocumentLinkMediaProperty).toULongLong())
: nullptr; : nullptr;
auto lnkIsVideo = lnkDocument ? lnkDocument->isVideoFile() : false; auto lnkIsVideo = lnkDocument ? lnkDocument->isVideoFile() : false;
@ -1179,7 +1179,7 @@ void InnerWidget::showContextMenu(QContextMenuEvent *e, bool showFromTouch) {
} }
} }
void InnerWidget::savePhotoToFile(not_null<PhotoData *> photo) { void InnerWidget::savePhotoToFile(not_null<PhotoData*> photo) {
const auto media = photo->activeMediaView(); const auto media = photo->activeMediaView();
if (photo->isNull() || !media || !media->loaded()) { if (photo->isNull() || !media || !media->loaded()) {
return; return;
@ -1200,14 +1200,14 @@ void InnerWidget::savePhotoToFile(not_null<PhotoData *> photo) {
})); }));
} }
void InnerWidget::saveDocumentToFile(not_null<DocumentData *> document) { void InnerWidget::saveDocumentToFile(not_null<DocumentData*> document) {
DocumentSaveClickHandler::Save( DocumentSaveClickHandler::Save(
Data::FileOrigin(), Data::FileOrigin(),
document, document,
DocumentSaveClickHandler::Mode::ToNewFile); DocumentSaveClickHandler::Mode::ToNewFile);
} }
void InnerWidget::copyContextImage(not_null<PhotoData *> photo) { void InnerWidget::copyContextImage(not_null<PhotoData*> photo) {
const auto media = photo->activeMediaView(); const auto media = photo->activeMediaView();
if (photo->isNull() || !media || !media->loaded()) { if (photo->isNull() || !media || !media->loaded()) {
return; return;
@ -1219,15 +1219,15 @@ void InnerWidget::copySelectedText() {
TextUtilities::SetClipboardText(getSelectedText()); TextUtilities::SetClipboardText(getSelectedText());
} }
void InnerWidget::showStickerPackInfo(not_null<DocumentData *> document) { void InnerWidget::showStickerPackInfo(not_null<DocumentData*> document) {
StickerSetBox::Show(_controller->uiShow(), document); StickerSetBox::Show(_controller->uiShow(), document);
} }
void InnerWidget::cancelContextDownload(not_null<DocumentData *> document) { void InnerWidget::cancelContextDownload(not_null<DocumentData*> document) {
document->cancel(); document->cancel();
} }
void InnerWidget::showContextInFolder(not_null<DocumentData *> document) { void InnerWidget::showContextInFolder(not_null<DocumentData*> document) {
const auto filepath = document->filepath(true); const auto filepath = document->filepath(true);
if (!filepath.isEmpty()) { if (!filepath.isEmpty()) {
File::ShowInFolder(filepath); File::ShowInFolder(filepath);
@ -1406,7 +1406,7 @@ void InnerWidget::mouseActionFinish(const QPoint &screenPos, Qt::MouseButton but
.elementDelegate = [weak = Ui::MakeWeak(this)] .elementDelegate = [weak = Ui::MakeWeak(this)]
{ {
return weak return weak
? (ElementDelegate *)weak ? (ElementDelegate*) weak
: nullptr; : nullptr;
}, },
.sessionWindow = base::make_weak(_controller), .sessionWindow = base::make_weak(_controller),
@ -1503,7 +1503,7 @@ void InnerWidget::updateSelected() {
if (!dragState.link && itemPoint.x() >= st::historyPhotoLeft if (!dragState.link && itemPoint.x() >= st::historyPhotoLeft
&& itemPoint.x() < st::historyPhotoLeft + st::msgPhotoSize) { && itemPoint.x() < st::historyPhotoLeft + st::msgPhotoSize) {
if (!item->isService() && view->hasFromPhoto()) { if (!item->isService() && view->hasFromPhoto()) {
enumerateUserpics([&](not_null<Element *> view, int userpicTop) enumerateUserpics([&](not_null<Element*> view, int userpicTop)
{ {
// stop enumeration if the userpic is below our point // stop enumeration if the userpic is below our point
if (userpicTop > point.y()) { if (userpicTop > point.y()) {
@ -1594,7 +1594,7 @@ void InnerWidget::performDrag() {
if (_mouseAction != MouseAction::Dragging) return; if (_mouseAction != MouseAction::Dragging) return;
} }
int InnerWidget::itemTop(not_null<const Element *> view) const { int InnerWidget::itemTop(not_null<const Element*> view) const {
return _itemsTop + view->y(); return _itemsTop + view->y();
} }
@ -1607,11 +1607,11 @@ void InnerWidget::repaintItem(const Element *view) {
update(0, top + range.top, width(), range.height); update(0, top + range.top, width(), range.height);
} }
void InnerWidget::resizeItem(not_null<Element *> view) { void InnerWidget::resizeItem(not_null<Element*> view) {
updateSize(); updateSize();
} }
void InnerWidget::refreshItem(not_null<const Element *> view) { void InnerWidget::refreshItem(not_null<const Element*> view) {
// No need to refresh views in admin log. // No need to refresh views in admin log.
// sogl // sogl
} }

View file

@ -50,19 +50,19 @@ class InnerWidget final
public: public:
InnerWidget( InnerWidget(
QWidget *parent, QWidget *parent,
not_null<Window::SessionController *> controller, not_null<Window::SessionController*> controller,
not_null<PeerData *> peer, not_null<PeerData*> peer,
not_null<HistoryItem *> item); not_null<HistoryItem*> item);
[[nodiscard]] Main::Session &session() const; [[nodiscard]] Main::Session &session() const;
[[nodiscard]] not_null<Ui::ChatTheme *> theme() const { [[nodiscard]] not_null<Ui::ChatTheme*> theme() const {
return _theme.get(); return _theme.get();
} }
[[nodiscard]] rpl::producer<int> scrollToSignal() const; [[nodiscard]] rpl::producer<int> scrollToSignal() const;
[[nodiscard]] not_null<PeerData *> channel() const { [[nodiscard]] not_null<PeerData*> channel() const {
return _peer; return _peer;
} }
@ -74,8 +74,8 @@ public:
return TWidget::resizeToWidth(newWidth); return TWidget::resizeToWidth(newWidth);
} }
void saveState(not_null<SectionMemento *> memento); void saveState(not_null<SectionMemento*> memento);
void restoreState(not_null<SectionMemento *> memento); void restoreState(not_null<SectionMemento*> memento);
// Ui::AbstractTooltipShower interface. // Ui::AbstractTooltipShower interface.
QString tooltipText() const override; QString tooltipText() const override;
@ -85,22 +85,22 @@ public:
// HistoryView::ElementDelegate interface. // HistoryView::ElementDelegate interface.
HistoryView::Context elementContext() override; HistoryView::Context elementContext() override;
bool elementUnderCursor( bool elementUnderCursor(
not_null<const HistoryView::Element *> view) override; not_null<const HistoryView::Element*> view) override;
bool elementInSelectionMode() override; bool elementInSelectionMode() override;
bool elementIntersectsRange( bool elementIntersectsRange(
not_null<const HistoryView::Element *> view, not_null<const HistoryView::Element*> view,
int from, int from,
int till) override; int till) override;
void elementStartStickerLoop( void elementStartStickerLoop(
not_null<const HistoryView::Element *> view) override; not_null<const HistoryView::Element*> view) override;
void elementShowPollResults( void elementShowPollResults(
not_null<PollData *> poll, not_null<PollData*> poll,
FullMsgId context) override; FullMsgId context) override;
void elementOpenPhoto( void elementOpenPhoto(
not_null<PhotoData *> photo, not_null<PhotoData*> photo,
FullMsgId context) override; FullMsgId context) override;
void elementOpenDocument( void elementOpenDocument(
not_null<DocumentData *> document, not_null<DocumentData*> document,
FullMsgId context, FullMsgId context,
bool showInMediaView = false) override; bool showInMediaView = false) override;
void elementCancelUpload(const FullMsgId &context) override; void elementCancelUpload(const FullMsgId &context) override;
@ -109,28 +109,28 @@ public:
Fn<void()> hiddenCallback) override; Fn<void()> hiddenCallback) override;
bool elementAnimationsPaused() override; bool elementAnimationsPaused() override;
bool elementHideReply( bool elementHideReply(
not_null<const HistoryView::Element *> view) override; not_null<const HistoryView::Element*> view) override;
bool elementShownUnread( bool elementShownUnread(
not_null<const HistoryView::Element *> view) override; not_null<const HistoryView::Element*> view) override;
void elementSendBotCommand( void elementSendBotCommand(
const QString &command, const QString &command,
const FullMsgId &context) override; const FullMsgId &context) override;
void elementSearchInList( void elementSearchInList(
const QString &query, const QString &query,
const FullMsgId &context) override; const FullMsgId &context) override;
void elementHandleViaClick(not_null<UserData *> bot) override; void elementHandleViaClick(not_null<UserData*> bot) override;
bool elementIsChatWide() override; bool elementIsChatWide() override;
not_null<Ui::PathShiftGradient *> elementPathShiftGradient() override; not_null<Ui::PathShiftGradient*> elementPathShiftGradient() override;
void elementReplyTo(const FullReplyTo &to) override; void elementReplyTo(const FullReplyTo &to) override;
void elementStartInteraction( void elementStartInteraction(
not_null<const HistoryView::Element *> view) override; not_null<const HistoryView::Element*> view) override;
void elementStartPremium( void elementStartPremium(
not_null<const HistoryView::Element *> view, not_null<const HistoryView::Element*> view,
HistoryView::Element *replacing) override; HistoryView::Element *replacing) override;
void elementCancelPremium( void elementCancelPremium(
not_null<const HistoryView::Element *> view) override; not_null<const HistoryView::Element*> view) override;
QString elementAuthorRank( QString elementAuthorRank(
not_null<const HistoryView::Element *> view) override; not_null<const HistoryView::Element*> view) override;
~InnerWidget(); ~InnerWidget();
@ -186,19 +186,19 @@ private:
void mouseActionCancel(); void mouseActionCancel();
void updateSelected(); void updateSelected();
void performDrag(); void performDrag();
int itemTop(not_null<const Element *> view) const; int itemTop(not_null<const Element*> view) const;
void repaintItem(const Element *view); void repaintItem(const Element *view);
void refreshItem(not_null<const Element *> view); void refreshItem(not_null<const Element*> view);
void resizeItem(not_null<Element *> view); void resizeItem(not_null<Element*> view);
QPoint mapPointToItem(QPoint point, const Element *view) const; QPoint mapPointToItem(QPoint point, const Element *view) const;
void showContextMenu(QContextMenuEvent *e, bool showFromTouch = false); void showContextMenu(QContextMenuEvent *e, bool showFromTouch = false);
void savePhotoToFile(not_null<PhotoData *> photo); void savePhotoToFile(not_null<PhotoData*> photo);
void saveDocumentToFile(not_null<DocumentData *> document); void saveDocumentToFile(not_null<DocumentData*> document);
void copyContextImage(not_null<PhotoData *> photo); void copyContextImage(not_null<PhotoData*> photo);
void showStickerPackInfo(not_null<DocumentData *> document); void showStickerPackInfo(not_null<DocumentData*> document);
void cancelContextDownload(not_null<DocumentData *> document); void cancelContextDownload(not_null<DocumentData*> document);
void showContextInFolder(not_null<DocumentData *> document); void showContextInFolder(not_null<DocumentData*> document);
void openContextGif(FullMsgId itemId); void openContextGif(FullMsgId itemId);
void copyContextText(FullMsgId itemId); void copyContextText(FullMsgId itemId);
void copySelectedText(); void copySelectedText();
@ -208,7 +208,7 @@ private:
void itemsAdded(Direction direction, int addedCount); void itemsAdded(Direction direction, int addedCount);
void updateSize(); void updateSize();
void updateEmptyText(); void updateEmptyText();
void paintEmpty(Painter &p, not_null<const Ui::ChatStyle *> st); void paintEmpty(Painter &p, not_null<const Ui::ChatStyle*> st);
void addEvents(Direction direction); void addEvents(Direction direction);
Element *viewForItem(const HistoryItem *item); Element *viewForItem(const HistoryItem *item);
@ -243,10 +243,10 @@ private:
template<typename Method> template<typename Method>
void enumerateDates(Method method); void enumerateDates(Method method);
const not_null<Window::SessionController *> _controller; const not_null<Window::SessionController*> _controller;
const not_null<PeerData *> _peer; const not_null<PeerData*> _peer;
const not_null<HistoryItem *> _item; const not_null<HistoryItem*> _item;
const not_null<History *> _history; const not_null<History*> _history;
MTP::Sender _api; MTP::Sender _api;
const std::unique_ptr<Ui::PathShiftGradient> _pathGradient; const std::unique_ptr<Ui::PathShiftGradient> _pathGradient;
@ -254,11 +254,11 @@ private:
std::vector<OwnedItem> _items; std::vector<OwnedItem> _items;
std::set<uint64> _eventIds; std::set<uint64> _eventIds;
std::map<not_null<const HistoryItem *>, not_null<Element *>> _itemsByData; std::map<not_null<const HistoryItem*>, not_null<Element*>> _itemsByData;
base::flat_map<not_null<const HistoryItem *>, TimeId> _itemDates; base::flat_map<not_null<const HistoryItem*>, TimeId> _itemDates;
base::flat_set<FullMsgId> _animatedStickersPlayed; base::flat_set<FullMsgId> _animatedStickersPlayed;
base::flat_map<not_null<PeerData *>, Ui::PeerUserpicView> _userpics; base::flat_map<not_null<PeerData*>, Ui::PeerUserpicView> _userpics;
base::flat_map<not_null<PeerData *>, Ui::PeerUserpicView> _userpicsCache; base::flat_map<not_null<PeerData*>, Ui::PeerUserpicView> _userpicsCache;
int _itemsTop = 0; int _itemsTop = 0;
int _itemsWidth = 0; int _itemsWidth = 0;
int _itemsHeight = 0; int _itemsHeight = 0;

View file

@ -5,7 +5,7 @@
// //
// Copyright @Radolyn, 2023 // Copyright @Radolyn, 2023
#include "ayu/ui/sections/edited/edited_log_item.h" #include "ayu/ui/sections/edited/edited_log_item.h"
#include <ayu/database/entities.h> #include "ayu/data/entities.h"
#include "api/api_chat_participants.h" #include "api/api_chat_participants.h"
#include "api/api_text_entities.h" #include "api/api_text_entities.h"
@ -51,7 +51,7 @@ const auto CollectChanges = [](
}; };
TextWithEntities GenerateAdminChangeText( TextWithEntities GenerateAdminChangeText(
not_null<ChannelData *> channel, not_null<ChannelData*> channel,
const TextWithEntities &user, const TextWithEntities &user,
ChatAdminRightsInfo newRights, ChatAdminRightsInfo newRights,
ChatAdminRightsInfo prevRights) { ChatAdminRightsInfo prevRights) {
@ -363,7 +363,7 @@ TextWithEntities GenerateInviteLinkChangeText(
}; };
auto GenerateParticipantString( auto GenerateParticipantString(
not_null<Main::Session *> session, not_null<Main::Session*> session,
PeerId participantId) { PeerId participantId) {
// User name in "User name (@username)" format with entities. // User name in "User name (@username)" format with entities.
const auto peer = session->data().peer(participantId); const auto peer = session->data().peer(participantId);
@ -401,7 +401,7 @@ auto GenerateParticipantString(
} }
auto GenerateParticipantChangeText( auto GenerateParticipantChangeText(
not_null<ChannelData *> channel, not_null<ChannelData*> channel,
const Api::ChatParticipant &participant, const Api::ChatParticipant &participant,
std::optional<Api::ChatParticipant> oldParticipant = std::nullopt) { std::optional<Api::ChatParticipant> oldParticipant = std::nullopt) {
using Type = Api::ChatParticipant::Type; using Type = Api::ChatParticipant::Type;
@ -501,7 +501,7 @@ auto GenerateParticipantChangeText(
} }
TextWithEntities GenerateParticipantChangeText( TextWithEntities GenerateParticipantChangeText(
not_null<ChannelData *> channel, not_null<ChannelData*> channel,
const MTPChannelParticipant &participant, const MTPChannelParticipant &participant,
std::optional<MTPChannelParticipant> oldParticipant = std::nullopt) { std::optional<MTPChannelParticipant> oldParticipant = std::nullopt) {
return GenerateParticipantChangeText( return GenerateParticipantChangeText(
@ -515,7 +515,7 @@ TextWithEntities GenerateParticipantChangeText(
} }
TextWithEntities GenerateDefaultBannedRightsChangeText( TextWithEntities GenerateDefaultBannedRightsChangeText(
not_null<ChannelData *> channel, not_null<ChannelData*> channel,
ChatRestrictionsInfo rights, ChatRestrictionsInfo rights,
ChatRestrictionsInfo oldRights) { ChatRestrictionsInfo oldRights) {
auto result = TextWithEntities{ auto result = TextWithEntities{
@ -553,7 +553,7 @@ TextWithEntities GenerateDefaultBannedRightsChangeText(
} }
[[nodiscard]] TextWithEntities GenerateTopicLink( [[nodiscard]] TextWithEntities GenerateTopicLink(
not_null<ChannelData *> channel, not_null<ChannelData*> channel,
const MTPForumTopic &topic) { const MTPForumTopic &topic) {
return topic.match([&](const MTPDforumTopic &data) return topic.match([&](const MTPDforumTopic &data)
{ {
@ -578,8 +578,8 @@ OwnedItem::OwnedItem(std::nullptr_t) {
} }
OwnedItem::OwnedItem( OwnedItem::OwnedItem(
not_null<HistoryView::ElementDelegate *> delegate, not_null<HistoryView::ElementDelegate*> delegate,
not_null<HistoryItem *> data) not_null<HistoryItem*> data)
: _data(data), _view(_data->createView(delegate)) { : _data(data), _view(_data->createView(delegate)) {
} }
@ -601,7 +601,7 @@ OwnedItem::~OwnedItem() {
} }
void OwnedItem::refreshView( void OwnedItem::refreshView(
not_null<HistoryView::ElementDelegate *> delegate) { not_null<HistoryView::ElementDelegate*> delegate) {
_view = _data->createView(delegate); _view = _data->createView(delegate);
} }
@ -610,8 +610,8 @@ void OwnedItem::clearView() {
} }
void GenerateItems( void GenerateItems(
not_null<HistoryView::ElementDelegate *> delegate, not_null<HistoryView::ElementDelegate*> delegate,
not_null<History *> history, not_null<History*> history,
EditedMessage message, EditedMessage message,
Fn<void(OwnedItem item, TimeId sentDate, MsgId)> callback) { Fn<void(OwnedItem item, TimeId sentDate, MsgId)> callback) {
const auto session = &history->session(); const auto session = &history->session();
@ -621,14 +621,14 @@ void GenerateItems(
from = history->owner().channelLoaded(message.fromId); from = history->owner().channelLoaded(message.fromId);
} }
if (!from) { if (!from) {
from = reinterpret_cast<PeerData *>(history->owner().chatLoaded(message.fromId)); from = reinterpret_cast<PeerData*>(history->owner().chatLoaded(message.fromId));
} }
if (!from) { if (!from) {
return; return;
} }
const auto date = message.entityCreateDate; const auto date = message.entityCreateDate;
const auto addPart = [&]( const auto addPart = [&](
not_null<HistoryItem *> item, not_null<HistoryItem*> item,
TimeId sentDate = 0, TimeId sentDate = 0,
MsgId realId = MsgId()) MsgId realId = MsgId())
{ {

View file

@ -6,7 +6,7 @@
// Copyright @Radolyn, 2023 // Copyright @Radolyn, 2023
#pragma once #pragma once
#include "ayu/database/entities.h" #include "ayu/data/entities.h"
class History; class History;
@ -20,8 +20,8 @@ namespace EditedLog {
class OwnedItem; class OwnedItem;
void GenerateItems( void GenerateItems(
not_null<HistoryView::ElementDelegate *> delegate, not_null<HistoryView::ElementDelegate*> delegate,
not_null<History *> history, not_null<History*> history,
EditedMessage message, EditedMessage message,
Fn<void(OwnedItem item, TimeId sentDate, MsgId)> callback); Fn<void(OwnedItem item, TimeId sentDate, MsgId)> callback);
@ -31,8 +31,8 @@ class OwnedItem
public: public:
OwnedItem(std::nullptr_t = nullptr); OwnedItem(std::nullptr_t = nullptr);
OwnedItem( OwnedItem(
not_null<HistoryView::ElementDelegate *> delegate, not_null<HistoryView::ElementDelegate*> delegate,
not_null<HistoryItem *> data); not_null<HistoryItem*> data);
OwnedItem(const OwnedItem &other) = delete; OwnedItem(const OwnedItem &other) = delete;
OwnedItem &operator=(const OwnedItem &other) = delete; OwnedItem &operator=(const OwnedItem &other) = delete;
OwnedItem(OwnedItem &&other); OwnedItem(OwnedItem &&other);
@ -47,11 +47,11 @@ public:
return get(); return get();
} }
[[nodiscard]] operator HistoryView::Element *() const { [[nodiscard]] operator HistoryView::Element*() const {
return get(); return get();
} }
void refreshView(not_null<HistoryView::ElementDelegate *> delegate); void refreshView(not_null<HistoryView::ElementDelegate*> delegate);
void clearView(); void clearView();
private: private:

View file

@ -32,8 +32,8 @@ class FixedBar final : public TWidget
public: public:
FixedBar( FixedBar(
QWidget *parent, QWidget *parent,
not_null<Window::SessionController *> controller, not_null<Window::SessionController*> controller,
not_null<PeerData *> peer); not_null<PeerData*> peer);
// When animating mode is enabled the content is hidden and the // When animating mode is enabled the content is hidden and the
// whole fixed bar acts like a back button. // whole fixed bar acts like a back button.
@ -47,8 +47,8 @@ protected:
int resizeGetHeight(int newWidth) override; int resizeGetHeight(int newWidth) override;
private: private:
not_null<Window::SessionController *> _controller; not_null<Window::SessionController*> _controller;
not_null<PeerData *> _peer; not_null<PeerData*> _peer;
object_ptr<Profile::BackButton> _backButton; object_ptr<Profile::BackButton> _backButton;
object_ptr<Ui::CrossButton> _cancel; object_ptr<Ui::CrossButton> _cancel;
@ -57,7 +57,7 @@ private:
object_ptr<Window::SectionWidget> SectionMemento::createWidget( object_ptr<Window::SectionWidget> SectionMemento::createWidget(
QWidget *parent, QWidget *parent,
not_null<Window::SessionController *> controller, not_null<Window::SessionController*> controller,
Window::Column column, Window::Column column,
const QRect &geometry) { const QRect &geometry) {
if (column == Window::Column::Third) { if (column == Window::Column::Third) {
@ -70,8 +70,8 @@ object_ptr<Window::SectionWidget> SectionMemento::createWidget(
FixedBar::FixedBar( FixedBar::FixedBar(
QWidget *parent, QWidget *parent,
not_null<Window::SessionController *> controller, not_null<Window::SessionController*> controller,
not_null<PeerData *> peer) not_null<PeerData*> peer)
: TWidget(parent), _controller(controller), _peer(peer), _backButton( : TWidget(parent), _controller(controller), _peer(peer), _backButton(
this, this,
&controller->session(), &controller->session(),
@ -140,10 +140,10 @@ void FixedBar::mousePressEvent(QMouseEvent *e) {
Widget::Widget( Widget::Widget(
QWidget *parent, QWidget *parent,
not_null<Window::SessionController *> controller, not_null<Window::SessionController*> controller,
not_null<PeerData *> peer, not_null<PeerData*> peer,
not_null<HistoryItem *> item) not_null<HistoryItem*> item)
: Window::SectionWidget(parent, controller, rpl::single<PeerData *>(peer)), : Window::SectionWidget(parent, controller, rpl::single<PeerData*>(peer)),
_scroll(this, st::historyScroll, false), _scroll(this, st::historyScroll, false),
_fixedBar(this, controller, peer), _fixedBar(this, controller, peer),
_fixedBarShadow(this), _fixedBarShadow(this),
@ -189,7 +189,7 @@ void Widget::updateAdaptiveLayout() {
_fixedBar->height()); _fixedBar->height());
} }
not_null<PeerData *> Widget::channel() const { not_null<PeerData*> Widget::channel() const {
return _inner->channel(); return _inner->channel();
} }
@ -212,9 +212,9 @@ void Widget::doSetInnerFocus() {
} }
bool Widget::showInternal( bool Widget::showInternal(
not_null<Window::SectionMemento *> memento, not_null<Window::SectionMemento*> memento,
const Window::SectionShow &params) { const Window::SectionShow &params) {
if (auto logMemento = dynamic_cast<SectionMemento *>(memento.get())) { if (auto logMemento = dynamic_cast<SectionMemento*>(memento.get())) {
if (logMemento->getPeer() == channel()) { if (logMemento->getPeer() == channel()) {
restoreState(logMemento); restoreState(logMemento);
return true; return true;
@ -223,7 +223,7 @@ bool Widget::showInternal(
return false; return false;
} }
void Widget::setInternalState(const QRect &geometry, not_null<SectionMemento *> memento) { void Widget::setInternalState(const QRect &geometry, not_null<SectionMemento*> memento) {
setGeometry(geometry); setGeometry(geometry);
Ui::SendPendingMoveResizeEvents(this); Ui::SendPendingMoveResizeEvents(this);
restoreState(memento); restoreState(memento);
@ -239,12 +239,12 @@ std::shared_ptr<Window::SectionMemento> Widget::createMemento() {
return result; return result;
} }
void Widget::saveState(not_null<SectionMemento *> memento) { void Widget::saveState(not_null<SectionMemento*> memento) {
memento->setScrollTop(_scroll->scrollTop()); memento->setScrollTop(_scroll->scrollTop());
_inner->saveState(memento); _inner->saveState(memento);
} }
void Widget::restoreState(not_null<SectionMemento *> memento) { void Widget::restoreState(not_null<SectionMemento*> memento) {
_inner->restoreState(memento); _inner->restoreState(memento);
auto scrollTop = memento->getScrollTop(); auto scrollTop = memento->getScrollTop();
_scroll->scrollToY(scrollTop); _scroll->scrollToY(scrollTop);

View file

@ -33,11 +33,11 @@ class Widget final : public Window::SectionWidget
public: public:
Widget( Widget(
QWidget *parent, QWidget *parent,
not_null<Window::SessionController *> controller, not_null<Window::SessionController*> controller,
not_null<PeerData *> peer, not_null<PeerData*> peer,
not_null<HistoryItem *> item); not_null<HistoryItem*> item);
not_null<PeerData *> channel() const; not_null<PeerData*> channel() const;
Dialogs::RowDescriptor activeChat() const override; Dialogs::RowDescriptor activeChat() const override;
bool hasTopBarShadow() const override { bool hasTopBarShadow() const override {
@ -47,11 +47,11 @@ public:
QPixmap grabForShowAnimation(const Window::SectionSlideParams &params) override; QPixmap grabForShowAnimation(const Window::SectionSlideParams &params) override;
bool showInternal( bool showInternal(
not_null<Window::SectionMemento *> memento, not_null<Window::SectionMemento*> memento,
const Window::SectionShow &params) override; const Window::SectionShow &params) override;
std::shared_ptr<Window::SectionMemento> createMemento() override; std::shared_ptr<Window::SectionMemento> createMemento() override;
void setInternalState(const QRect &geometry, not_null<SectionMemento *> memento); void setInternalState(const QRect &geometry, not_null<SectionMemento*> memento);
// Float player interface. // Float player interface.
bool floatPlayerHandleWheelEvent(QEvent *e) override; bool floatPlayerHandleWheelEvent(QEvent *e) override;
@ -69,15 +69,15 @@ protected:
private: private:
void onScroll(); void onScroll();
void updateAdaptiveLayout(); void updateAdaptiveLayout();
void saveState(not_null<SectionMemento *> memento); void saveState(not_null<SectionMemento*> memento);
void restoreState(not_null<SectionMemento *> memento); void restoreState(not_null<SectionMemento*> memento);
void setupShortcuts(); void setupShortcuts();
object_ptr<Ui::ScrollArea> _scroll; object_ptr<Ui::ScrollArea> _scroll;
QPointer<InnerWidget> _inner; QPointer<InnerWidget> _inner;
object_ptr<FixedBar> _fixedBar; object_ptr<FixedBar> _fixedBar;
object_ptr<Ui::PlainShadow> _fixedBarShadow; object_ptr<Ui::PlainShadow> _fixedBarShadow;
not_null<HistoryItem *> _item; not_null<HistoryItem*> _item;
}; };
@ -86,18 +86,18 @@ class SectionMemento : public Window::SectionMemento
public: public:
using Element = HistoryView::Element; using Element = HistoryView::Element;
SectionMemento(not_null<PeerData *> peer, not_null<HistoryItem *> item) SectionMemento(not_null<PeerData*> peer, not_null<HistoryItem*> item)
: _peer(peer), : _peer(peer),
_item(item) { _item(item) {
} }
object_ptr<Window::SectionWidget> createWidget( object_ptr<Window::SectionWidget> createWidget(
QWidget *parent, QWidget *parent,
not_null<Window::SessionController *> controller, not_null<Window::SessionController*> controller,
Window::Column column, Window::Column column,
const QRect &geometry) override; const QRect &geometry) override;
not_null<PeerData *> getPeer() const { not_null<PeerData*> getPeer() const {
return _peer; return _peer;
} }
@ -137,11 +137,11 @@ public:
} }
private: private:
not_null<PeerData *> _peer; not_null<PeerData*> _peer;
not_null<HistoryItem *> _item; not_null<HistoryItem*> _item;
int _scrollTop = 0; int _scrollTop = 0;
std::vector<not_null<UserData *>> _admins; std::vector<not_null<UserData*>> _admins;
std::vector<not_null<UserData *>> _adminsCanEdit; std::vector<not_null<UserData*>> _adminsCanEdit;
std::vector<OwnedItem> _items; std::vector<OwnedItem> _items;
std::set<uint64> _eventIds; std::set<uint64> _eventIds;
bool _upLoaded = false; bool _upLoaded = false;

View file

@ -10,7 +10,7 @@
#include "core/application.h" #include "core/application.h"
#include "styles/style_layers.h" #include "styles/style_layers.h"
#include "ayu/ui/ayu_assets.h" #include "ayu/ui/ayu_logo.h"
#include "main/main_domain.h" #include "main/main_domain.h"
#include "styles/style_ayu_styles.h" #include "styles/style_ayu_styles.h"
#include "ui/painter.h" #include "ui/painter.h"

View file

@ -41,12 +41,12 @@
class PainterHighQualityEnabler; class PainterHighQualityEnabler;
not_null<Ui::RpWidget *> AddInnerToggle(not_null<Ui::VerticalLayout *> container, not_null<Ui::RpWidget*> AddInnerToggle(not_null<Ui::VerticalLayout*> container,
const style::SettingsButton &st, const style::SettingsButton &st,
std::vector<not_null<Ui::AbstractCheckView *>> innerCheckViews, std::vector<not_null<Ui::AbstractCheckView*>> innerCheckViews,
not_null<Ui::SlideWrap<> *> wrap, not_null<Ui::SlideWrap<>*> wrap,
rpl::producer<QString> buttonLabel, rpl::producer<QString> buttonLabel,
bool toggledWhenAll) { bool toggledWhenAll) {
const auto button = container->add(object_ptr<Ui::SettingsButton>( const auto button = container->add(object_ptr<Ui::SettingsButton>(
container, container,
nullptr, nullptr,
@ -66,7 +66,7 @@ not_null<Ui::RpWidget *> AddInnerToggle(not_null<Ui::VerticalLayout *> container
Ui::ToggleView checkView; Ui::ToggleView checkView;
Ui::Animations::Simple animation; Ui::Animations::Simple animation;
rpl::event_stream<> anyChanges; rpl::event_stream<> anyChanges;
std::vector<not_null<Ui::AbstractCheckView *>> innerChecks; std::vector<not_null<Ui::AbstractCheckView*>> innerChecks;
}; };
const auto state = button->lifetime().make_state<State>( const auto state = button->lifetime().make_state<State>(
st.toggle, st.toggle,
@ -257,16 +257,16 @@ struct NestedEntry
std::function<void(bool)> callback; std::function<void(bool)> callback;
}; };
void AddCollapsibleToggle(not_null<Ui::VerticalLayout *> container, void AddCollapsibleToggle(not_null<Ui::VerticalLayout*> container,
rpl::producer<QString> title, rpl::producer<QString> title,
std::vector<NestedEntry> checkboxes, std::vector<NestedEntry> checkboxes,
bool toggledWhenAll) { bool toggledWhenAll) {
const auto addCheckbox = [&]( const auto addCheckbox = [&](
not_null<Ui::VerticalLayout *> verticalLayout, not_null<Ui::VerticalLayout*> verticalLayout,
const QString &label, const QString &label,
const bool isCheckedOrig) const bool isCheckedOrig)
{ {
const auto checkView = [&]() -> not_null<Ui::AbstractCheckView *> const auto checkView = [&]() -> not_null<Ui::AbstractCheckView*>
{ {
const auto checkbox = verticalLayout->add( const auto checkbox = verticalLayout->add(
object_ptr<Ui::Checkbox>( object_ptr<Ui::Checkbox>(
@ -311,7 +311,7 @@ void AddCollapsibleToggle(not_null<Ui::VerticalLayout *> container,
container, container,
object_ptr<Ui::VerticalLayout>(container)); object_ptr<Ui::VerticalLayout>(container));
const auto verticalLayout = wrap->entity(); const auto verticalLayout = wrap->entity();
auto innerChecks = std::vector<not_null<Ui::AbstractCheckView *>>(); auto innerChecks = std::vector<not_null<Ui::AbstractCheckView*>>();
for (const auto &entry : checkboxes) { for (const auto &entry : checkboxes) {
const auto c = addCheckbox(verticalLayout, entry.checkboxLabel, entry.initial); const auto c = addCheckbox(verticalLayout, entry.checkboxLabel, entry.initial);
c->checkedValue( c->checkedValue(
@ -341,8 +341,8 @@ void AddCollapsibleToggle(not_null<Ui::VerticalLayout *> container,
raw->lifetime()); raw->lifetime());
} }
void AddChooseButtonWithIconAndRightText(not_null<Ui::VerticalLayout *> container, void AddChooseButtonWithIconAndRightText(not_null<Ui::VerticalLayout*> container,
not_null<Window::SessionController *> controller, not_null<Window::SessionController*> controller,
int initialState, int initialState,
std::vector<QString> options, std::vector<QString> options,
rpl::producer<QString> text, rpl::producer<QString> text,
@ -366,7 +366,7 @@ void AddChooseButtonWithIconAndRightText(not_null<Ui::VerticalLayout *> containe
[=] [=]
{ {
controller->show(Box( controller->show(Box(
[=](not_null<Ui::GenericBox *> box) [=](not_null<Ui::GenericBox*> box)
{ {
const auto save = [=](int index) mutable const auto save = [=](int index) mutable
{ {
@ -393,12 +393,12 @@ rpl::producer<QString> Ayu::title() {
Ayu::Ayu( Ayu::Ayu(
QWidget *parent, QWidget *parent,
not_null<Window::SessionController *> controller) not_null<Window::SessionController*> controller)
: Section(parent) { : Section(parent) {
setupContent(controller); setupContent(controller);
} }
void SetupGhostModeToggle(not_null<Ui::VerticalLayout *> container) { void SetupGhostModeToggle(not_null<Ui::VerticalLayout*> container) {
auto settings = &AyuSettings::getInstance(); auto settings = &AyuSettings::getInstance();
AddSubsectionTitle(container, tr::ayu_GhostEssentialsHeader()); AddSubsectionTitle(container, tr::ayu_GhostEssentialsHeader());
@ -444,7 +444,7 @@ void SetupGhostModeToggle(not_null<Ui::VerticalLayout *> container) {
AddCollapsibleToggle(container, tr::ayu_GhostEssentialsHeader(), checkboxes, true); AddCollapsibleToggle(container, tr::ayu_GhostEssentialsHeader(), checkboxes, true);
} }
void SetupReadAfterActionToggle(not_null<Ui::VerticalLayout *> container) { void SetupReadAfterActionToggle(not_null<Ui::VerticalLayout*> container) {
auto settings = &AyuSettings::getInstance(); auto settings = &AyuSettings::getInstance();
std::vector checkboxes{ std::vector checkboxes{
@ -474,7 +474,7 @@ void SetupReadAfterActionToggle(not_null<Ui::VerticalLayout *> container) {
AddCollapsibleToggle(container, tr::ayu_MarkReadAfterAction(), checkboxes, false); AddCollapsibleToggle(container, tr::ayu_MarkReadAfterAction(), checkboxes, false);
} }
void SetupGhostEssentials(not_null<Ui::VerticalLayout *> container) { void SetupGhostEssentials(not_null<Ui::VerticalLayout*> container) {
auto settings = &AyuSettings::getInstance(); auto settings = &AyuSettings::getInstance();
SetupGhostModeToggle(container); SetupGhostModeToggle(container);
@ -504,7 +504,7 @@ void SetupGhostEssentials(not_null<Ui::VerticalLayout *> container) {
container->lifetime()); container->lifetime());
} }
void SetupSpyEssentials(not_null<Ui::VerticalLayout *> container) { void SetupSpyEssentials(not_null<Ui::VerticalLayout*> container) {
auto settings = &AyuSettings::getInstance(); auto settings = &AyuSettings::getInstance();
AddSubsectionTitle(container, tr::ayu_SpyEssentialsHeader()); AddSubsectionTitle(container, tr::ayu_SpyEssentialsHeader());
@ -552,7 +552,7 @@ void SetupSpyEssentials(not_null<Ui::VerticalLayout *> container) {
container->lifetime()); container->lifetime());
} }
void SetupQoLToggles(not_null<Ui::VerticalLayout *> container) { void SetupQoLToggles(not_null<Ui::VerticalLayout*> container) {
auto settings = &AyuSettings::getInstance(); auto settings = &AyuSettings::getInstance();
AddSubsectionTitle(container, tr::ayu_QoLTogglesHeader()); AddSubsectionTitle(container, tr::ayu_QoLTogglesHeader());
@ -718,14 +718,14 @@ void SetupQoLToggles(not_null<Ui::VerticalLayout *> container) {
container->lifetime()); container->lifetime());
} }
void SetupAppIcon(not_null<Ui::VerticalLayout *> container) { void SetupAppIcon(not_null<Ui::VerticalLayout*> container) {
container->add( container->add(
object_ptr<IconPicker>(container), object_ptr<IconPicker>(container),
st::settingsCheckboxPadding); st::settingsCheckboxPadding);
} }
void SetupContextMenuElements(not_null<Ui::VerticalLayout *> container, void SetupContextMenuElements(not_null<Ui::VerticalLayout*> container,
not_null<Window::SessionController *> controller) { not_null<Window::SessionController*> controller) {
auto settings = &AyuSettings::getInstance(); auto settings = &AyuSettings::getInstance();
AddSkip(container); AddSkip(container);
@ -808,7 +808,7 @@ void SetupContextMenuElements(not_null<Ui::VerticalLayout *> container,
AddDividerText(container, tr::ayu_SettingsContextMenuDescription()); AddDividerText(container, tr::ayu_SettingsContextMenuDescription());
} }
void SetupDrawerElements(not_null<Ui::VerticalLayout *> container) { void SetupDrawerElements(not_null<Ui::VerticalLayout*> container) {
auto settings = &AyuSettings::getInstance(); auto settings = &AyuSettings::getInstance();
AddSkip(container); AddSkip(container);
@ -897,7 +897,7 @@ void SetupDrawerElements(not_null<Ui::VerticalLayout *> container) {
#endif #endif
} }
void SetupTrayElements(not_null<Ui::VerticalLayout *> container) { void SetupTrayElements(not_null<Ui::VerticalLayout*> container) {
auto settings = &AyuSettings::getInstance(); auto settings = &AyuSettings::getInstance();
AddSkip(container); AddSkip(container);
@ -944,8 +944,8 @@ void SetupTrayElements(not_null<Ui::VerticalLayout *> container) {
#endif #endif
} }
void SetupShowPeerId(not_null<Ui::VerticalLayout *> container, void SetupShowPeerId(not_null<Ui::VerticalLayout*> container,
not_null<Window::SessionController *> controller) { not_null<Window::SessionController*> controller) {
auto settings = &AyuSettings::getInstance(); auto settings = &AyuSettings::getInstance();
const auto options = std::vector{ const auto options = std::vector{
@ -969,7 +969,7 @@ void SetupShowPeerId(not_null<Ui::VerticalLayout *> container,
[=] [=]
{ {
controller->show(Box( controller->show(Box(
[=](not_null<Ui::GenericBox *> box) [=](not_null<Ui::GenericBox*> box)
{ {
const auto save = [=](int index) const auto save = [=](int index)
{ {
@ -987,7 +987,7 @@ void SetupShowPeerId(not_null<Ui::VerticalLayout *> container,
}); });
} }
void SetupRecentStickersLimitSlider(not_null<Ui::VerticalLayout *> container) { void SetupRecentStickersLimitSlider(not_null<Ui::VerticalLayout*> container) {
auto settings = &AyuSettings::getInstance(); auto settings = &AyuSettings::getInstance();
container->add( container->add(
@ -1033,7 +1033,7 @@ void SetupRecentStickersLimitSlider(not_null<Ui::VerticalLayout *> container) {
}); });
} }
void SetupFonts(not_null<Ui::VerticalLayout *> container, not_null<Window::SessionController *> controller) { void SetupFonts(not_null<Ui::VerticalLayout*> container, not_null<Window::SessionController*> controller) {
const auto settings = &AyuSettings::getInstance(); const auto settings = &AyuSettings::getInstance();
const auto commonButton = AddButtonWithLabel( const auto commonButton = AddButtonWithLabel(
@ -1081,7 +1081,7 @@ void SetupFonts(not_null<Ui::VerticalLayout *> container, not_null<Window::Sessi
}); });
} }
void SetupSendConfirmations(not_null<Ui::VerticalLayout *> container) { void SetupSendConfirmations(not_null<Ui::VerticalLayout*> container) {
auto settings = &AyuSettings::getInstance(); auto settings = &AyuSettings::getInstance();
AddSubsectionTitle(container, tr::ayu_ConfirmationsTitle()); AddSubsectionTitle(container, tr::ayu_ConfirmationsTitle());
@ -1144,7 +1144,7 @@ void SetupSendConfirmations(not_null<Ui::VerticalLayout *> container) {
container->lifetime()); container->lifetime());
} }
void SetupMarks(not_null<Ui::VerticalLayout *> container) { void SetupMarks(not_null<Ui::VerticalLayout*> container) {
auto settings = &AyuSettings::getInstance(); auto settings = &AyuSettings::getInstance();
AddButtonWithLabel( AddButtonWithLabel(
@ -1172,7 +1172,7 @@ void SetupMarks(not_null<Ui::VerticalLayout *> container) {
}); });
} }
void SetupFolderSettings(not_null<Ui::VerticalLayout *> container) { void SetupFolderSettings(not_null<Ui::VerticalLayout*> container) {
auto settings = &AyuSettings::getInstance(); auto settings = &AyuSettings::getInstance();
AddButtonWithIcon( AddButtonWithIcon(
@ -1214,7 +1214,7 @@ void SetupFolderSettings(not_null<Ui::VerticalLayout *> container) {
container->lifetime()); container->lifetime());
} }
void SetupNerdSettings(not_null<Ui::VerticalLayout *> container, not_null<Window::SessionController *> controller) { void SetupNerdSettings(not_null<Ui::VerticalLayout*> container, not_null<Window::SessionController*> controller) {
auto settings = &AyuSettings::getInstance(); auto settings = &AyuSettings::getInstance();
SetupShowPeerId(container, controller); SetupShowPeerId(container, controller);
@ -1258,8 +1258,8 @@ void SetupNerdSettings(not_null<Ui::VerticalLayout *> container, not_null<Window
container->lifetime()); container->lifetime());
} }
void SetupCustomization(not_null<Ui::VerticalLayout *> container, void SetupCustomization(not_null<Ui::VerticalLayout*> container,
not_null<Window::SessionController *> controller) { not_null<Window::SessionController*> controller) {
AddSubsectionTitle(container, tr::ayu_CustomizationHeader()); AddSubsectionTitle(container, tr::ayu_CustomizationHeader());
SetupAppIcon(container); SetupAppIcon(container);
@ -1299,8 +1299,8 @@ void SetupCustomization(not_null<Ui::VerticalLayout *> container,
SetupFonts(container, controller); SetupFonts(container, controller);
} }
void SetupAyuGramSettings(not_null<Ui::VerticalLayout *> container, void SetupAyuGramSettings(not_null<Ui::VerticalLayout*> container,
not_null<Window::SessionController *> controller) { not_null<Window::SessionController*> controller) {
AddSkip(container); AddSkip(container);
SetupGhostEssentials(container); SetupGhostEssentials(container);
AddSkip(container); AddSkip(container);
@ -1332,7 +1332,7 @@ void SetupAyuGramSettings(not_null<Ui::VerticalLayout *> container,
AddDividerText(container, tr::ayu_SettingsWatermark()); AddDividerText(container, tr::ayu_SettingsWatermark());
} }
void Ayu::setupContent(not_null<Window::SessionController *> controller) { void Ayu::setupContent(not_null<Window::SessionController*> controller) {
const auto content = Ui::CreateChild<Ui::VerticalLayout>(this); const auto content = Ui::CreateChild<Ui::VerticalLayout>(this);
SetupAyuGramSettings(content, controller); SetupAyuGramSettings(content, controller);

View file

@ -21,12 +21,12 @@ namespace Settings {
class Ayu : public Section<Ayu> class Ayu : public Section<Ayu>
{ {
public: public:
Ayu(QWidget *parent, not_null<Window::SessionController *> controller); Ayu(QWidget *parent, not_null<Window::SessionController*> controller);
[[nodiscard]] rpl::producer<QString> title() override; [[nodiscard]] rpl::producer<QString> title() override;
private: private:
void setupContent(not_null<Window::SessionController *> controller); void setupContent(not_null<Window::SessionController*> controller);
}; };
} // namespace Settings } // namespace Settings

View file

@ -12,7 +12,7 @@
constexpr auto kMaxChannelId = -1000000000000; constexpr auto kMaxChannelId = -1000000000000;
QString IDString(not_null<PeerData *> peer) { QString IDString(not_null<PeerData*> peer) {
auto resultId = QString::number(getBareID(peer)); auto resultId = QString::number(getBareID(peer));
const auto settings = &AyuSettings::getInstance(); const auto settings = &AyuSettings::getInstance();
@ -33,7 +33,7 @@ QString IDString(MsgId topic_root_id) {
return resultId; return resultId;
} }
rpl::producer<TextWithEntities> IDValue(not_null<PeerData *> peer) { rpl::producer<TextWithEntities> IDValue(not_null<PeerData*> peer) {
return rpl::single(IDString(peer)) | Ui::Text::ToWithEntities(); return rpl::single(IDString(peer)) | Ui::Text::ToWithEntities();
} }

View file

@ -6,8 +6,8 @@
// Copyright @Radolyn, 2023 // Copyright @Radolyn, 2023
#pragma once #pragma once
QString IDString(not_null<PeerData *> peer); QString IDString(not_null<PeerData*> peer);
QString IDString(MsgId topic_root_id); QString IDString(MsgId topic_root_id);
rpl::producer<TextWithEntities> IDValue(not_null<PeerData *> peer); rpl::producer<TextWithEntities> IDValue(not_null<PeerData*> peer);
rpl::producer<TextWithEntities> IDValue(MsgId topicRootId); rpl::producer<TextWithEntities> IDValue(MsgId topicRootId);

View file

@ -12,11 +12,22 @@
namespace AyuMapper { namespace AyuMapper {
int mapItemFlagsToMTPFlags(not_null<HistoryItem *> item) { std::pair<std::string, std::vector<char>> serializeTextWithEntities(not_null<HistoryItem*> item) {
if (item->emptyText()) {
return std::make_pair("", std::vector<char>());
}
auto textWithEntities = item->originalText();
std::vector<char> entities; // todo: implement writing to buffer
return std::make_pair(textWithEntities.text.toStdString(), entities);
}
int mapItemFlagsToMTPFlags(not_null<HistoryItem*> item) {
int flags = 0; int flags = 0;
const auto thread = item->topic() const auto thread = item->topic()
? (Data::Thread *)item->topic() ? (Data::Thread*) item->topic()
: item->history(); : item->history();
const auto unseen = item->unread(thread); const auto unseen = item->unread(thread);
if (unseen) { if (unseen) {

View file

@ -8,6 +8,7 @@
namespace AyuMapper { namespace AyuMapper {
int mapItemFlagsToMTPFlags(not_null<HistoryItem *> item); std::pair<std::string, std::vector<char>> serializeTextWithEntities(not_null<HistoryItem*> item);
int mapItemFlagsToMTPFlags(not_null<HistoryItem*> item);
} // namespace AyuMapper } // namespace AyuMapper

View file

@ -13,7 +13,7 @@
#include "lang_auto.h" #include "lang_auto.h"
#include "ayu/ayu_worker.h" #include "ayu/ayu_worker.h"
#include "ayu/database/entities.h" #include "ayu/data/entities.h"
#include "core/mime_type.h" #include "core/mime_type.h"
#include "data/data_channel.h" #include "data/data_channel.h"
#include "data/data_forum.h" #include "data/data_forum.h"
@ -110,7 +110,7 @@ void dispatchToMainThread(std::function<void()> callback, int delay) {
QMetaObject::invokeMethod(timer, "start", Qt::QueuedConnection, Q_ARG(int, delay)); QMetaObject::invokeMethod(timer, "start", Qt::QueuedConnection, Q_ARG(int, delay));
} }
not_null<History *> getHistoryFromDialogId(ID dialogId, Main::Session *session) { not_null<History*> getHistoryFromDialogId(ID dialogId, Main::Session *session) {
if (dialogId > 0) { if (dialogId > 0) {
return session->data().history(peerFromUser(dialogId)); return session->data().history(peerFromUser(dialogId));
} }
@ -123,7 +123,7 @@ not_null<History *> getHistoryFromDialogId(ID dialogId, Main::Session *session)
return session->data().history(peerFromChat(abs(dialogId))); return session->data().history(peerFromChat(abs(dialogId)));
} }
ID getDialogIdFromPeer(not_null<PeerData *> peer) { ID getDialogIdFromPeer(not_null<PeerData*> peer) {
auto peerId = peerIsUser(peer->id) auto peerId = peerIsUser(peer->id)
? peerToUser(peer->id).bare ? peerToUser(peer->id).bare
: peerIsChat(peer->id) : peerIsChat(peer->id)
@ -139,30 +139,7 @@ ID getDialogIdFromPeer(not_null<PeerData *> peer) {
return peerId; return peerId;
} }
std::pair<std::string, std::string> serializeTextWithEntities(not_null<HistoryItem *> item) { ID getBareID(not_null<PeerData*> peer) {
if (item->emptyText()) {
return std::make_pair("", "");
}
auto textWithEntities = item->originalText();
auto text = textWithEntities.text.toStdString();
auto entities = EntitiesToMTP(&item->history()->owner().session(),
textWithEntities.entities,
Api::ConvertOption::SkipLocal);
if (entities.v.isEmpty()) {
return std::make_pair(text, "");
}
auto buff = mtpBuffer();
for (auto entity : entities.v) {
entity.write(buff);
}
return std::make_pair(text, std::string(reinterpret_cast<char *>(buff.data()), buff.size()));
}
ID getBareID(not_null<PeerData *> peer) {
return peerIsUser(peer->id) return peerIsUser(peer->id)
? peerToUser(peer->id).bare ? peerToUser(peer->id).bare
: peerIsChat(peer->id) : peerIsChat(peer->id)
@ -180,8 +157,8 @@ bool isExteraRelated(ID peerId) {
return extera_devs.contains(peerId) || extera_channels.contains(peerId); return extera_devs.contains(peerId) || extera_channels.contains(peerId);
} }
void MarkAsReadChatList(not_null<Dialogs::MainList *> list) { void MarkAsReadChatList(not_null<Dialogs::MainList*> list) {
auto mark = std::vector<not_null<History *>>(); auto mark = std::vector<not_null<History*>>();
for (const auto &row : list->indexed()->all()) { for (const auto &row : list->indexed()->all()) {
if (const auto history = row->history()) { if (const auto history = row->history()) {
mark.push_back(history); mark.push_back(history);
@ -242,18 +219,18 @@ void readReactions(base::weak_ptr<Data::Thread> weakThread) {
}).send(); }).send();
} }
void MarkAsReadThread(not_null<Data::Thread *> thread) { void MarkAsReadThread(not_null<Data::Thread*> thread) {
const auto readHistory = [&](not_null<History *> history) const auto readHistory = [&](not_null<History*> history)
{ {
history->owner().histories().readInbox(history); history->owner().histories().readInbox(history);
}; };
const auto sendReadMentions = [=]( const auto sendReadMentions = [=](
not_null<Data::Thread *> thread) not_null<Data::Thread*> thread)
{ {
readMentions(base::make_weak(thread)); readMentions(base::make_weak(thread));
}; };
const auto sendReadReactions = [=]( const auto sendReadReactions = [=](
not_null<Data::Thread *> thread) not_null<Data::Thread*> thread)
{ {
readReactions(base::make_weak(thread)); readReactions(base::make_weak(thread));
}; };
@ -261,7 +238,7 @@ void MarkAsReadThread(not_null<Data::Thread *> thread) {
if (thread->chatListBadgesState().unread) { if (thread->chatListBadgesState().unread) {
if (const auto forum = thread->asForum()) { if (const auto forum = thread->asForum()) {
forum->enumerateTopics([]( forum->enumerateTopics([](
not_null<Data::ForumTopic *> topic) not_null<Data::ForumTopic*> topic)
{ {
MarkAsReadThread(topic); MarkAsReadThread(topic);
}); });
@ -286,7 +263,7 @@ void MarkAsReadThread(not_null<Data::Thread *> thread) {
AyuWorker::markAsOnline(&thread->session()); AyuWorker::markAsOnline(&thread->session());
} }
void readHistory(not_null<HistoryItem *> message) { void readHistory(not_null<HistoryItem*> message) {
const auto history = message->history(); const auto history = message->history();
const auto tillId = message->id; const auto tillId = message->id;
@ -369,7 +346,7 @@ QString formatDateTime(const QDateTime &date) {
return datePart + getLocalizedAt() + timePart; return datePart + getLocalizedAt() + timePart;
} }
QString getMediaSize(not_null<HistoryItem *> message) { QString getMediaSize(not_null<HistoryItem*> message) {
if (!message->media()) { if (!message->media()) {
return {}; return {};
} }
@ -410,7 +387,7 @@ QString getMediaSize(not_null<HistoryItem *> message) {
return Ui::FormatSizeText(size); return Ui::FormatSizeText(size);
} }
QString getMediaMime(not_null<HistoryItem *> message) { QString getMediaMime(not_null<HistoryItem*> message) {
if (!message->media()) { if (!message->media()) {
return {}; return {};
} }
@ -434,7 +411,7 @@ QString getMediaMime(not_null<HistoryItem *> message) {
return {}; return {};
} }
QString getMediaName(not_null<HistoryItem *> message) { QString getMediaName(not_null<HistoryItem*> message) {
if (!message->media()) { if (!message->media()) {
return {}; return {};
} }
@ -450,7 +427,7 @@ QString getMediaName(not_null<HistoryItem *> message) {
return {}; return {};
} }
QString getMediaResolution(not_null<HistoryItem *> message) { QString getMediaResolution(not_null<HistoryItem*> message) {
if (!message->media()) { if (!message->media()) {
return {}; return {};
} }
@ -485,7 +462,7 @@ QString getMediaResolution(not_null<HistoryItem *> message) {
return {}; return {};
} }
QString getMediaDC(not_null<HistoryItem *> message) { QString getMediaDC(not_null<HistoryItem*> message) {
if (!message->media()) { if (!message->media()) {
return {}; return {};
} }

View file

@ -6,7 +6,7 @@
// Copyright @Radolyn, 2023 // Copyright @Radolyn, 2023
#pragma once #pragma once
#include "ayu/database/entities.h" #include "ayu/data/entities.h"
#include "core/application.h" #include "core/application.h"
#include "dialogs/dialogs_main_list.h" #include "dialogs/dialogs_main_list.h"
@ -17,30 +17,29 @@ using Callback = Fn<void(const QString &, UserData *)>;
Main::Session *getSession(ID userId); Main::Session *getSession(ID userId);
bool accountExists(ID userId); bool accountExists(ID userId);
void dispatchToMainThread(std::function<void()> callback, int delay = 0); void dispatchToMainThread(std::function<void()> callback, int delay = 0);
not_null<History *> getHistoryFromDialogId(ID dialogId, Main::Session *session); not_null<History*> getHistoryFromDialogId(ID dialogId, Main::Session *session);
ID getDialogIdFromPeer(not_null<PeerData *> peer); ID getDialogIdFromPeer(not_null<PeerData*> peer);
std::pair<std::string, std::string> serializeTextWithEntities(not_null<HistoryItem *> item);
ID getBareID(not_null<PeerData *> peer); ID getBareID(not_null<PeerData*> peer);
bool isAyuGramRelated(ID peerId); bool isAyuGramRelated(ID peerId);
bool isExteraRelated(ID peerId); bool isExteraRelated(ID peerId);
void MarkAsReadChatList(not_null<Dialogs::MainList *> list); void MarkAsReadChatList(not_null<Dialogs::MainList*> list);
void MarkAsReadThread(not_null<Data::Thread *> thread); void MarkAsReadThread(not_null<Data::Thread*> thread);
void readHistory(not_null<HistoryItem *> message); void readHistory(not_null<HistoryItem*> message);
QString formatTTL(int time); QString formatTTL(int time);
QString formatDateTime(const QDateTime &date); QString formatDateTime(const QDateTime &date);
QString getDCName(int dc); QString getDCName(int dc);
QString getMediaSize(not_null<HistoryItem *> message); QString getMediaSize(not_null<HistoryItem*> message);
QString getMediaMime(not_null<HistoryItem *> message); QString getMediaMime(not_null<HistoryItem*> message);
QString getMediaName(not_null<HistoryItem *> message); QString getMediaName(not_null<HistoryItem*> message);
QString getMediaResolution(not_null<HistoryItem *> message); QString getMediaResolution(not_null<HistoryItem*> message);
QString getMediaDC(not_null<HistoryItem *> message); QString getMediaDC(not_null<HistoryItem*> message);
void searchById(ID userId, Main::Session *session, bool retry, const Callback &callback); void searchById(ID userId, Main::Session *session, bool retry, const Callback &callback);
void searchById(ID userId, Main::Session *session, const Callback &callback); void searchById(ID userId, Main::Session *session, const Callback &callback);

View file

@ -27,9 +27,9 @@ void reloadAppIconFromTaskBar() {
NULL, NULL,
CLSCTX_INPROC_SERVER, CLSCTX_INPROC_SERVER,
IID_IShellLink, IID_IShellLink,
(void **)&pShellLink); (void**) &pShellLink);
if (SUCCEEDED(hr)) { if (SUCCEEDED(hr)) {
hr = pShellLink->QueryInterface(IID_IPersistFile, (void **)&pPersistFile); hr = pShellLink->QueryInterface(IID_IPersistFile, (void**) &pPersistFile);
if (SUCCEEDED(hr)) { if (SUCCEEDED(hr)) {
WCHAR wszShortcutPath[MAX_PATH]; WCHAR wszShortcutPath[MAX_PATH];
shortcut.toWCharArray(wszShortcutPath); shortcut.toWCharArray(wszShortcutPath);

View file

@ -78,8 +78,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
// AyuGram includes // AyuGram includes
#include "ayu/ayu_settings.h" #include "ayu/ayu_settings.h"
#include "ayu/database/ayu_database.h" #include "ayu/data/ayu_database.h"
#include "ayu/messages/ayu_messages_controller.h" #include "../ayu/data/messages_storage.h"
#include "ayu/ayu_state.h" #include "ayu/ayu_state.h"
@ -2309,12 +2309,11 @@ void Session::updateEditedMessage(const MTPMessage &data) {
// AyuGram saveMessagesHistory // AyuGram saveMessagesHistory
const auto settings = &AyuSettings::getInstance(); const auto settings = &AyuSettings::getInstance();
HistoryMessageEdition edit;
if (data.type() != mtpc_message) { if (data.type() != mtpc_message) {
goto proceed; goto proceed;
} }
edit = HistoryMessageEdition(_session, data.c_message()); HistoryMessageEdition edit = HistoryMessageEdition(_session, data.c_message());
if (settings->saveMessagesHistory && !existing->isLocal() && !existing->author()->isSelf() && !edit.isEditHide) { if (settings->saveMessagesHistory && !existing->isLocal() && !existing->author()->isSelf() && !edit.isEditHide) {
const auto msg = existing->originalText(); const auto msg = existing->originalText();
@ -2322,7 +2321,7 @@ void Session::updateEditedMessage(const MTPMessage &data) {
goto proceed; goto proceed;
} }
AyuMessages::getInstance().addEditedMessage(edit, existing); AyuMessages::addEditedMessage(edit, existing);
} }
proceed: proceed:

View file

@ -87,8 +87,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
// AyuGram includes // AyuGram includes
#include "ayu/ayu_settings.h" #include "ayu/ayu_settings.h"
#include "ayu/database/ayu_database.h" #include "ayu/data/ayu_database.h"
#include "ayu/messages/ayu_messages_controller.h" #include "../../ayu/data/messages_storage.h"
#include "ayu/ui/context_menu/context_menu.h" #include "ayu/ui/context_menu/context_menu.h"
#include "ayu/ui/sections/edited/edited_log_section.h" #include "ayu/ui/sections/edited/edited_log_section.h"

View file

@ -40,7 +40,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "styles/style_window.h" #include "styles/style_window.h"
// AyuGram includes // AyuGram includes
#include "ayu/ui/ayu_assets.h" #include "ayu/ui/ayu_logo.h"
namespace Intro { namespace Intro {

View file

@ -29,7 +29,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include <QBuffer> #include <QBuffer>
// AyuGram includes // AyuGram includes
#include "ayu/ui/ayu_assets.h" #include "ayu/ui/ayu_logo.h"
#include "ui/painter.h" #include "ui/painter.h"

View file

@ -48,7 +48,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include <kurlmimedata.h> #include <kurlmimedata.h>
// AyuGram includes // AyuGram includes
#include "ayu/ui/ayu_assets.h" #include "ayu/ui/ayu_logo.h"
namespace Window { namespace Window {