mirror of
https://github.com/kotatogram/kotatogram-desktop
synced 2025-09-05 09:05:14 +00:00
Remove non-UI calls to App::main.
This commit is contained in:
@@ -9,6 +9,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
|
||||
#include "dialogs/dialogs_key.h"
|
||||
#include "dialogs/dialogs_indexed_list.h"
|
||||
#include "data/data_changes.h"
|
||||
#include "data/data_session.h"
|
||||
#include "data/data_folder.h"
|
||||
#include "data/data_chat_filters.h"
|
||||
@@ -41,10 +42,10 @@ uint64 PinnedDialogPos(int pinnedIndex) {
|
||||
|
||||
} // namespace
|
||||
|
||||
Entry::Entry(not_null<Data::Session*> owner, const Key &key)
|
||||
Entry::Entry(not_null<Data::Session*> owner, Type type)
|
||||
: lastItemTextCache(st::dialogsTextWidthMin)
|
||||
, _owner(owner)
|
||||
, _key(key) {
|
||||
, _isFolder(type == Type::Folder) {
|
||||
}
|
||||
|
||||
Data::Session &Entry::owner() const {
|
||||
@@ -55,6 +56,14 @@ Main::Session &Entry::session() const {
|
||||
return _owner->session();
|
||||
}
|
||||
|
||||
History *Entry::asHistory() {
|
||||
return _isFolder ? nullptr : static_cast<History*>(this);
|
||||
}
|
||||
|
||||
Data::Folder *Entry::asFolder() {
|
||||
return _isFolder ? static_cast<Data::Folder*>(this) : nullptr;
|
||||
}
|
||||
|
||||
void Entry::pinnedIndexChanged(int was, int now) {
|
||||
if (session().supportMode()) {
|
||||
// Force reorder in support mode.
|
||||
@@ -159,13 +168,11 @@ void Entry::notifyUnreadStateChange(const UnreadState &wasState) {
|
||||
}
|
||||
|
||||
void Entry::setChatListExistence(bool exists) {
|
||||
if (const auto main = App::main()) {
|
||||
if (exists && _sortKeyInChatList) {
|
||||
main->refreshDialog(_key);
|
||||
updateChatListEntry();
|
||||
} else {
|
||||
main->removeDialog(_key);
|
||||
}
|
||||
if (exists && _sortKeyInChatList) {
|
||||
owner().refreshChatListEntry(this);
|
||||
updateChatListEntry();
|
||||
} else {
|
||||
owner().removeChatListEntry(this);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -228,7 +235,7 @@ not_null<Row*> Entry::addToChatList(
|
||||
}
|
||||
return _chatListLinks.emplace(
|
||||
filterId,
|
||||
list->addEntry(_key)
|
||||
list->addEntry(this)
|
||||
).first->second.main;
|
||||
}
|
||||
|
||||
@@ -236,7 +243,7 @@ void Entry::removeFromChatList(
|
||||
FilterId filterId,
|
||||
not_null<MainList*> list) {
|
||||
if (isPinnedDialog(filterId)) {
|
||||
owner().setChatPinned(_key, filterId, false);
|
||||
owner().setChatPinned(this, filterId, false);
|
||||
}
|
||||
|
||||
const auto i = _chatListLinks.find(filterId);
|
||||
@@ -244,7 +251,7 @@ void Entry::removeFromChatList(
|
||||
return;
|
||||
}
|
||||
_chatListLinks.erase(i);
|
||||
list->removeEntry(_key);
|
||||
list->removeEntry(this);
|
||||
}
|
||||
|
||||
void Entry::removeChatListEntryByLetter(FilterId filterId, QChar letter) {
|
||||
@@ -264,16 +271,8 @@ void Entry::addChatListEntryByLetter(
|
||||
}
|
||||
}
|
||||
|
||||
void Entry::updateChatListEntry() const {
|
||||
if (const auto main = App::main()) {
|
||||
for (const auto &[filterId, links] : _chatListLinks) {
|
||||
main->repaintDialogRow(filterId, links.main);
|
||||
}
|
||||
if (session().supportMode()
|
||||
&& !session().settings().supportAllSearchResults()) {
|
||||
main->repaintDialogRow({ _key, FullMsgId() });
|
||||
}
|
||||
}
|
||||
void Entry::updateChatListEntry() {
|
||||
session().changes().entryUpdated(this, Data::EntryUpdate::Flag::Repaint);
|
||||
}
|
||||
|
||||
} // namespace Dialogs
|
||||
|
Reference in New Issue
Block a user