chore: refactor settings

This commit is contained in:
AlexeyZavar 2025-05-05 20:36:16 +03:00
parent 4870d59a43
commit 409165dec6
65 changed files with 647 additions and 651 deletions

View file

@ -171,8 +171,8 @@ void Polls::sendVotes(
hideSending(); hideSending();
_session->updates().applyUpdates(result); _session->updates().applyUpdates(result);
const auto settings = &AyuSettings::getInstance(); const auto& settings = AyuSettings::getInstance();
if (!settings->sendReadMessages && settings->markReadAfterAction && item) if (!settings.sendReadMessages && settings.markReadAfterAction && item)
{ {
readHistory(item); readHistory(item);
} }

View file

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

View file

@ -997,10 +997,10 @@ void Updates::updateOnline(crl::time lastNonIdleTime, bool gotOtherOffline) {
}); });
// AyuGram sendOnlinePackets // AyuGram sendOnlinePackets
const auto settings = &AyuSettings::getInstance(); const auto& settings = AyuSettings::getInstance();
const auto& config = _session->serverConfig(); const auto& config = _session->serverConfig();
bool isOnlineOrig = Core::App().hasActiveWindow(&session()); bool isOnlineOrig = Core::App().hasActiveWindow(&session());
bool isOnline = settings->sendOnlinePackets && isOnlineOrig; bool isOnline = settings.sendOnlinePackets && isOnlineOrig;
int updateIn = config.onlineUpdatePeriod; int updateIn = config.onlineUpdatePeriod;
Assert(updateIn >= 0); Assert(updateIn >= 0);

View file

@ -302,8 +302,8 @@ void ApiWrap::topPromotionDone(const MTPhelp_PromoData &proxy) {
base::unixtime::now(), base::unixtime::now(),
_topPromotionNextRequestTime); _topPromotionNextRequestTime);
const auto settings = &AyuSettings::getInstance(); const auto& settings = AyuSettings::getInstance();
if (settings->disableAds) { if (settings.disableAds) {
_session->data().setTopPromoted(nullptr, QString(), QString()); _session->data().setTopPromoted(nullptr, QString(), QString());
return; return;
} }
@ -507,8 +507,8 @@ void ApiWrap::toggleHistoryArchived(
if (archived) { if (archived) {
history->setFolder(_session->data().folder(archiveId)); history->setFolder(_session->data().folder(archiveId));
} else { } else {
const auto settings = &AyuSettings::getInstance(); const auto& settings = AyuSettings::getInstance();
if (settings->hideAllChatsFolder) { if (settings.hideAllChatsFolder) {
if (const auto window = Core::App().activeWindow()) { if (const auto window = Core::App().activeWindow()) {
if (const auto controller = window->sessionController()) { if (const auto controller = window->sessionController()) {
const auto filters = &_session->data().chatsFilters(); const auto filters = &_session->data().chatsFilters();
@ -1384,7 +1384,7 @@ void ApiWrap::migrateFail(not_null<PeerData*> peer, const QString &error) {
void ApiWrap::markContentsRead( void ApiWrap::markContentsRead(
const base::flat_set<not_null<HistoryItem*>> &items) { const base::flat_set<not_null<HistoryItem*>> &items) {
const auto settings = &AyuSettings::getInstance(); const auto& settings = AyuSettings::getInstance();
auto markedIds = QVector<MTPint>(); auto markedIds = QVector<MTPint>();
auto channelMarkedIds = base::flat_map< auto channelMarkedIds = base::flat_map<
@ -1398,7 +1398,7 @@ void ApiWrap::markContentsRead(
continue; continue;
} }
if (!settings->sendReadMessages && !passthrough) { if (!settings.sendReadMessages && !passthrough) {
continue; continue;
} }
@ -1430,8 +1430,8 @@ void ApiWrap::markContentsRead(not_null<HistoryItem*> item) {
return; return;
} }
const auto settings = &AyuSettings::getInstance(); const auto& settings = AyuSettings::getInstance();
if (!settings->sendReadMessages && !passthrough) { if (!settings.sendReadMessages && !passthrough) {
return; return;
} }
@ -1833,8 +1833,8 @@ void ApiWrap::joinChannel(not_null<ChannelData*> channel) {
using Flag = ChannelDataFlag; using Flag = ChannelDataFlag;
chatParticipants().loadSimilarPeers(channel); chatParticipants().loadSimilarPeers(channel);
const auto settings = &AyuSettings::getInstance(); const auto& settings = AyuSettings::getInstance();
if (!settings->collapseSimilarChannels) { if (!settings.collapseSimilarChannels) {
channel->setFlags(channel->flags() | Flag::SimilarExpanded); channel->setFlags(channel->flags() | Flag::SimilarExpanded);
} }
} }
@ -3461,8 +3461,8 @@ void ApiWrap::forwardMessages(
shared->callback(); shared->callback();
} }
const auto settings = &AyuSettings::getInstance(); const auto& settings = AyuSettings::getInstance();
if (!settings->sendReadMessages && settings->markReadAfterAction && history->lastMessage()) if (!settings.sendReadMessages && settings.markReadAfterAction && history->lastMessage())
{ {
readHistory(history->lastMessage()); readHistory(history->lastMessage());
} }

View file

@ -28,10 +28,10 @@ void initLang() {
} }
void initUiSettings() { void initUiSettings() {
auto settings = &AyuSettings::getInstance(); const auto& settings = AyuSettings::getInstance();
AyuUiSettings::setMonoFont(settings->monoFont); AyuUiSettings::setMonoFont(settings.monoFont);
AyuUiSettings::setWideMultiplier(settings->wideMultiplier); AyuUiSettings::setWideMultiplier(settings.wideMultiplier);
} }
void initDatabase() { void initDatabase() {

View file

@ -219,6 +219,7 @@ AyuGramSettings::AyuGramSettings() {
disableAds = true; disableAds = true;
disableStories = false; disableStories = false;
disableCustomBackgrounds = true; disableCustomBackgrounds = true;
showOnlyAddedEmojisAndStickers = false;
collapseSimilarChannels = true; collapseSimilarChannels = true;
hideSimilarChannels = false; hideSimilarChannels = false;
@ -300,32 +301,32 @@ AyuGramSettings::AyuGramSettings() {
voiceConfirmation = false; voiceConfirmation = false;
} }
void AyuGramSettings::set_sendReadMessages(bool val) { void set_sendReadMessages(bool val) {
sendReadMessages = val; settings->sendReadMessages = val;
sendReadMessagesReactive = val; sendReadMessagesReactive = val;
} }
void AyuGramSettings::set_sendReadStories(bool val) { void set_sendReadStories(bool val) {
sendReadStories = val; settings->sendReadStories = val;
sendReadStoriesReactive = val; sendReadStoriesReactive = val;
} }
void AyuGramSettings::set_sendOnlinePackets(bool val) { void set_sendOnlinePackets(bool val) {
sendOnlinePackets = val; settings->sendOnlinePackets = val;
sendOnlinePacketsReactive = val; sendOnlinePacketsReactive = val;
} }
void AyuGramSettings::set_sendUploadProgress(bool val) { void set_sendUploadProgress(bool val) {
sendUploadProgress = val; settings->sendUploadProgress = val;
sendUploadProgressReactive = val; sendUploadProgressReactive = val;
} }
void AyuGramSettings::set_sendOfflinePacketAfterOnline(bool val) { void set_sendOfflinePacketAfterOnline(bool val) {
sendOfflinePacketAfterOnline = val; settings->sendOfflinePacketAfterOnline = val;
sendOfflinePacketAfterOnlineReactive = val; sendOfflinePacketAfterOnlineReactive = val;
} }
void AyuGramSettings::set_ghostModeEnabled(bool val) { void set_ghostModeEnabled(bool val) {
set_sendReadMessages(!val); set_sendReadMessages(!val);
set_sendReadStories(!val); set_sendReadStories(!val);
set_sendOnlinePackets(!val); set_sendOnlinePackets(!val);
@ -339,235 +340,234 @@ void AyuGramSettings::set_ghostModeEnabled(bool val) {
} }
} }
void AyuGramSettings::set_markReadAfterAction(bool val) { void set_markReadAfterAction(bool val) {
markReadAfterAction = val; settings->markReadAfterAction = val;
} }
void AyuGramSettings::set_useScheduledMessages(bool val) { void set_useScheduledMessages(bool val) {
useScheduledMessages = val; settings->useScheduledMessages = val;
} }
void AyuGramSettings::set_sendWithoutSound(bool val) { void set_sendWithoutSound(bool val) {
sendWithoutSound = val; settings->sendWithoutSound = val;
} }
void AyuGramSettings::set_saveDeletedMessages(bool val) { void set_saveDeletedMessages(bool val) {
saveDeletedMessages = val; settings->saveDeletedMessages = val;
} }
void AyuGramSettings::set_saveMessagesHistory(bool val) { void set_saveMessagesHistory(bool val) {
saveMessagesHistory = val; settings->saveMessagesHistory = val;
} }
void AyuGramSettings::set_saveForBots(bool val) { void set_saveForBots(bool val) {
saveForBots = val; settings->saveForBots = val;
} }
void AyuGramSettings::set_hideFromBlocked(bool val) { void set_hideFromBlocked(bool val) {
hideFromBlocked = val; settings->hideFromBlocked = val;
hideFromBlockedReactive = val; hideFromBlockedReactive = val;
} }
void AyuGramSettings::set_disableAds(bool val) { void set_disableAds(bool val) {
disableAds = val; settings->disableAds = val;
} }
void AyuGramSettings::set_disableStories(bool val) { void set_disableStories(bool val) {
disableStories = val; settings->disableStories = val;
} }
void AyuGramSettings::set_disableCustomBackgrounds(bool val) { void set_disableCustomBackgrounds(bool val) {
disableCustomBackgrounds = val; settings->disableCustomBackgrounds = val;
} }
void AyuGramSettings::set_showOnlyAddedEmojisAndStickers(bool val) { void set_showOnlyAddedEmojisAndStickers(bool val) {
showOnlyAddedEmojisAndStickers = val; settings->showOnlyAddedEmojisAndStickers = val;
} }
void AyuGramSettings::set_collapseSimilarChannels(bool val) { void set_collapseSimilarChannels(bool val) {
collapseSimilarChannels = val; settings->collapseSimilarChannels = val;
} }
void AyuGramSettings::set_hideSimilarChannels(bool val) { void set_hideSimilarChannels(bool val) {
hideSimilarChannels = val; settings->hideSimilarChannels = val;
} }
void AyuGramSettings::set_wideMultiplier(double val) { void set_wideMultiplier(double val) {
wideMultiplier = val; settings->wideMultiplier = val;
} }
void AyuGramSettings::set_spoofWebviewAsAndroid(bool val) { void set_spoofWebviewAsAndroid(bool val) {
spoofWebviewAsAndroid = val; settings->spoofWebviewAsAndroid = val;
} }
void AyuGramSettings::set_increaseWebviewHeight(bool val) { void set_increaseWebviewHeight(bool val) {
increaseWebviewHeight = val; settings->increaseWebviewHeight = val;
} }
void AyuGramSettings::set_increaseWebviewWidth(bool val) { void set_increaseWebviewWidth(bool val) {
increaseWebviewWidth = val; settings->increaseWebviewWidth = val;
} }
void AyuGramSettings::set_disableNotificationsDelay(bool val) { void set_disableNotificationsDelay(bool val) {
disableNotificationsDelay = val; settings->disableNotificationsDelay = val;
} }
void AyuGramSettings::set_localPremium(bool val) { void set_localPremium(bool val) {
localPremium = val; settings->localPremium = val;
} }
void AyuGramSettings::set_appIcon(QString val) { void set_appIcon(QString val) {
appIcon = std::move(val); settings->appIcon = std::move(val);
} }
void AyuGramSettings::set_simpleQuotesAndReplies(bool val) { void set_simpleQuotesAndReplies(bool val) {
simpleQuotesAndReplies = val; settings->simpleQuotesAndReplies = val;
} }
void AyuGramSettings::set_replaceBottomInfoWithIcons(bool val) { void set_replaceBottomInfoWithIcons(bool val) {
replaceBottomInfoWithIcons = val; settings->replaceBottomInfoWithIcons = val;
} }
void AyuGramSettings::set_deletedMark(QString val) { void set_deletedMark(QString val) {
deletedMark = std::move(val); settings->deletedMark = std::move(val);
deletedMarkReactive = deletedMark; deletedMarkReactive = settings->deletedMark;
} }
void AyuGramSettings::set_editedMark(QString val) { void set_editedMark(QString val) {
editedMark = std::move(val); settings->editedMark = std::move(val);
editedMarkReactive = editedMark; editedMarkReactive = settings->editedMark;
} }
void AyuGramSettings::set_recentStickersCount(int val) { void set_recentStickersCount(int val) {
recentStickersCount = val; settings->recentStickersCount = val;
} }
void AyuGramSettings::set_showReactionsPanelInContextMenu(int val) { void set_showReactionsPanelInContextMenu(int val) {
showReactionsPanelInContextMenu = val; settings->showReactionsPanelInContextMenu = val;
} }
void AyuGramSettings::set_showViewsPanelInContextMenu(int val) { void set_showViewsPanelInContextMenu(int val) {
showViewsPanelInContextMenu = val; settings->showViewsPanelInContextMenu = val;
} }
void AyuGramSettings::set_showHideMessageInContextMenu(int val) { void set_showHideMessageInContextMenu(int val) {
showHideMessageInContextMenu = val; settings->showHideMessageInContextMenu = val;
} }
void AyuGramSettings::set_showUserMessagesInContextMenu(int val) { void set_showUserMessagesInContextMenu(int val) {
showUserMessagesInContextMenu = val; settings->showUserMessagesInContextMenu = val;
} }
void AyuGramSettings::set_showMessageDetailsInContextMenu(int val) { void set_showMessageDetailsInContextMenu(int val) {
showMessageDetailsInContextMenu = val; settings->showMessageDetailsInContextMenu = val;
} }
void AyuGramSettings::set_showAttachButtonInMessageField(bool val) { void set_showAttachButtonInMessageField(bool val) {
showAttachButtonInMessageField = val; settings->showAttachButtonInMessageField = val;
triggerHistoryUpdate(); triggerHistoryUpdate();
} }
void AyuGramSettings::set_showCommandsButtonInMessageField(bool val) { void set_showCommandsButtonInMessageField(bool val) {
showCommandsButtonInMessageField = val; settings->showCommandsButtonInMessageField = val;
triggerHistoryUpdate(); triggerHistoryUpdate();
} }
void AyuGramSettings::set_showEmojiButtonInMessageField(bool val) { void set_showEmojiButtonInMessageField(bool val) {
showEmojiButtonInMessageField = val; settings->showEmojiButtonInMessageField = val;
triggerHistoryUpdate(); triggerHistoryUpdate();
} }
void AyuGramSettings::set_showMicrophoneButtonInMessageField(bool val) { void set_showMicrophoneButtonInMessageField(bool val) {
showMicrophoneButtonInMessageField = val; settings->showMicrophoneButtonInMessageField = val;
triggerHistoryUpdate(); triggerHistoryUpdate();
} }
void AyuGramSettings::set_showAutoDeleteButtonInMessageField(bool val) { void set_showAutoDeleteButtonInMessageField(bool val) {
showAutoDeleteButtonInMessageField = val; settings->showAutoDeleteButtonInMessageField = val;
triggerHistoryUpdate(); triggerHistoryUpdate();
} }
void AyuGramSettings::set_showAttachPopup(bool val) { void set_showAttachPopup(bool val) {
showAttachPopup = val; settings->showAttachPopup = val;
triggerHistoryUpdate(); triggerHistoryUpdate();
} }
void AyuGramSettings::set_showEmojiPopup(bool val) { void set_showEmojiPopup(bool val) {
showEmojiPopup = val; settings->showEmojiPopup = val;
triggerHistoryUpdate(); triggerHistoryUpdate();
} }
void AyuGramSettings::set_showLReadToggleInDrawer(bool val) { void set_showLReadToggleInDrawer(bool val) {
showLReadToggleInDrawer = val; settings->showLReadToggleInDrawer = val;
} }
void AyuGramSettings::set_showSReadToggleInDrawer(bool val) { void set_showSReadToggleInDrawer(bool val) {
showSReadToggleInDrawer = val; settings->showSReadToggleInDrawer = val;
} }
void AyuGramSettings::set_showGhostToggleInDrawer(bool val) { void set_showGhostToggleInDrawer(bool val) {
showGhostToggleInDrawer = val; settings->showGhostToggleInDrawer = val;
} }
void AyuGramSettings::set_showStreamerToggleInDrawer(bool val) { void set_showStreamerToggleInDrawer(bool val) {
showStreamerToggleInDrawer = val; settings->showStreamerToggleInDrawer = val;
} }
void AyuGramSettings::set_showGhostToggleInTray(bool val) { void set_showGhostToggleInTray(bool val) {
showGhostToggleInTray = val; settings->showGhostToggleInTray = val;
} }
void AyuGramSettings::set_showStreamerToggleInTray(bool val) { void set_showStreamerToggleInTray(bool val) {
showStreamerToggleInTray = val; settings->showStreamerToggleInTray = val;
} }
void AyuGramSettings::set_monoFont(QString val) { void set_monoFont(QString val) {
monoFont = val; settings->monoFont = val;
} }
void AyuGramSettings::set_showPeerId(int val) { void set_showPeerId(int val) {
showPeerId = val; settings->showPeerId = val;
showPeerIdReactive = val; showPeerIdReactive = val;
} }
void AyuGramSettings::set_hideNotificationCounters(bool val) { void set_hideNotificationCounters(bool val) {
hideNotificationCounters = val; settings->hideNotificationCounters = val;
} }
void AyuGramSettings::set_hideNotificationBadge(bool val) { void set_hideNotificationBadge(bool val) {
hideNotificationBadge = val; settings->hideNotificationBadge = val;
} }
void AyuGramSettings::set_hideAllChatsFolder(bool val) { void set_hideAllChatsFolder(bool val) {
hideAllChatsFolder = val; settings->hideAllChatsFolder = val;
} }
void AyuGramSettings::set_channelBottomButton(int val) { void set_channelBottomButton(int val) {
channelBottomButton = val; settings->channelBottomButton = val;
} }
void AyuGramSettings::set_showMessageSeconds(bool val) { void set_showMessageSeconds(bool val) {
showMessageSeconds = val; settings->showMessageSeconds = val;
} }
void AyuGramSettings::set_showMessageShot(bool val) { void set_showMessageShot(bool val) {
showMessageShot = val; settings->showMessageShot = val;
} }
void AyuGramSettings::set_stickerConfirmation(bool val) { void set_stickerConfirmation(bool val) {
stickerConfirmation = val; settings->stickerConfirmation = val;
} }
void AyuGramSettings::set_gifConfirmation(bool val) { void set_gifConfirmation(bool val) {
gifConfirmation = val; settings->gifConfirmation = val;
} }
void AyuGramSettings::set_voiceConfirmation(bool val) { void set_voiceConfirmation(bool val) {
voiceConfirmation = val; settings->voiceConfirmation = val;
} }
bool isUseScheduledMessages() { bool isUseScheduledMessages() {
const auto settings = &getInstance();
return isGhostModeActive() && settings->useScheduledMessages; return isGhostModeActive() && settings->useScheduledMessages;
} }

View file

@ -95,6 +95,7 @@ public:
bool stickerConfirmation; bool stickerConfirmation;
bool gifConfirmation; bool gifConfirmation;
bool voiceConfirmation; bool voiceConfirmation;
};
void set_sendReadMessages(bool val); void set_sendReadMessages(bool val);
void set_sendReadStories(bool val); void set_sendReadStories(bool val);
@ -176,7 +177,6 @@ public:
void set_stickerConfirmation(bool val); void set_stickerConfirmation(bool val);
void set_gifConfirmation(bool val); void set_gifConfirmation(bool val);
void set_voiceConfirmation(bool val); void set_voiceConfirmation(bool val);
};
NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE_WITH_DEFAULT( NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE_WITH_DEFAULT(
AyuGramSettings, AyuGramSettings,
@ -195,6 +195,7 @@ NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE_WITH_DEFAULT(
disableAds, disableAds,
disableStories, disableStories,
disableCustomBackgrounds, disableCustomBackgrounds,
showOnlyAddedEmojisAndStickers,
collapseSimilarChannels, collapseSimilarChannels,
hideSimilarChannels, hideSimilarChannels,
wideMultiplier, wideMultiplier,

View file

@ -42,8 +42,8 @@ void runOnce() {
lateInit(); lateInit();
} }
const auto settings = &AyuSettings::getInstance(); const auto& settings = AyuSettings::getInstance();
if (!settings->sendOfflinePacketAfterOnline) { if (!settings.sendOfflinePacketAfterOnline) {
return; return;
} }

View file

@ -14,7 +14,7 @@ static QImage LAST_LOADED_NO_MARGIN;
namespace AyuAssets { namespace AyuAssets {
void loadAppIco() { void loadAppIco() {
auto settings = &AyuSettings::getInstance(); const auto& settings = AyuSettings::getInstance();
QString appDataPath = QDir::fromNativeSeparators(qgetenv("APPDATA")); QString appDataPath = QDir::fromNativeSeparators(qgetenv("APPDATA"));
QString tempIconPath = appDataPath + "/AyuGram.ico"; QString tempIconPath = appDataPath + "/AyuGram.ico";
@ -26,20 +26,20 @@ void loadAppIco() {
f.remove(); f.remove();
} }
f.close(); f.close();
QFile::copy(qsl(":/gui/art/ayu/%1/app_icon.ico").arg(settings->appIcon), tempIconPath); QFile::copy(qsl(":/gui/art/ayu/%1/app_icon.ico").arg(settings.appIcon), tempIconPath);
} }
void loadIcons() { void loadIcons() {
auto settings = &AyuSettings::getInstance(); const auto& settings = AyuSettings::getInstance();
if (LAST_LOADED_NAME != settings->appIcon) { if (LAST_LOADED_NAME != settings.appIcon) {
LAST_LOADED_NAME = settings->appIcon; LAST_LOADED_NAME = settings.appIcon;
#ifdef Q_OS_MAC #ifdef Q_OS_MAC
LAST_LOADED = QImage(qsl(":/gui/art/ayu/%1/app_macos.png").arg(settings->appIcon)); LAST_LOADED = QImage(qsl(":/gui/art/ayu/%1/app_macos.png").arg(settings.appIcon));
#else #else
LAST_LOADED = QImage(qsl(":/gui/art/ayu/%1/app.png").arg(settings->appIcon)); LAST_LOADED = QImage(qsl(":/gui/art/ayu/%1/app.png").arg(settings.appIcon));
#endif #endif
LAST_LOADED_NO_MARGIN = QImage(qsl(":/gui/art/ayu/%1/app_preview.png").arg(settings->appIcon)); LAST_LOADED_NO_MARGIN = QImage(qsl(":/gui/art/ayu/%1/app_preview.png").arg(settings.appIcon));
} }
} }

View file

@ -87,8 +87,7 @@ void EditDeletedMarkBox::resizeEvent(QResizeEvent *e) {
} }
void EditDeletedMarkBox::save() { void EditDeletedMarkBox::save() {
const auto settings = &AyuSettings::getInstance(); AyuSettings::set_deletedMark(_text->getLastText());
settings->set_deletedMark(_text->getLastText());
AyuSettings::save(); AyuSettings::save();
closeBox(); closeBox();

View file

@ -86,8 +86,7 @@ void EditEditedMarkBox::resizeEvent(QResizeEvent *e) {
} }
void EditEditedMarkBox::save() { void EditEditedMarkBox::save() {
const auto settings = &AyuSettings::getInstance(); AyuSettings::set_editedMark(_text->getLastText());
settings->set_editedMark(_text->getLastText());
AyuSettings::save(); AyuSettings::save();
closeBox(); closeBox();

View file

@ -38,8 +38,8 @@ void MessageShotBox::prepare() {
void MessageShotBox::setupContent() { void MessageShotBox::setupContent() {
_selectedPalette = std::make_shared<style::palette>(); _selectedPalette = std::make_shared<style::palette>();
const auto settings = &AyuSettings::getInstance(); const auto& settings = AyuSettings::getInstance();
const auto savedShowColorfulReplies = !settings->simpleQuotesAndReplies; const auto savedShowColorfulReplies = !settings.simpleQuotesAndReplies;
using namespace Settings; using namespace Settings;
@ -164,8 +164,7 @@ void MessageShotBox::setupContent() {
) | start_with_next( ) | start_with_next(
[=](bool enabled) [=](bool enabled)
{ {
const auto settings = &AyuSettings::getInstance(); AyuSettings::set_simpleQuotesAndReplies(!enabled);
settings->set_simpleQuotesAndReplies(!enabled);
_config.st = std::make_shared<Ui::ChatStyle>(_config.st.get()); _config.st = std::make_shared<Ui::ChatStyle>(_config.st.get());
updatePreview(); updatePreview();
@ -209,8 +208,7 @@ void MessageShotBox::setupContent() {
AyuFeatures::MessageShot::resetDefaultSelected(); AyuFeatures::MessageShot::resetDefaultSelected();
AyuFeatures::MessageShot::resetShotConfig(); AyuFeatures::MessageShot::resetShotConfig();
const auto settings = &AyuSettings::getInstance(); AyuSettings::set_simpleQuotesAndReplies(!savedShowColorfulReplies);
settings->set_simpleQuotesAndReplies(!savedShowColorfulReplies);
}, },
content->lifetime()); content->lifetime());

View file

@ -197,8 +197,8 @@ 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;
} }
@ -220,8 +220,8 @@ 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) {
const auto settings = &AyuSettings::getInstance(); const auto& settings = AyuSettings::getInstance();
if (!needToShowItem(settings->showUserMessagesInContextMenu)) { if (!needToShowItem(settings.showUserMessagesInContextMenu)) {
return; return;
} }
@ -245,8 +245,8 @@ 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;
} }
@ -464,8 +464,8 @@ void AddReadUntilAction(not_null<Ui::PopupMenu*> menu, HistoryItem *item) {
return; return;
} }
const auto settings = &AyuSettings::getInstance(); const auto& settings = AyuSettings::getInstance();
if (settings->sendReadMessages) { if (settings.sendReadMessages) {
return; return;
} }

View file

@ -121,7 +121,7 @@ void IconPicker::paintEvent(QPaintEvent *e) {
} }
void IconPicker::mousePressEvent(QMouseEvent *e) { void IconPicker::mousePressEvent(QMouseEvent *e) {
auto settings = &AyuSettings::getInstance(); const auto& settings = AyuSettings::getInstance();
auto changed = false; auto changed = false;
auto x = e->pos().x(); auto x = e->pos().x();
@ -139,8 +139,8 @@ void IconPicker::mousePressEvent(QMouseEvent *e) {
break; break;
} }
if (settings->appIcon != iconName) { if (settings.appIcon != iconName) {
wasSelected = settings->appIcon; wasSelected = settings.appIcon;
animation.start( animation.start(
[=] [=]
{ {
@ -152,7 +152,7 @@ void IconPicker::mousePressEvent(QMouseEvent *e) {
anim::easeOutCubic anim::easeOutCubic
); );
settings->set_appIcon(iconName); AyuSettings::set_appIcon(iconName);
changed = true; changed = true;
break; break;
} }

File diff suppressed because it is too large Load diff

View file

@ -15,8 +15,8 @@ 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();
if (settings->showPeerId == 2) { if (settings.showPeerId == 2) {
if (peer->isChannel()) { if (peer->isChannel()) {
resultId = QString::number(peerToChannel(peer->id).bare - kMaxChannelId).prepend("-"); resultId = QString::number(peerToChannel(peer->id).bare - kMaxChannelId).prepend("-");
} else if (peer->isChat()) { } else if (peer->isChat()) {

View file

@ -100,8 +100,8 @@ bool isMessageHidden(const not_null<HistoryItem*> item) {
return true; return true;
} }
const auto settings = &AyuSettings::getInstance(); const auto& settings = AyuSettings::getInstance();
if (settings->hideFromBlocked) { if (settings.hideFromBlocked) {
if (item->from()->isUser() && if (item->from()->isUser() &&
item->from()->asUser()->isBlocked()) { item->from()->asUser()->isBlocked()) {
// don't hide messages if it's a dialog with blocked user // don't hide messages if it's a dialog with blocked user
@ -505,14 +505,14 @@ int getScheduleTime(int64 sumSize) {
} }
bool isMessageSavable(const not_null<HistoryItem *> item) { bool isMessageSavable(const not_null<HistoryItem *> item) {
const auto settings = &AyuSettings::getInstance(); const auto& settings = AyuSettings::getInstance();
if (!settings->saveDeletedMessages) { if (!settings.saveDeletedMessages) {
return false; return false;
} }
if (const auto possiblyBot = item->history()->peer->asUser()) { if (const auto possiblyBot = item->history()->peer->asUser()) {
return !possiblyBot->isBot() || (settings->saveForBots && possiblyBot->isBot()); return !possiblyBot->isBot() || (settings.saveForBots && possiblyBot->isBot());
} }
return true; return true;
} }

View file

@ -1731,8 +1731,8 @@ ShareBox::SubmitCallback ShareBox::DefaultForwardCallback(
} }
} }
const auto settings = &AyuSettings::getInstance(); const auto& settings = AyuSettings::getInstance();
if (!settings->sendReadMessages && settings->markReadAfterAction && history->lastMessage()) if (!settings.sendReadMessages && settings.markReadAfterAction && history->lastMessage())
{ {
readHistory(history->lastMessage()); readHistory(history->lastMessage());
} }

View file

@ -2259,11 +2259,11 @@ void EmojiListWidget::refreshCustom() {
&& !_allowWithoutPremium; && !_allowWithoutPremium;
const auto owner = &session->data(); const auto owner = &session->data();
const auto &sets = owner->stickers().sets(); const auto &sets = owner->stickers().sets();
auto settings = &AyuSettings::getInstance(); const auto& settings = AyuSettings::getInstance();
const auto push = [&](uint64 setId, bool installed) { const auto push = [&](uint64 setId, bool installed) {
const auto megagroup = _megagroupSet const auto megagroup = _megagroupSet
&& (setId == Data::Stickers::MegagroupSetId); && (setId == Data::Stickers::MegagroupSetId);
if (settings->showOnlyAddedEmojisAndStickers && !installed && !megagroup) { if (settings.showOnlyAddedEmojisAndStickers && !installed && !megagroup) {
return; return;
} }
const auto lookupId = megagroup const auto lookupId = megagroup

View file

@ -408,11 +408,11 @@ bool FieldAutocomplete::clearFilteredBotCommands() {
FieldAutocomplete::StickerRows FieldAutocomplete::getStickerSuggestions() { FieldAutocomplete::StickerRows FieldAutocomplete::getStickerSuggestions() {
const auto data = &_session->data().stickers(); const auto data = &_session->data().stickers();
const auto list = data->getListByEmoji({ _emoji }, _stickersSeed); const auto list = data->getListByEmoji({ _emoji }, _stickersSeed);
const auto settings = &AyuSettings::getInstance(); const auto& settings = AyuSettings::getInstance();
auto result = ranges::views::all( auto result = ranges::views::all(
list list
) | ranges::views::filter([&](not_null<DocumentData*> sticker) { ) | ranges::views::filter([&](not_null<DocumentData*> sticker) {
return !settings->showOnlyAddedEmojisAndStickers return !settings.showOnlyAddedEmojisAndStickers
|| sticker->isStickerSetInstalled(); || sticker->isStickerSetInstalled();
}) | ranges::views::transform([](not_null<DocumentData*> sticker) { }) | ranges::views::transform([](not_null<DocumentData*> sticker) {
return StickerSuggestion{ return StickerSuggestion{

View file

@ -502,7 +502,7 @@ void GifsListWidget::selectInlineResult(
return; return;
} }
auto settings = &AyuSettings::getInstance(); const auto& settings = AyuSettings::getInstance();
if (AyuSettings::isUseScheduledMessages()) { if (AyuSettings::isUseScheduledMessages()) {
auto current = base::unixtime::now(); auto current = base::unixtime::now();
options.scheduled = current + 12; options.scheduled = current + 12;
@ -552,7 +552,7 @@ void GifsListWidget::selectInlineResult(
}); });
}); });
if (settings->gifConfirmation) { if (settings.gifConfirmation) {
Ui::show(Ui::MakeConfirmBox({ Ui::show(Ui::MakeConfirmBox({
.text = tr::ayu_ConfirmationGIF(), .text = tr::ayu_ConfirmationGIF(),
.confirmed = sendGIFCallback, .confirmed = sendGIFCallback,

View file

@ -763,8 +763,8 @@ void StickersListWidget::fillFilteredStickersRow() {
} }
void StickersListWidget::addSearchRow(not_null<StickersSet*> set) { void StickersListWidget::addSearchRow(not_null<StickersSet*> set) {
const auto settings = &AyuSettings::getInstance(); const auto& settings = AyuSettings::getInstance();
if (settings->showOnlyAddedEmojisAndStickers && !SetInMyList(set->flags)) { if (settings.showOnlyAddedEmojisAndStickers && !SetInMyList(set->flags)) {
return; return;
} }
const auto skipPremium = !session().premiumPossible(); const auto skipPremium = !session().premiumPossible();
@ -1910,7 +1910,7 @@ void StickersListWidget::mouseReleaseEvent(QMouseEvent *e) {
&& (e->modifiers() & Qt::ControlModifier)) { && (e->modifiers() & Qt::ControlModifier)) {
showStickerSetBox(document, set.id); showStickerSetBox(document, set.id);
} else { } else {
auto settings = &AyuSettings::getInstance(); const auto& settings = AyuSettings::getInstance();
auto from = messageSentAnimationInfo( auto from = messageSentAnimationInfo(
sticker->section, sticker->section,
sticker->index, sticker->index,
@ -1932,7 +1932,7 @@ void StickersListWidget::mouseReleaseEvent(QMouseEvent *e) {
}); });
}); });
if (settings->stickerConfirmation && (_mode == Mode::Full || _mode == Mode::ChatIntro) && _requireConfirmation) { if (settings.stickerConfirmation && (_mode == Mode::Full || _mode == Mode::ChatIntro) && _requireConfirmation) {
Ui::show(Ui::MakeConfirmBox({ Ui::show(Ui::MakeConfirmBox({
.text = tr::ayu_ConfirmationSticker(), .text = tr::ayu_ConfirmationSticker(),
.confirmed = sendStickerCallback, .confirmed = sendStickerCallback,
@ -2339,10 +2339,10 @@ auto StickersListWidget::collectRecentStickers() -> std::vector<Sticker> {
result.reserve(cloudCount + recent.size() + customCount); result.reserve(cloudCount + recent.size() + customCount);
_custom.reserve(cloudCount + recent.size() + customCount); _custom.reserve(cloudCount + recent.size() + customCount);
auto settings = &AyuSettings::getInstance(); const auto& settings = AyuSettings::getInstance();
auto add = [&](not_null<DocumentData*> document, bool custom) { auto add = [&](not_null<DocumentData*> document, bool custom) {
if (result.size() >= settings->recentStickersCount) { if (result.size() >= settings.recentStickersCount) {
return; return;
} }
const auto i = ranges::find(result, document, &Sticker::document); const auto i = ranges::find(result, document, &Sticker::document);

View file

@ -474,9 +474,9 @@ void TabbedPanel::showStarted() {
} }
bool TabbedPanel::eventFilter(QObject *obj, QEvent *e) { bool TabbedPanel::eventFilter(QObject *obj, QEvent *e) {
const auto settings = &AyuSettings::getInstance(); const auto& settings = AyuSettings::getInstance();
if (TabbedPanelShowOnClick.value() || !settings->showEmojiPopup) { if (TabbedPanelShowOnClick.value() || !settings.showEmojiPopup) {
return false; return false;
} else if (e->type() == QEvent::Enter) { } else if (e->type() == QEvent::Enter) {
otherEnter(); otherEnter();

View file

@ -195,12 +195,12 @@ PreviewWrap::PreviewWrap(
} }
}, lifetime()); }, lifetime());
const auto settings = &AyuSettings::getInstance(); const auto& settings = AyuSettings::getInstance();
{ {
const auto close = Ui::CreateChild<Ui::RoundButton>( const auto close = Ui::CreateChild<Ui::RoundButton>(
this, this,
item->out() || settings->saveDeletedMessages item->out() || settings.saveDeletedMessages
? tr::lng_close() ? tr::lng_close()
: tr::lng_ttl_voice_close_in(), : tr::lng_ttl_voice_close_in(),
st::ttlMediaButton); st::ttlMediaButton);
@ -234,8 +234,8 @@ PreviewWrap::PreviewWrap(
) | Ui::Text::ToRichLangValue(), ) | Ui::Text::ToRichLangValue(),
Ui::Text::RichLangValue) Ui::Text::RichLangValue)
: (isRound : (isRound
? settings->saveDeletedMessages ? tr::ayu_ExpiringVideoMessageNote : tr::lng_ttl_round_tooltip_in ? settings.saveDeletedMessages ? tr::ayu_ExpiringVideoMessageNote : tr::lng_ttl_round_tooltip_in
: settings->saveDeletedMessages ? tr::ayu_ExpiringVoiceMessageNote : tr::lng_ttl_voice_tooltip_in)(Ui::Text::RichLangValue); : settings.saveDeletedMessages ? tr::ayu_ExpiringVoiceMessageNote : tr::lng_ttl_voice_tooltip_in)(Ui::Text::RichLangValue);
const auto tooltip = Ui::CreateChild<Ui::ImportantTooltip>( const auto tooltip = Ui::CreateChild<Ui::ImportantTooltip>(
this, this,
object_ptr<Ui::PaddingWrap<Ui::FlatLabel>>( object_ptr<Ui::PaddingWrap<Ui::FlatLabel>>(

View file

@ -228,8 +228,8 @@ void SponsoredMessages::inject(
} }
bool SponsoredMessages::canHaveFor(not_null<History*> history) const { bool SponsoredMessages::canHaveFor(not_null<History*> history) const {
auto settings = &AyuSettings::getInstance(); const auto& settings = AyuSettings::getInstance();
if (settings->disableAds) { if (settings.disableAds) {
return false; return false;
} }
@ -242,8 +242,8 @@ bool SponsoredMessages::canHaveFor(not_null<History*> history) const {
} }
bool SponsoredMessages::isTopBarFor(not_null<History*> history) const { bool SponsoredMessages::isTopBarFor(not_null<History*> history) const {
auto settings = &AyuSettings::getInstance(); const auto& settings = AyuSettings::getInstance();
if (settings->disableAds) { if (settings.disableAds) {
return false; return false;
} }

View file

@ -484,13 +484,13 @@ void ChatFilters::requestToggleTags(bool value, Fn<void()> fail) {
void ChatFilters::received(const QVector<MTPDialogFilter> &list) { void ChatFilters::received(const QVector<MTPDialogFilter> &list) {
// AyuGram hideAllChatsFolder // AyuGram hideAllChatsFolder
const auto settings = &AyuSettings::getInstance(); const auto& settings = AyuSettings::getInstance();
auto position = 0; auto position = 0;
auto changed = false; auto changed = false;
for (const auto &filter : list) { for (const auto &filter : list) {
auto parsed = ChatFilter::FromTL(filter, _owner); auto parsed = ChatFilter::FromTL(filter, _owner);
if (settings->hideAllChatsFolder && parsed.id() == 0 && list.size() > 1) { if (settings.hideAllChatsFolder && parsed.id() == 0 && list.size() > 1) {
continue; continue;
} }
const auto b = begin(_list) + position; const auto b = begin(_list) + position;
@ -514,7 +514,7 @@ void ChatFilters::received(const QVector<MTPDialogFilter> &list) {
applyRemove(position); applyRemove(position);
changed = true; changed = true;
} }
if (!settings->hideAllChatsFolder && !ranges::contains(begin(_list), end(_list), 0, &ChatFilter::id)) { if (!settings.hideAllChatsFolder && !ranges::contains(begin(_list), end(_list), 0, &ChatFilter::id)) {
_list.insert(begin(_list), ChatFilter()); _list.insert(begin(_list), ChatFilter());
} }
if (changed || !_loaded || _reloading) { if (changed || !_loaded || _reloading) {
@ -526,12 +526,12 @@ void ChatFilters::received(const QVector<MTPDialogFilter> &list) {
void ChatFilters::apply(const MTPUpdate &update) { void ChatFilters::apply(const MTPUpdate &update) {
// AyuGram hideAllChatsFolder // AyuGram hideAllChatsFolder
const auto settings = &AyuSettings::getInstance(); const auto& settings = AyuSettings::getInstance();
update.match([&](const MTPDupdateDialogFilter &data) { update.match([&](const MTPDupdateDialogFilter &data) {
if (const auto filter = data.vfilter()) { if (const auto filter = data.vfilter()) {
auto parsed = ChatFilter::FromTL(*filter, _owner); auto parsed = ChatFilter::FromTL(*filter, _owner);
if (settings->hideAllChatsFolder && parsed.id() == 0) { if (settings.hideAllChatsFolder && parsed.id() == 0) {
return; return;
} }
set(parsed); set(parsed);
@ -912,9 +912,9 @@ FilterId ChatFilters::lookupId(int index) const {
return FilterId(); // AyuGram: fix crash when using `hideAllChatsFolder` return FilterId(); // AyuGram: fix crash when using `hideAllChatsFolder`
} }
const auto settings = &AyuSettings::getInstance(); const auto& settings = AyuSettings::getInstance();
if (_owner->session().user()->isPremium() || !_list.front().id() || settings->hideAllChatsFolder) { if (_owner->session().user()->isPremium() || !_list.front().id() || settings.hideAllChatsFolder) {
return _list[index].id(); return _list[index].id();
} }
const auto i = ranges::find(_list, FilterId(0), &ChatFilter::id); const auto i = ranges::find(_list, FilterId(0), &ChatFilter::id);

View file

@ -627,8 +627,8 @@ void Histories::sendReadRequests() {
DEBUG_LOG(("Reading: send requests with count %1.").arg(_states.size())); DEBUG_LOG(("Reading: send requests with count %1.").arg(_states.size()));
// AyuGram sendReadMessages // AyuGram sendReadMessages
const auto settings = &AyuSettings::getInstance(); const auto& settings = AyuSettings::getInstance();
if (!settings->sendReadMessages) { if (!settings.sendReadMessages) {
DEBUG_LOG(("[AyuGram] Don't read messages")); DEBUG_LOG(("[AyuGram] Don't read messages"));
_states.clear(); _states.clear();
return; return;

View file

@ -1491,8 +1491,8 @@ void Reactions::send(not_null<HistoryItem*> item, bool addToRecent) {
_sentRequests.remove(id); _sentRequests.remove(id);
_owner->session().api().applyUpdates(result); _owner->session().api().applyUpdates(result);
const auto settings = &AyuSettings::getInstance(); const auto& settings = AyuSettings::getInstance();
if (!settings->sendReadMessages && settings->markReadAfterAction && item) { if (!settings.sendReadMessages && settings.markReadAfterAction && item) {
readHistory(item); readHistory(item);
} }
}).fail([=](const MTP::Error &error) { }).fail([=](const MTP::Error &error) {

View file

@ -399,8 +399,8 @@ rpl::producer<bool> PeerPremiumValue(not_null<PeerData*> peer) {
} }
rpl::producer<bool> AmPremiumValue(not_null<Main::Session*> session) { rpl::producer<bool> AmPremiumValue(not_null<Main::Session*> session) {
auto settings = &AyuSettings::getInstance(); const auto& settings = AyuSettings::getInstance();
if (settings->localPremium) { if (settings.localPremium) {
return rpl::single(true); return rpl::single(true);
} }

View file

@ -1005,8 +1005,8 @@ void RepliesList::sendReadTillRequest() {
const auto api = &_history->session().api(); const auto api = &_history->session().api();
api->request(base::take(_readRequestId)).cancel(); api->request(base::take(_readRequestId)).cancel();
const auto settings = &AyuSettings::getInstance(); const auto& settings = AyuSettings::getInstance();
if (!settings->sendReadMessages) { if (!settings.sendReadMessages) {
return; return;
} }

View file

@ -319,8 +319,8 @@ Session::Session(not_null<Main::Session*> session)
}, _lifetime); }, _lifetime);
// AyuGram disableStories // AyuGram disableStories
const auto settings = &AyuSettings::getInstance(); const auto& settings = AyuSettings::getInstance();
if (!settings->disableStories) { if (!settings.disableStories) {
_stories->loadMore(Data::StorySourcesList::NotHidden); _stories->loadMore(Data::StorySourcesList::NotHidden);
} }
}); });
@ -2485,14 +2485,14 @@ void Session::updateEditedMessage(const MTPMessage &data) {
} }
// AyuGram saveMessagesHistory // AyuGram saveMessagesHistory
const auto settings = &AyuSettings::getInstance(); const auto& settings = AyuSettings::getInstance();
HistoryMessageEdition edit; HistoryMessageEdition edit;
if (data.type() != mtpc_message) { if (data.type() != mtpc_message) {
goto proceed; goto proceed;
} }
edit = HistoryMessageEdition(_session, data.c_message()); 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();
if (edit.textWithEntities == msg || msg.empty()) { if (edit.textWithEntities == msg || msg.empty()) {
@ -2637,12 +2637,12 @@ void Session::unregisterMessageTTL(
} }
void Session::checkTTLs() { void Session::checkTTLs() {
const auto settings = &AyuSettings::getInstance(); const auto& settings = AyuSettings::getInstance();
_ttlCheckTimer.cancel(); _ttlCheckTimer.cancel();
const auto now = base::unixtime::now(); const auto now = base::unixtime::now();
if (settings->saveDeletedMessages) { if (settings.saveDeletedMessages) {
auto toBeRemoved = ranges::views::take_while( auto toBeRemoved = ranges::views::take_while(
_ttlMessages, _ttlMessages,
[now](const auto &pair) { [now](const auto &pair) {

View file

@ -1120,8 +1120,8 @@ void Stories::markAsRead(FullStoryId id, bool viewed) {
return; return;
} }
const auto settings = &AyuSettings::getInstance(); const auto& settings = AyuSettings::getInstance();
if (!settings->sendReadStories) { if (!settings.sendReadStories) {
return; return;
} }
@ -1270,8 +1270,8 @@ void Stories::toggleHidden(
void Stories::sendMarkAsReadRequest( void Stories::sendMarkAsReadRequest(
not_null<PeerData*> peer, not_null<PeerData*> peer,
StoryId tillId) { StoryId tillId) {
const auto settings = &AyuSettings::getInstance(); const auto& settings = AyuSettings::getInstance();
if (!settings->sendReadStories) { if (!settings.sendReadStories) {
return; return;
} }
@ -1305,8 +1305,8 @@ void Stories::checkQuitPreventFinished() {
void Stories::sendMarkAsReadRequests() { void Stories::sendMarkAsReadRequests() {
_markReadTimer.cancel(); _markReadTimer.cancel();
const auto settings = &AyuSettings::getInstance(); const auto& settings = AyuSettings::getInstance();
if (!settings->sendReadStories) { if (!settings.sendReadStories) {
return; return;
} }
@ -1329,8 +1329,8 @@ void Stories::sendIncrementViewsRequests() {
return; return;
} }
const auto settings = &AyuSettings::getInstance(); const auto& settings = AyuSettings::getInstance();
if (!settings->sendReadStories) { if (!settings.sendReadStories) {
return; return;
} }
@ -1941,8 +1941,8 @@ bool Stories::isQuitPrevent() {
sendIncrementViewsRequests(); sendIncrementViewsRequests();
} }
const auto settings = &AyuSettings::getInstance(); const auto& settings = AyuSettings::getInstance();
if (!settings->sendReadStories || _markReadRequests.empty() && _incrementViewsRequests.empty()) { if (!settings.sendReadStories || _markReadRequests.empty() && _incrementViewsRequests.empty()) {
return false; return false;
} }
LOG(("Stories prevents quit, marking as read...")); LOG(("Stories prevents quit, marking as read..."));

View file

@ -489,8 +489,8 @@ bool UserData::isFake() const {
bool UserData::isPremium() const { bool UserData::isPremium() const {
if (id) { if (id) {
auto settings = &AyuSettings::getInstance(); const auto& settings = AyuSettings::getInstance();
if (settings->localPremium) { if (settings.localPremium) {
if (getSession(id.value)) { if (getSession(id.value)) {
return true; return true;
} }

View file

@ -553,12 +553,12 @@ void Row::paintUserpic(
updateCornerBadgeShown(peer, nullptr, hasUnreadBadgesAbove); updateCornerBadgeShown(peer, nullptr, hasUnreadBadgesAbove);
} }
const auto settings = &AyuSettings::getInstance(); const auto& settings = AyuSettings::getInstance();
const auto cornerBadgeShown = !_cornerBadgeUserpic const auto cornerBadgeShown = !_cornerBadgeUserpic
? _cornerBadgeShown ? _cornerBadgeShown
: !_cornerBadgeUserpic->layersManager.isDisplayedNone(); : !_cornerBadgeUserpic->layersManager.isDisplayedNone();
const auto storiesPeer = settings->disableStories ? nullptr : peer const auto storiesPeer = settings.disableStories ? nullptr : peer
? ((peer->isUser() || peer->isChannel()) ? peer : nullptr) ? ((peer->isUser() || peer->isChannel()) ? peer : nullptr)
: nullptr; : nullptr;
const auto storiesFolder = peer ? nullptr : _id.folder(); const auto storiesFolder = peer ? nullptr : _id.folder();

View file

@ -1307,8 +1307,8 @@ void Widget::setupMainMenuToggle() {
? &st::dialogsMenuToggleUnread ? &st::dialogsMenuToggleUnread
: &st::dialogsMenuToggleUnreadMuted; : &st::dialogsMenuToggleUnreadMuted;
const auto settings = &AyuSettings::getInstance(); const auto& settings = AyuSettings::getInstance();
if (settings->hideNotificationCounters) { if (settings.hideNotificationCounters) {
icon = nullptr; icon = nullptr;
} }
@ -1318,8 +1318,8 @@ void Widget::setupMainMenuToggle() {
void Widget::setupStories() { void Widget::setupStories() {
// AyuGram disableStories // AyuGram disableStories
const auto settings = &AyuSettings::getInstance(); const auto& settings = AyuSettings::getInstance();
if (settings->disableStories) { if (settings.disableStories) {
return; return;
} }
@ -2277,8 +2277,8 @@ void Widget::updateStoriesVisibility() {
return; return;
} }
const auto settings = &AyuSettings::getInstance(); const auto& settings = AyuSettings::getInstance();
if (settings->disableStories) { if (settings.disableStories) {
_stories->setVisible(false); _stories->setVisible(false);
return; return;
} }

View file

@ -1253,11 +1253,11 @@ void HistoryItem::setCommentsItemId(FullMsgId id) {
void HistoryItem::setServiceText(PreparedServiceText &&prepared) { void HistoryItem::setServiceText(PreparedServiceText &&prepared) {
auto text = std::move(prepared.text); auto text = std::move(prepared.text);
const auto settings = &AyuSettings::getInstance(); const auto& settings = AyuSettings::getInstance();
if (date() > 0) { if (date() > 0) {
const auto timeString = QString(" (%1)").arg(QLocale().toString( const auto timeString = QString(" (%1)").arg(QLocale().toString(
base::unixtime::parse(_date), base::unixtime::parse(_date),
settings->showMessageSeconds settings.showMessageSeconds
? QLocale::system().timeFormat(QLocale::LongFormat).remove(" t") ? QLocale::system().timeFormat(QLocale::LongFormat).remove(" t")
: QLocale::system().timeFormat(QLocale::ShortFormat) : QLocale::system().timeFormat(QLocale::ShortFormat)
)); ));
@ -3183,8 +3183,8 @@ void HistoryItem::setDeleted() {
_deleted = true; _deleted = true;
if (isService()) { if (isService()) {
const auto settings = &AyuSettings::getInstance(); const auto& settings = AyuSettings::getInstance();
setAyuHint(settings->deletedMark); setAyuHint(settings.deletedMark);
} else { } else {
history()->owner().requestItemViewRefresh(this); history()->owner().requestItemViewRefresh(this);
history()->owner().requestItemResize(this); history()->owner().requestItemResize(this);

View file

@ -484,13 +484,13 @@ void HistoryMessageReply::updateData(
&& (asExternal || _fields.manualQuote); && (asExternal || _fields.manualQuote);
_multiline = !_fields.storyId && (asExternal || nonEmptyQuote); _multiline = !_fields.storyId && (asExternal || nonEmptyQuote);
const auto settings = &AyuSettings::getInstance(); const auto& settings = AyuSettings::getInstance();
const auto author = resolvedMessage const auto author = resolvedMessage
? resolvedMessage->from().get() ? resolvedMessage->from().get()
: resolvedStory : resolvedStory
? resolvedStory->peer().get() ? resolvedStory->peer().get()
: nullptr; : nullptr;
const auto blocked = settings->hideFromBlocked const auto blocked = settings.hideFromBlocked
&& author && author
&& author->isUser() && author->isUser()
&& author->asUser()->isBlocked(); && author->asUser()->isBlocked();

View file

@ -525,8 +525,8 @@ QString NewMessagePostAuthor(const Api::SendAction &action) {
bool ShouldSendSilent( bool ShouldSendSilent(
not_null<PeerData*> peer, not_null<PeerData*> peer,
const Api::SendOptions &options) { const Api::SendOptions &options) {
const auto settings = &AyuSettings::getInstance(); const auto& settings = AyuSettings::getInstance();
if (settings->sendWithoutSound) { if (settings.sendWithoutSound) {
return true; return true;
} }

View file

@ -510,13 +510,13 @@ HistoryWidget::HistoryWidget(
_fieldCharsCountManager.limitExceeds( _fieldCharsCountManager.limitExceeds(
) | rpl::start_with_next([=] { ) | rpl::start_with_next([=] {
const auto settings = &AyuSettings::getInstance(); const auto& settings = AyuSettings::getInstance();
const auto hide = _fieldCharsCountManager.isLimitExceeded(); const auto hide = _fieldCharsCountManager.isLimitExceeded();
if (_silent) { if (_silent) {
_silent->setVisible(!hide); _silent->setVisible(!hide);
} }
if (_ttlInfo) { if (_ttlInfo) {
_ttlInfo->setVisible(!hide && settings->showAutoDeleteButtonInMessageField); _ttlInfo->setVisible(!hide && settings.showAutoDeleteButtonInMessageField);
} }
if (_giftToUser) { if (_giftToUser) {
_giftToUser->setVisible(!hide); _giftToUser->setVisible(!hide);
@ -1980,8 +1980,8 @@ void HistoryWidget::fileChosen(ChatHelpers::FileChosen &&data) {
Data::InsertCustomEmoji(_field.data(), data.document); Data::InsertCustomEmoji(_field.data(), data.document);
} }
} else if (_history) { } else if (_history) {
const auto settings = &AyuSettings::getInstance(); const auto& settings = AyuSettings::getInstance();
if (!settings->sendReadMessages && settings->markReadAfterAction) { if (!settings.sendReadMessages && settings.markReadAfterAction) {
if (const auto lastMessage = history()->lastMessage()) { if (const auto lastMessage = history()->lastMessage()) {
readHistory(lastMessage); readHistory(lastMessage);
} }
@ -2789,10 +2789,10 @@ void HistoryWidget::setHistory(History *history) {
return; return;
} }
const auto settings = &AyuSettings::getInstance(); const auto& settings = AyuSettings::getInstance();
const auto was = _attachBotsMenu && _history && _history->peer->isUser(); const auto was = _attachBotsMenu && _history && _history->peer->isUser();
const auto now = _attachBotsMenu && history && history->peer->isUser() && settings->showAttachPopup; const auto now = _attachBotsMenu && history && history->peer->isUser() && settings.showAttachPopup;
if (was && !now) { if (was && !now) {
_attachToggle->removeEventFilter(_attachBotsMenu.get()); _attachToggle->removeEventFilter(_attachBotsMenu.get());
_attachBotsMenu->hideFast(); _attachBotsMenu->hideFast();
@ -2875,7 +2875,7 @@ void HistoryWidget::refreshAttachBotsMenu() {
return; return;
} }
const auto settings = &AyuSettings::getInstance(); const auto& settings = AyuSettings::getInstance();
_attachBotsMenu = InlineBots::MakeAttachBotsMenu( _attachBotsMenu = InlineBots::MakeAttachBotsMenu(
this, this,
@ -2888,7 +2888,7 @@ void HistoryWidget::refreshAttachBotsMenu() {
} }
_attachBotsMenu->setOrigin( _attachBotsMenu->setOrigin(
Ui::PanelAnimation::Origin::BottomLeft); Ui::PanelAnimation::Origin::BottomLeft);
if (settings->showAttachPopup) { if (settings.showAttachPopup) {
_attachToggle->installEventFilter(_attachBotsMenu.get()); _attachToggle->installEventFilter(_attachBotsMenu.get());
} }
_attachBotsMenu->heightValue( _attachBotsMenu->heightValue(
@ -3201,7 +3201,7 @@ bool HistoryWidget::canWriteMessage() const {
} }
void HistoryWidget::updateControlsVisibility() { void HistoryWidget::updateControlsVisibility() {
const auto settings = &AyuSettings::getInstance(); const auto& settings = AyuSettings::getInstance();
auto fieldDisabledRemoved = (_fieldDisabled != nullptr); auto fieldDisabledRemoved = (_fieldDisabled != nullptr);
const auto hideExtraButtons = _fieldCharsCountManager.isLimitExceeded(); const auto hideExtraButtons = _fieldCharsCountManager.isLimitExceeded();
@ -3396,27 +3396,27 @@ void HistoryWidget::updateControlsVisibility() {
_botCommandStart->hide(); _botCommandStart->hide();
} else if (_kbReplyTo) { } else if (_kbReplyTo) {
_kbScroll->hide(); _kbScroll->hide();
SWITCH_BUTTON(_tabbedSelectorToggle, settings->showEmojiButtonInMessageField); SWITCH_BUTTON(_tabbedSelectorToggle, settings.showEmojiButtonInMessageField);
_botKeyboardHide->hide(); _botKeyboardHide->hide();
_botKeyboardShow->hide(); _botKeyboardShow->hide();
_botCommandStart->hide(); _botCommandStart->hide();
} else { } else {
_kbScroll->hide(); _kbScroll->hide();
SWITCH_BUTTON(_tabbedSelectorToggle, settings->showEmojiButtonInMessageField); SWITCH_BUTTON(_tabbedSelectorToggle, settings.showEmojiButtonInMessageField);
_botKeyboardHide->hide(); _botKeyboardHide->hide();
if (_keyboard->hasMarkup()) { if (_keyboard->hasMarkup()) {
_botKeyboardShow->show(); _botKeyboardShow->show();
_botCommandStart->hide(); _botCommandStart->hide();
} else { } else {
_botKeyboardShow->hide(); _botKeyboardShow->hide();
_botCommandStart->setVisible(_cmdStartShown && settings->showCommandsButtonInMessageField); _botCommandStart->setVisible(_cmdStartShown && settings.showCommandsButtonInMessageField);
} }
} }
if (_replaceMedia) { if (_replaceMedia) {
_replaceMedia->show(); _replaceMedia->show();
_attachToggle->hide(); _attachToggle->hide();
} else { } else {
SWITCH_BUTTON(_attachToggle, settings->showAttachButtonInMessageField); SWITCH_BUTTON(_attachToggle, settings.showAttachButtonInMessageField);
} }
if (_botMenu.button) { if (_botMenu.button) {
_botMenu.button->show(); _botMenu.button->show();
@ -3452,7 +3452,7 @@ void HistoryWidget::updateControlsVisibility() {
} }
if (_ttlInfo) { if (_ttlInfo) {
const auto was = _ttlInfo->isVisible(); const auto was = _ttlInfo->isVisible();
const auto now = (!_editMsgId) && (!hideExtraButtons) && settings->showAutoDeleteButtonInMessageField; const auto now = (!_editMsgId) && (!hideExtraButtons) && settings.showAutoDeleteButtonInMessageField;
if (was != now) { if (was != now) {
_ttlInfo->setVisible(now); _ttlInfo->setVisible(now);
rightButtonsChanged = true; rightButtonsChanged = true;
@ -4583,14 +4583,14 @@ void HistoryWidget::sendVoice(const VoiceToSend &data) {
} }
void HistoryWidget::send(Api::SendOptions options) { void HistoryWidget::send(Api::SendOptions options) {
const auto settings = &AyuSettings::getInstance(); const auto& settings = AyuSettings::getInstance();
if (AyuSettings::isUseScheduledMessages() && !options.scheduled) { if (AyuSettings::isUseScheduledMessages() && !options.scheduled) {
auto current = base::unixtime::now(); auto current = base::unixtime::now();
options.scheduled = current + 12; options.scheduled = current + 12;
} }
auto lastMessage = _history->lastMessage(); auto lastMessage = _history->lastMessage();
if (!settings->sendReadMessages && settings->markReadAfterAction && lastMessage) { if (!settings.sendReadMessages && settings.markReadAfterAction && lastMessage) {
readHistory(lastMessage); readHistory(lastMessage);
} }
@ -4784,8 +4784,8 @@ void HistoryWidget::goToDiscussionGroup() {
} }
bool HistoryWidget::hasDiscussionGroup() const { bool HistoryWidget::hasDiscussionGroup() const {
const auto settings = &AyuSettings::getInstance(); const auto& settings = AyuSettings::getInstance();
if (settings->channelBottomButton != 2) { if (settings.channelBottomButton != 2) {
return false; return false;
} }
@ -5377,8 +5377,8 @@ bool HistoryWidget::isChoosingTheme() const {
} }
bool HistoryWidget::isMuteUnmute() const { bool HistoryWidget::isMuteUnmute() const {
const auto settings = &AyuSettings::getInstance(); const auto& settings = AyuSettings::getInstance();
if (settings->channelBottomButton == 0) { if (settings.channelBottomButton == 0) {
return false; return false;
} }
@ -5394,8 +5394,8 @@ bool HistoryWidget::isSearching() const {
} }
bool HistoryWidget::showRecordButton() const { bool HistoryWidget::showRecordButton() const {
const auto settings = &AyuSettings::getInstance(); const auto& settings = AyuSettings::getInstance();
if (!settings->showMicrophoneButtonInMessageField) { if (!settings.showMicrophoneButtonInMessageField) {
return false; return false;
} }
@ -5637,7 +5637,7 @@ void HistoryWidget::showKeyboardHideButton() {
} }
void HistoryWidget::toggleKeyboard(bool manual) { void HistoryWidget::toggleKeyboard(bool manual) {
const auto settings = &AyuSettings::getInstance(); const auto& settings = AyuSettings::getInstance();
const auto fieldEnabled = canWriteMessage() && !_showAnimation; const auto fieldEnabled = canWriteMessage() && !_showAnimation;
if (_kbShown || _kbReplyTo) { if (_kbShown || _kbReplyTo) {
@ -5674,7 +5674,7 @@ void HistoryWidget::toggleKeyboard(bool manual) {
_botKeyboardHide->hide(); _botKeyboardHide->hide();
_botKeyboardShow->hide(); _botKeyboardShow->hide();
if (fieldEnabled) { if (fieldEnabled) {
SWITCH_BUTTON(_botCommandStart, settings->showCommandsButtonInMessageField); SWITCH_BUTTON(_botCommandStart, settings.showCommandsButtonInMessageField);
} }
_kbScroll->hide(); _kbScroll->hide();
_kbShown = false; _kbShown = false;
@ -5724,7 +5724,7 @@ void HistoryWidget::toggleKeyboard(bool manual) {
updateFieldPlaceholder(); updateFieldPlaceholder();
SWITCH_BUTTON(_tabbedSelectorToggle, _botKeyboardHide->isHidden() SWITCH_BUTTON(_tabbedSelectorToggle, _botKeyboardHide->isHidden()
&& canWriteMessage() && canWriteMessage()
&& !_showAnimation && settings->showEmojiButtonInMessageField); && !_showAnimation && settings.showEmojiButtonInMessageField);
updateField(); updateField();
} }
@ -5865,7 +5865,7 @@ bool HistoryWidget::fieldOrDisabledShown() const {
} }
void HistoryWidget::moveFieldControls() { void HistoryWidget::moveFieldControls() {
const auto settings = &AyuSettings::getInstance(); const auto& settings = AyuSettings::getInstance();
auto keyboardHeight = 0; auto keyboardHeight = 0;
auto bottom = height(); auto bottom = height();
@ -5891,7 +5891,7 @@ void HistoryWidget::moveFieldControls() {
if (_replaceMedia) { if (_replaceMedia) {
_replaceMedia->moveToLeft(left, buttonsBottom); _replaceMedia->moveToLeft(left, buttonsBottom);
} }
if (settings->showAttachButtonInMessageField) { if (settings.showAttachButtonInMessageField) {
_attachToggle->moveToLeft(left, buttonsBottom); _attachToggle->moveToLeft(left, buttonsBottom);
left += _attachToggle->width(); left += _attachToggle->width();
} }
@ -5912,14 +5912,14 @@ void HistoryWidget::moveFieldControls() {
_voiceRecordBar->moveToLeft(0, bottom - _voiceRecordBar->height()); _voiceRecordBar->moveToLeft(0, bottom - _voiceRecordBar->height());
_tabbedSelectorToggle->moveToRight(right, buttonsBottom); _tabbedSelectorToggle->moveToRight(right, buttonsBottom);
_botKeyboardHide->moveToRight(right, buttonsBottom); _botKeyboardHide->moveToRight(right, buttonsBottom);
right += settings->showEmojiButtonInMessageField || !_botKeyboardHide->isHidden() ? _botKeyboardHide->width() : 0; right += settings.showEmojiButtonInMessageField || !_botKeyboardHide->isHidden() ? _botKeyboardHide->width() : 0;
_botKeyboardShow->moveToRight(right, buttonsBottom); _botKeyboardShow->moveToRight(right, buttonsBottom);
_botCommandStart->moveToRight(right, buttonsBottom); _botCommandStart->moveToRight(right, buttonsBottom);
if (_silent) { if (_silent) {
_silent->moveToRight(right, buttonsBottom); _silent->moveToRight(right, buttonsBottom);
} }
const auto kbShowShown = _history && !_kbShown && _keyboard->hasMarkup(); const auto kbShowShown = _history && !_kbShown && _keyboard->hasMarkup();
if (kbShowShown || (_cmdStartShown && settings->showCommandsButtonInMessageField) || _silent) { if (kbShowShown || (_cmdStartShown && settings.showCommandsButtonInMessageField) || _silent) {
right += _botCommandStart->width(); right += _botCommandStart->width();
} }
if (_giftToUser) { if (_giftToUser) {
@ -5966,14 +5966,14 @@ void HistoryWidget::moveFieldControls() {
} }
void HistoryWidget::updateFieldSize() { void HistoryWidget::updateFieldSize() {
const auto settings = &AyuSettings::getInstance(); const auto& settings = AyuSettings::getInstance();
const auto kbShowShown = _history && !_kbShown && _keyboard->hasMarkup(); const auto kbShowShown = _history && !_kbShown && _keyboard->hasMarkup();
auto fieldWidth = width() auto fieldWidth = width()
- (settings->showAttachButtonInMessageField ? _attachToggle->width() : 0) - (settings.showAttachButtonInMessageField ? _attachToggle->width() : 0)
- st::historySendRight - st::historySendRight
- _send->width() - _send->width()
- (settings->showEmojiButtonInMessageField ? _tabbedSelectorToggle->width() : 0); - (settings.showEmojiButtonInMessageField ? _tabbedSelectorToggle->width() : 0);
if (_botMenu.button) { if (_botMenu.button) {
fieldWidth -= st::historyBotMenuSkip + _botMenu.button->width(); fieldWidth -= st::historyBotMenuSkip + _botMenu.button->width();
} }
@ -5983,7 +5983,7 @@ void HistoryWidget::updateFieldSize() {
if (kbShowShown) { if (kbShowShown) {
fieldWidth -= _botKeyboardShow->width(); fieldWidth -= _botKeyboardShow->width();
} }
if (_cmdStartShown && settings->showCommandsButtonInMessageField) { if (_cmdStartShown && settings.showCommandsButtonInMessageField) {
fieldWidth -= _botCommandStart->width(); fieldWidth -= _botCommandStart->width();
} }
if (_silent && !_silent->isHidden()) { if (_silent && !_silent->isHidden()) {
@ -5995,7 +5995,7 @@ void HistoryWidget::updateFieldSize() {
if (_scheduled && !_scheduled->isHidden()) { if (_scheduled && !_scheduled->isHidden()) {
fieldWidth -= _scheduled->width(); fieldWidth -= _scheduled->width();
} }
if (_ttlInfo && _ttlInfo->isVisible() && settings->showAutoDeleteButtonInMessageField) { if (_ttlInfo && _ttlInfo->isVisible() && settings.showAutoDeleteButtonInMessageField) {
fieldWidth -= _ttlInfo->width(); fieldWidth -= _ttlInfo->width();
} }
@ -7104,7 +7104,7 @@ void HistoryWidget::updateBotKeyboard(History *h, bool force) {
return; return;
} }
const auto settings = &AyuSettings::getInstance(); const auto& settings = AyuSettings::getInstance();
const auto wasVisible = _kbShown || _kbReplyTo; const auto wasVisible = _kbShown || _kbReplyTo;
const auto wasMsgId = _keyboard->forMsgId(); const auto wasMsgId = _keyboard->forMsgId();
@ -7156,7 +7156,7 @@ void HistoryWidget::updateBotKeyboard(History *h, bool force) {
showKeyboardHideButton(); showKeyboardHideButton();
} else { } else {
_kbScroll->hide(); _kbScroll->hide();
SWITCH_BUTTON(_tabbedSelectorToggle, settings->showEmojiButtonInMessageField); SWITCH_BUTTON(_tabbedSelectorToggle, settings.showEmojiButtonInMessageField);
_botKeyboardHide->hide(); _botKeyboardHide->hide();
} }
_botKeyboardShow->hide(); _botKeyboardShow->hide();
@ -7180,7 +7180,7 @@ void HistoryWidget::updateBotKeyboard(History *h, bool force) {
} else { } else {
if (!_showAnimation) { if (!_showAnimation) {
_kbScroll->hide(); _kbScroll->hide();
SWITCH_BUTTON(_tabbedSelectorToggle, settings->showEmojiButtonInMessageField); SWITCH_BUTTON(_tabbedSelectorToggle, settings.showEmojiButtonInMessageField);
_botKeyboardHide->hide(); _botKeyboardHide->hide();
_botKeyboardShow->show(); _botKeyboardShow->show();
_botCommandStart->hide(); _botCommandStart->hide();
@ -7198,11 +7198,11 @@ void HistoryWidget::updateBotKeyboard(History *h, bool force) {
} else { } else {
if (!_scroll->isHidden()) { if (!_scroll->isHidden()) {
_kbScroll->hide(); _kbScroll->hide();
//SWITCH_BUTTON(_tabbedSelectorToggle, settings->showEmojiButtonInMessageField); //SWITCH_BUTTON(_tabbedSelectorToggle, settings.showEmojiButtonInMessageField);
_tabbedSelectorToggle->show(); _tabbedSelectorToggle->show();
_botKeyboardHide->hide(); _botKeyboardHide->hide();
_botKeyboardShow->hide(); _botKeyboardShow->hide();
_botCommandStart->setVisible(!_editMsgId && settings->showCommandsButtonInMessageField); _botCommandStart->setVisible(!_editMsgId && settings.showCommandsButtonInMessageField);
} }
_field->setMaxHeight(computeMaxFieldHeight()); _field->setMaxHeight(computeMaxFieldHeight());
_kbShown = false; _kbShown = false;

View file

@ -2129,7 +2129,7 @@ void VoiceRecordBar::stopRecording(StopType type, bool ttlBeforeHide) {
: 0), : 0),
}; };
auto settings = &AyuSettings::getInstance(); const auto& settings = AyuSettings::getInstance();
if (AyuSettings::isUseScheduledMessages()) { if (AyuSettings::isUseScheduledMessages()) {
auto current = base::unixtime::now(); auto current = base::unixtime::now();
options.scheduled = current + 12 + 5; options.scheduled = current + 12 + 5;
@ -2147,7 +2147,7 @@ void VoiceRecordBar::stopRecording(StopType type, bool ttlBeforeHide) {
close(); close();
}); });
if (settings->voiceConfirmation) { if (settings.voiceConfirmation) {
_show->showBox(Ui::MakeConfirmBox( _show->showBox(Ui::MakeConfirmBox(
{ {
.text = tr::ayu_ConfirmationVoice(), .text = tr::ayu_ConfirmationVoice(),
@ -2221,7 +2221,7 @@ void VoiceRecordBar::requestToSendWithOptions(Api::SendOptions options) {
options.ttlSeconds = std::numeric_limits<int>::max(); options.ttlSeconds = std::numeric_limits<int>::max();
} }
auto settings = &AyuSettings::getInstance(); const auto& settings = AyuSettings::getInstance();
if (AyuSettings::isUseScheduledMessages()) { if (AyuSettings::isUseScheduledMessages()) {
auto current = base::unixtime::now(); auto current = base::unixtime::now();
options.scheduled = current + 12 + 5; options.scheduled = current + 12 + 5;
@ -2240,7 +2240,7 @@ void VoiceRecordBar::requestToSendWithOptions(Api::SendOptions options) {
close(); close();
}); });
if (settings->voiceConfirmation) { if (settings.voiceConfirmation) {
_show->showBox(Ui::MakeConfirmBox( _show->showBox(Ui::MakeConfirmBox(
{ {
.text = tr::ayu_ConfirmationVoice(), .text = tr::ayu_ConfirmationVoice(),

View file

@ -415,14 +415,14 @@ void BottomInfo::layout() {
} }
void BottomInfo::layoutDateText() { void BottomInfo::layoutDateText() {
const auto settings = &AyuSettings::getInstance(); const auto& settings = AyuSettings::getInstance();
if (!settings->replaceBottomInfoWithIcons) { if (!settings.replaceBottomInfoWithIcons) {
const auto deleted = (_data.flags & Data::Flag::AyuDeleted) const auto deleted = (_data.flags & Data::Flag::AyuDeleted)
? (settings->deletedMark + ' ') ? (settings.deletedMark + ' ')
: QString(); : QString();
const auto edited = (_data.flags & Data::Flag::Edited) const auto edited = (_data.flags & Data::Flag::Edited)
? (settings->editedMark + ' ') ? (settings.editedMark + ' ')
: (_data.flags & Data::Flag::EstimateDate) : (_data.flags & Data::Flag::EstimateDate)
? (tr::lng_approximate(tr::now) + ' ') ? (tr::lng_approximate(tr::now) + ' ')
: QString(); : QString();
@ -430,7 +430,7 @@ void BottomInfo::layoutDateText() {
const auto prefix = !author.isEmpty() ? u", "_q : QString(); const auto prefix = !author.isEmpty() ? u", "_q : QString();
const auto date = edited + QLocale().toString( const auto date = edited + QLocale().toString(
_data.date.time(), _data.date.time(),
settings->showMessageSeconds settings.showMessageSeconds
? QLocale::system().timeFormat(QLocale::LongFormat).remove(" t") ? QLocale::system().timeFormat(QLocale::LongFormat).remove(" t")
: QLocale::system().timeFormat(QLocale::ShortFormat) : QLocale::system().timeFormat(QLocale::ShortFormat)
); );
@ -496,7 +496,7 @@ void BottomInfo::layoutDateText() {
const auto date = TextWithEntities{}.append(edited).append(QLocale().toString( const auto date = TextWithEntities{}.append(edited).append(QLocale().toString(
_data.date.time(), _data.date.time(),
settings->showMessageSeconds settings.showMessageSeconds
? QLocale::system().timeFormat(QLocale::LongFormat).remove(" t") ? QLocale::system().timeFormat(QLocale::LongFormat).remove(" t")
: QLocale::system().timeFormat(QLocale::ShortFormat) : QLocale::system().timeFormat(QLocale::ShortFormat)
)); ));

View file

@ -1513,8 +1513,8 @@ void AddWhoReactedAction(
not_null<QWidget*> context, not_null<QWidget*> context,
not_null<HistoryItem*> item, not_null<HistoryItem*> item,
not_null<Window::SessionController*> controller) { not_null<Window::SessionController*> controller) {
const auto settings = &AyuSettings::getInstance(); const auto& settings = AyuSettings::getInstance();
if (!AyuUi::needToShowItem(settings->showViewsPanelInContextMenu)) { if (!AyuUi::needToShowItem(settings.showViewsPanelInContextMenu)) {
return; return;
} }

View file

@ -646,8 +646,8 @@ void Reply::paint(
Ui::Text::ValidateQuotePaintCache(*cache, quoteSt); Ui::Text::ValidateQuotePaintCache(*cache, quoteSt);
Ui::Text::FillQuotePaint(p, rect, *cache, quoteSt); Ui::Text::FillQuotePaint(p, rect, *cache, quoteSt);
const auto settings = &AyuSettings::getInstance(); const auto& settings = AyuSettings::getInstance();
if (!settings->simpleQuotesAndReplies && backgroundEmoji) { if (!settings.simpleQuotesAndReplies && backgroundEmoji) {
ValidateBackgroundEmoji( ValidateBackgroundEmoji(
backgroundEmojiId, backgroundEmojiId,
backgroundEmoji, backgroundEmoji,

View file

@ -67,8 +67,8 @@ bool SendActionPainter::updateNeedsAnimating(
return false; return false;
} }
const auto settings = &AyuSettings::getInstance(); const auto& settings = AyuSettings::getInstance();
if (settings->hideFromBlocked) { if (settings.hideFromBlocked) {
if (user->isBlocked()) { if (user->isBlocked()) {
return false; return false;
} }

View file

@ -788,8 +788,8 @@ void TopBarWidget::infoClicked() {
void TopBarWidget::backClicked() { void TopBarWidget::backClicked() {
if (_activeChat.key.folder()) { if (_activeChat.key.folder()) {
auto settings = &AyuSettings::getInstance(); const auto& settings = AyuSettings::getInstance();
if (settings->hideAllChatsFolder) { if (settings.hideAllChatsFolder) {
const auto filters = &_controller->session().data().chatsFilters(); const auto filters = &_controller->session().data().chatsFilters();
const auto lookupId = filters->lookupId(_controller->session().premium() ? 0 : 1); const auto lookupId = filters->lookupId(_controller->session().premium() ? 0 : 1);
_controller->setActiveChatsFilter(lookupId); _controller->setActiveChatsFilter(lookupId);
@ -1156,11 +1156,11 @@ void TopBarWidget::updateControlsVisibility() {
return; return;
} }
const auto settings = &AyuSettings::getInstance(); const auto& settings = AyuSettings::getInstance();
_clear->show(); _clear->show();
_delete->setVisible(_canDelete); _delete->setVisible(_canDelete);
_messageShot->setVisible(settings->showMessageShot); _messageShot->setVisible(settings.showMessageShot);
_forward->setVisible(_canForward); _forward->setVisible(_canForward);
_sendNow->setVisible(_canSendNow); _sendNow->setVisible(_canSendNow);
@ -1337,19 +1337,19 @@ void TopBarWidget::updateMembersShowArea() {
} }
bool TopBarWidget::showSelectedState() const { bool TopBarWidget::showSelectedState() const {
const auto settings = &AyuSettings::getInstance(); const auto& settings = AyuSettings::getInstance();
return (_selectedCount > 0) return (_selectedCount > 0)
&& (_canDelete || _canForward || _canSendNow || settings->showMessageShot); && (_canDelete || _canForward || _canSendNow || settings.showMessageShot);
} }
void TopBarWidget::showSelected(SelectedState state) { void TopBarWidget::showSelected(SelectedState state) {
const auto settings = &AyuSettings::getInstance(); const auto& settings = AyuSettings::getInstance();
auto canDelete = (state.count > 0 && state.count == state.canDeleteCount); auto canDelete = (state.count > 0 && state.count == state.canDeleteCount);
auto canForward = (state.count > 0 && state.count == state.canForwardCount); auto canForward = (state.count > 0 && state.count == state.canForwardCount);
auto canSendNow = (state.count > 0 && state.count == state.canSendNowCount); auto canSendNow = (state.count > 0 && state.count == state.canSendNowCount);
auto count = (!canDelete && !canForward && !canSendNow && !settings->showMessageShot) ? 0 : state.count; auto count = (!canDelete && !canForward && !canSendNow && !settings.showMessageShot) ? 0 : state.count;
if (_selectedCount == count if (_selectedCount == count
&& _canDelete == canDelete && _canDelete == canDelete
&& _canForward == canForward && _canForward == canForward

View file

@ -325,8 +325,8 @@ Document::Document(
const auto &data = &_parent->data()->history()->owner(); const auto &data = &_parent->data()->history()->owner();
_parent->data()->removeFromSharedMediaIndex(); _parent->data()->removeFromSharedMediaIndex();
setDocumentLinks(_data, realParent, [=] { setDocumentLinks(_data, realParent, [=] {
const auto settings = &AyuSettings::getInstance(); const auto& settings = AyuSettings::getInstance();
if (!settings->saveDeletedMessages) { if (!settings.saveDeletedMessages) {
_openl = nullptr; _openl = nullptr;
} }

View file

@ -936,8 +936,8 @@ void WebPage::draw(Painter &p, const PaintContext &context) const {
Ui::Text::ValidateQuotePaintCache(*cache, _st); Ui::Text::ValidateQuotePaintCache(*cache, _st);
Ui::Text::FillQuotePaint(p, outer, *cache, _st); Ui::Text::FillQuotePaint(p, outer, *cache, _st);
const auto settings = &AyuSettings::getInstance(); const auto& settings = AyuSettings::getInstance();
if (!settings->simpleQuotesAndReplies && backgroundEmoji) { if (!settings.simpleQuotesAndReplies && backgroundEmoji) {
ValidateBackgroundEmoji( ValidateBackgroundEmoji(
backgroundEmojiId, backgroundEmojiId,
backgroundEmoji, backgroundEmoji,

View file

@ -1189,8 +1189,8 @@ bool AdjustMenuGeometryForSelector(
not_null<Ui::PopupMenu*> menu, not_null<Ui::PopupMenu*> menu,
QPoint desiredPosition, QPoint desiredPosition,
not_null<Selector*> selector) { not_null<Selector*> selector) {
const auto settings = &AyuSettings::getInstance(); const auto& settings = AyuSettings::getInstance();
if (!AyuUi::needToShowItem(settings->showReactionsPanelInContextMenu)) { if (!AyuUi::needToShowItem(settings.showReactionsPanelInContextMenu)) {
return false; return false;
} }
@ -1357,8 +1357,8 @@ AttachSelectorResult AttachSelectorToMenu(
Fn<void(ChosenReaction)> chosen, Fn<void(ChosenReaction)> chosen,
TextWithEntities about, TextWithEntities about,
IconFactory iconFactory) { IconFactory iconFactory) {
const auto settings = &AyuSettings::getInstance(); const auto& settings = AyuSettings::getInstance();
if (!AyuUi::needToShowItem(settings->showReactionsPanelInContextMenu)) { if (!AyuUi::needToShowItem(settings.showReactionsPanelInContextMenu)) {
return AttachSelectorResult::Skipped; return AttachSelectorResult::Skipped;
} }
@ -1409,8 +1409,8 @@ auto AttachSelectorToMenu(
IconFactory iconFactory, IconFactory iconFactory,
Fn<bool()> paused) Fn<bool()> paused)
-> base::expected<not_null<Selector*>, AttachSelectorResult> { -> base::expected<not_null<Selector*>, AttachSelectorResult> {
const auto settings = &AyuSettings::getInstance(); const auto& settings = AyuSettings::getInstance();
if (!AyuUi::needToShowItem(settings->showReactionsPanelInContextMenu)) { if (!AyuUi::needToShowItem(settings.showReactionsPanelInContextMenu)) {
return base::make_unexpected(AttachSelectorResult::Skipped); return base::make_unexpected(AttachSelectorResult::Skipped);
} }

View file

@ -505,8 +505,8 @@ void TopBar::updateControlsVisibility(anim::type animated) {
void TopBar::setStories(rpl::producer<Dialogs::Stories::Content> content) { void TopBar::setStories(rpl::producer<Dialogs::Stories::Content> content) {
// AyuGram disableStories // AyuGram disableStories
const auto settings = &AyuSettings::getInstance(); const auto& settings = AyuSettings::getInstance();
if (settings->disableStories) { if (settings.disableStories) {
return; return;
} }

View file

@ -1191,7 +1191,7 @@ bool SetClickContext(
} }
object_ptr<Ui::RpWidget> DetailsFiller::setupInfo() { object_ptr<Ui::RpWidget> DetailsFiller::setupInfo() {
auto settings = &AyuSettings::getInstance(); const auto& settings = AyuSettings::getInstance();
auto result = object_ptr<Ui::VerticalLayout>(_wrap); auto result = object_ptr<Ui::VerticalLayout>(_wrap);
auto tracker = Ui::MultiSlideTracker(); auto tracker = Ui::MultiSlideTracker();
@ -1501,7 +1501,7 @@ object_ptr<Ui::RpWidget> DetailsFiller::setupInfo() {
).text->setLinksTrusted(); ).text->setLinksTrusted();
} }
if (settings->showPeerId != 0) { if (settings.showPeerId != 0) {
const auto dataCenter = getPeerDC(_peer); const auto dataCenter = getPeerDC(_peer);
const auto idLabel = dataCenter.isEmpty() ? QString("ID") : dataCenter; const auto idLabel = dataCenter.isEmpty() ? QString("ID") : dataCenter;
@ -1637,7 +1637,7 @@ object_ptr<Ui::RpWidget> DetailsFiller::setupInfo() {
addTranslateToMenu(about.text, AboutWithAdvancedValue(_peer)); addTranslateToMenu(about.text, AboutWithAdvancedValue(_peer));
} }
if (settings->showPeerId != 0 && !_topic) { if (settings.showPeerId != 0 && !_topic) {
const auto dataCenter = getPeerDC(_peer); const auto dataCenter = getPeerDC(_peer);
const auto idLabel = dataCenter.isEmpty() ? QString("ID") : dataCenter; const auto idLabel = dataCenter.isEmpty() ? QString("ID") : dataCenter;
@ -1665,7 +1665,7 @@ object_ptr<Ui::RpWidget> DetailsFiller::setupInfo() {
}); });
} }
if (settings->showPeerId != 0 && _topic) { if (settings.showPeerId != 0 && _topic) {
auto idDrawableText = IDValue( auto idDrawableText = IDValue(
_peer->forumTopicFor(topicRootId)->topicRootId() _peer->forumTopicFor(topicRootId)->topicRootId()
) | rpl::map([](TextWithEntities &&text) ) | rpl::map([](TextWithEntities &&text)

View file

@ -140,7 +140,7 @@ object_ptr<Ui::RpWidget> InnerWidget::setupSharedMedia(
using namespace rpl::mappers; using namespace rpl::mappers;
using MediaType = Media::Type; using MediaType = Media::Type;
const auto settings = &AyuSettings::getInstance(); const auto& settings = AyuSettings::getInstance();
auto content = object_ptr<Ui::VerticalLayout>(parent); auto content = object_ptr<Ui::VerticalLayout>(parent);
auto tracker = Ui::MultiSlideTracker(); auto tracker = Ui::MultiSlideTracker();
@ -176,7 +176,7 @@ object_ptr<Ui::RpWidget> InnerWidget::setupSharedMedia(
const auto addSimilarPeersButton = [&]( const auto addSimilarPeersButton = [&](
not_null<PeerData*> peer, not_null<PeerData*> peer,
const style::icon &icon) { const style::icon &icon) {
if (settings->hideSimilarChannels) { if (settings.hideSimilarChannels) {
return; return;
} }

View file

@ -765,8 +765,8 @@ void BotAction::handleKeyPress(not_null<QKeyEvent*> e) {
} }
QString WebviewPlatform() { QString WebviewPlatform() {
const auto settings = &AyuSettings::getInstance(); const auto& settings = AyuSettings::getInstance();
return settings->spoofWebviewAsAndroid ? "android" : "tdesktop"; return settings.spoofWebviewAsAndroid ? "android" : "tdesktop";
} }
} // namespace } // namespace

View file

@ -319,8 +319,8 @@ rpl::producer<> Session::downloaderTaskFinished() const {
} }
bool Session::premium() const { bool Session::premium() const {
auto settings = &AyuSettings::getInstance(); const auto& settings = AyuSettings::getInstance();
if (settings->localPremium) { if (settings.localPremium) {
return true; return true;
} }
@ -328,8 +328,8 @@ bool Session::premium() const {
} }
bool Session::premiumPossible() const { bool Session::premiumPossible() const {
auto settings = &AyuSettings::getInstance(); const auto& settings = AyuSettings::getInstance();
if (settings->localPremium) { if (settings.localPremium) {
return true; return true;
} }
@ -351,8 +351,8 @@ rpl::producer<bool> Session::premiumPossibleValue() const {
return _user->isPremium(); return _user->isPremium();
}); });
auto settings = &AyuSettings::getInstance(); const auto& settings = AyuSettings::getInstance();
if (settings->localPremium) { if (settings.localPremium) {
premium = rpl::single(true); premium = rpl::single(true);
} }

View file

@ -100,8 +100,8 @@ void RepostView::draw(Painter &p, int x, int y, int availableWidth) {
Ui::Text::ValidateQuotePaintCache(*cache, quoteSt); Ui::Text::ValidateQuotePaintCache(*cache, quoteSt);
Ui::Text::FillQuotePaint(p, rect, *cache, quoteSt); Ui::Text::FillQuotePaint(p, rect, *cache, quoteSt);
const auto settings = &AyuSettings::getInstance(); const auto& settings = AyuSettings::getInstance();
if (!settings->simpleQuotesAndReplies && backgroundEmoji) { if (!settings.simpleQuotesAndReplies && backgroundEmoji) {
using namespace HistoryView; using namespace HistoryView;
if (backgroundEmoji->firstFrameMask.isNull() if (backgroundEmoji->firstFrameMask.isNull()
&& !backgroundEmoji->emoji) { && !backgroundEmoji->emoji) {

View file

@ -512,10 +512,10 @@ void MainWindow::unreadCounterChangedHook() {
} }
void MainWindow::updateTaskbarAndIconCounters() { void MainWindow::updateTaskbarAndIconCounters() {
const auto settings = &AyuSettings::getInstance(); const auto& settings = AyuSettings::getInstance();
const auto counter = settings->hideNotificationBadge ? 0 : Core::App().unreadBadge(); const auto counter = settings.hideNotificationBadge ? 0 : Core::App().unreadBadge();
const auto muted = settings->hideNotificationBadge ? 0 : Core::App().unreadBadgeMuted(); const auto muted = settings.hideNotificationBadge ? 0 : Core::App().unreadBadgeMuted();
const auto controller = sessionController(); const auto controller = sessionController();
const auto session = controller ? &controller->session() : nullptr; const auto session = controller ? &controller->session() : nullptr;

View file

@ -142,8 +142,8 @@ bool DarkTasbarValueValid/* = false*/;
ScaledLogoLight = base::flat_map<int, QImage>(); ScaledLogoLight = base::flat_map<int, QImage>();
} }
const auto settings = &AyuSettings::getInstance(); const auto& settings = AyuSettings::getInstance();
if (settings->hideNotificationBadge) { if (settings.hideNotificationBadge) {
args.count = 0; args.count = 0;
} }

View file

@ -1042,8 +1042,8 @@ QPointer<Ui::RpWidget> Premium::createPinnedToTop(
} }
} }
auto settings = &AyuSettings::getInstance(); const auto& settings = AyuSettings::getInstance();
if (settings->localPremium) { if (settings.localPremium) {
return tr::ayu_LocalPremiumNotice(Ui::Text::RichLangValue); return tr::ayu_LocalPremiumNotice(Ui::Text::RichLangValue);
} }

View file

@ -102,9 +102,9 @@ void Tray::rebuildMenu() {
[=] { toggleSoundNotifications(); }); [=] { toggleSoundNotifications(); });
} }
auto settings = &AyuSettings::getInstance(); const auto& settings = AyuSettings::getInstance();
if (settings->showGhostToggleInTray) { if (settings.showGhostToggleInTray) {
auto turnGhostModeText = _textUpdates.events( auto turnGhostModeText = _textUpdates.events(
) | rpl::map( ) | rpl::map(
[=] [=]
@ -121,13 +121,13 @@ void Tray::rebuildMenu() {
{ {
bool ghostMode = AyuSettings::isGhostModeActive(); bool ghostMode = AyuSettings::isGhostModeActive();
settings->set_ghostModeEnabled(!ghostMode); AyuSettings::set_ghostModeEnabled(!ghostMode);
AyuSettings::save(); AyuSettings::save();
}); });
} }
if (settings->showStreamerToggleInTray) { if (settings.showStreamerToggleInTray) {
auto turnStreamerModeText = _textUpdates.events( auto turnStreamerModeText = _textUpdates.events(
) | rpl::map( ) | rpl::map(
[=] [=]

View file

@ -386,12 +386,12 @@ Panel::Panel(Args &&args)
, _allowClipboardRead(args.allowClipboardRead) { , _allowClipboardRead(args.allowClipboardRead) {
_widget->setWindowFlag(Qt::WindowStaysOnTopHint, false); _widget->setWindowFlag(Qt::WindowStaysOnTopHint, false);
const auto settings = &AyuSettings::getInstance(); const auto& settings = AyuSettings::getInstance();
auto size = QSize(st::botWebViewPanelSize); auto size = QSize(st::botWebViewPanelSize);
if (settings->increaseWebviewHeight) { if (settings.increaseWebviewHeight) {
size.setHeight(st::botWebViewPanelHeightIncreased); size.setHeight(st::botWebViewPanelHeightIncreased);
} }
if (settings->increaseWebviewWidth) { if (settings.increaseWebviewWidth) {
size.setWidth(st::botWebViewPanelWidthIncreased); size.setWidth(st::botWebViewPanelWidthIncreased);
} }

View file

@ -48,8 +48,8 @@ void EnsureBlockquoteCache(
cache->outlines = colors.outlines; cache->outlines = colors.outlines;
cache->icon = colors.name; cache->icon = colors.name;
const auto settings = &AyuSettings::getInstance(); const auto& settings = AyuSettings::getInstance();
if (settings->simpleQuotesAndReplies) { if (settings.simpleQuotesAndReplies) {
cache->bg = QColor(0, 0, 0, 0); cache->bg = QColor(0, 0, 0, 0);
} }
} }

View file

@ -339,8 +339,8 @@ System::Timing System::countTiming(
delay = config.notifyDefaultDelay; delay = config.notifyDefaultDelay;
} }
const auto settings = &AyuSettings::getInstance(); const auto& settings = AyuSettings::getInstance();
if (settings->disableNotificationsDelay) { if (settings.disableNotificationsDelay) {
delay = minimalDelay; delay = minimalDelay;
} }

View file

@ -482,9 +482,9 @@ auto ChatThemeValueFromPeer(
peer peer
) | rpl::map([=](ResolvedTheme resolved) ) | rpl::map([=](ResolvedTheme resolved)
-> rpl::producer<std::shared_ptr<Ui::ChatTheme>> { -> rpl::producer<std::shared_ptr<Ui::ChatTheme>> {
const auto settings = &AyuSettings::getInstance(); const auto& settings = AyuSettings::getInstance();
// this check ensures that background is not a pattern wallpaper in a private chat // this check ensures that background is not a pattern wallpaper in a private chat
if (settings->disableCustomBackgrounds && resolved.paper && resolved.paper->media) { if (settings.disableCustomBackgrounds && resolved.paper && resolved.paper->media) {
resolved.paper = std::nullopt; resolved.paper = std::nullopt;
} }

View file

@ -140,8 +140,8 @@ void FiltersMenu::setupMainMenuIcon() {
? &st::windowFiltersMainMenuUnread ? &st::windowFiltersMainMenuUnread
: &st::windowFiltersMainMenuUnreadMuted; : &st::windowFiltersMainMenuUnreadMuted;
const auto settings = &AyuSettings::getInstance(); const auto& settings = AyuSettings::getInstance();
if (settings->hideNotificationCounters) { if (settings.hideNotificationCounters) {
icon = nullptr; icon = nullptr;
} }
@ -177,7 +177,7 @@ void FiltersMenu::scrollToButton(not_null<Ui::RpWidget*> widget) {
void FiltersMenu::refresh() { void FiltersMenu::refresh() {
// AyuGram hideAllChatsFolder // AyuGram hideAllChatsFolder
const auto settings = &AyuSettings::getInstance(); const auto& settings = AyuSettings::getInstance();
const auto filters = &_session->session().data().chatsFilters(); const auto filters = &_session->session().data().chatsFilters();
if (!filters->has() || _ignoreRefresh) { if (!filters->has() || _ignoreRefresh) {
@ -194,7 +194,7 @@ void FiltersMenu::refresh() {
const auto maxLimit = (reorderAll ? 1 : 0) const auto maxLimit = (reorderAll ? 1 : 0)
+ Data::PremiumLimits(&_session->session()).dialogFiltersCurrent(); + Data::PremiumLimits(&_session->session()).dialogFiltersCurrent();
const auto premiumFrom = (reorderAll ? 0 : 1) + maxLimit; const auto premiumFrom = (reorderAll ? 0 : 1) + maxLimit;
if (!reorderAll && !settings->hideAllChatsFolder) { if (!reorderAll && !settings.hideAllChatsFolder) {
_reorder->addPinnedInterval(0, 1); _reorder->addPinnedInterval(0, 1);
} }
_reorder->addPinnedInterval( _reorder->addPinnedInterval(
@ -229,7 +229,7 @@ void FiltersMenu::refresh() {
// Also check for session content existance, because it may be null // Also check for session content existance, because it may be null
// and there will be an exception in `Window::SessionController::showPeerHistory` // and there will be an exception in `Window::SessionController::showPeerHistory`
// because `SessionController::content()` == nullptr // because `SessionController::content()` == nullptr
if (settings->hideAllChatsFolder && _session->widget()->sessionContent()) { if (settings.hideAllChatsFolder && _session->widget()->sessionContent()) {
const auto lookupId = filters->lookupId(0); const auto lookupId = filters->lookupId(0);
_session->setActiveChatsFilter(lookupId); _session->setActiveChatsFilter(lookupId);
} }
@ -310,8 +310,8 @@ base::unique_qptr<Ui::SideBarButton> FiltersMenu::prepareButton(
auto count = (chats + state.marks) auto count = (chats + state.marks)
- (includeMuted ? 0 : muted); - (includeMuted ? 0 : muted);
const auto settings = &AyuSettings::getInstance(); const auto& settings = AyuSettings::getInstance();
if (settings->hideNotificationCounters) { if (settings.hideNotificationCounters) {
count = 0; count = 0;
muted = 0; muted = 0;
} }
@ -457,11 +457,11 @@ void FiltersMenu::applyReorder(
} }
// AyuGram hideAllChatsFolder // AyuGram hideAllChatsFolder
const auto settings = &AyuSettings::getInstance(); const auto& settings = AyuSettings::getInstance();
const auto filters = &_session->session().data().chatsFilters(); const auto filters = &_session->session().data().chatsFilters();
const auto &list = filters->list(); const auto &list = filters->list();
if (!settings->hideAllChatsFolder && !premium()) { if (!settings.hideAllChatsFolder && !premium()) {
if (list[0].id() != FilterId()) { if (list[0].id() != FilterId()) {
filters->moveAllToFront(); filters->moveAllToFront();
} }

View file

@ -639,7 +639,7 @@ void MainMenu::showFinished() {
void MainMenu::setupMenu() { void MainMenu::setupMenu() {
using namespace Settings; using namespace Settings;
const auto settings = &AyuSettings::getInstance(); const auto& settings = AyuSettings::getInstance();
const auto controller = _controller; const auto controller = _controller;
const auto addAction = [&]( const auto addAction = [&](
@ -706,28 +706,28 @@ void MainMenu::setupMenu() {
controller->showPeerHistory(controller->session().user()); controller->showPeerHistory(controller->session().user());
}); });
const auto settings = &AyuSettings::getInstance(); const auto& settings = AyuSettings::getInstance();
if (settings->showLReadToggleInDrawer) { if (settings.showLReadToggleInDrawer) {
addAction( addAction(
tr::ayu_LReadMessages(), tr::ayu_LReadMessages(),
{&st::ayuLReadMenuIcon} {&st::ayuLReadMenuIcon}
)->setClickedCallback([=] )->setClickedCallback([=]
{ {
auto prev = settings->sendReadMessages; auto prev = settings.sendReadMessages;
settings->set_sendReadMessages(false); AyuSettings::set_sendReadMessages(false);
auto chats = controller->session().data().chatsList(); auto chats = controller->session().data().chatsList();
MarkAsReadChatList(chats); MarkAsReadChatList(chats);
settings->set_sendReadMessages(prev); AyuSettings::set_sendReadMessages(prev);
}); });
} }
if (settings->showSReadToggleInDrawer) { if (settings.showSReadToggleInDrawer) {
auto callback = [=](Fn<void()> &&close) { auto callback = [=](Fn<void()> &&close) {
auto prev = settings->sendReadMessages; auto prev = settings.sendReadMessages;
settings->set_sendReadMessages(true); AyuSettings::set_sendReadMessages(true);
auto chats = controller->session().data().chatsList(); auto chats = controller->session().data().chatsList();
MarkAsReadChatList(chats); MarkAsReadChatList(chats);
@ -735,7 +735,7 @@ void MainMenu::setupMenu() {
// slight delay for forums to send packets // slight delay for forums to send packets
dispatchToMainThread([=] dispatchToMainThread([=]
{ {
settings->set_sendReadMessages(prev); AyuSettings::set_sendReadMessages(prev);
}, 200); }, 200);
close(); close();
}; };
@ -814,7 +814,7 @@ void MainMenu::setupMenu() {
toggle); toggle);
}, _nightThemeToggle->lifetime()); }, _nightThemeToggle->lifetime());
if (settings->showGhostToggleInDrawer) { if (settings.showGhostToggleInDrawer) {
_ghostModeToggle = addAction( _ghostModeToggle = addAction(
tr::ayu_GhostModeToggle(), tr::ayu_GhostModeToggle(),
{&st::ayuGhostIcon} {&st::ayuGhostIcon}
@ -824,13 +824,13 @@ void MainMenu::setupMenu() {
) | rpl::start_with_next( ) | rpl::start_with_next(
[=](bool ghostMode) [=](bool ghostMode)
{ {
settings->set_ghostModeEnabled(ghostMode); AyuSettings::set_ghostModeEnabled(ghostMode);
AyuSettings::save(); AyuSettings::save();
}, },
_ghostModeToggle->lifetime()); _ghostModeToggle->lifetime());
} }
if (settings->showStreamerToggleInDrawer) { if (settings.showStreamerToggleInDrawer) {
_streamerModeToggle = addAction( _streamerModeToggle = addAction(
tr::ayu_StreamerModeToggle(), tr::ayu_StreamerModeToggle(),
{&st::ayuStreamerModeMenuIcon} {&st::ayuStreamerModeMenuIcon}

View file

@ -1794,8 +1794,8 @@ void SessionController::activateFirstChatsFilter() {
} }
_filtersActivated = true; _filtersActivated = true;
auto settings = &AyuSettings::getInstance(); const auto& settings = AyuSettings::getInstance();
if (!settings->hideAllChatsFolder) { if (!settings.hideAllChatsFolder) {
setActiveChatsFilter(session().data().chatsFilters().defaultId()); setActiveChatsFilter(session().data().chatsFilters().defaultId());
} }
} }