mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +02:00
Show first (may be non-"All Chats") folder by default.
This commit is contained in:
parent
fe91887ea2
commit
3b5ec78f4f
6 changed files with 53 additions and 8 deletions
|
@ -534,6 +534,28 @@ const std::vector<ChatFilter> &ChatFilters::list() const {
|
||||||
return _list;
|
return _list;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
FilterId ChatFilters::defaultId() const {
|
||||||
|
return lookupId(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
FilterId ChatFilters::lookupId(int index) const {
|
||||||
|
Expects(index >= 0 && index < _list.size());
|
||||||
|
|
||||||
|
if (_owner->session().user()->isPremium() || !_list.front().id()) {
|
||||||
|
return _list[index].id();
|
||||||
|
}
|
||||||
|
const auto i = ranges::find(_list, FilterId(0), &ChatFilter::id);
|
||||||
|
return !index
|
||||||
|
? FilterId()
|
||||||
|
: (index <= int(i - begin(_list)))
|
||||||
|
? _list[index - 1].id()
|
||||||
|
: _list[index].id();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool ChatFilters::loaded() const {
|
||||||
|
return _loaded;
|
||||||
|
}
|
||||||
|
|
||||||
bool ChatFilters::has() const {
|
bool ChatFilters::has() const {
|
||||||
return _list.size() > 1;
|
return _list.size() > 1;
|
||||||
}
|
}
|
||||||
|
|
|
@ -102,8 +102,12 @@ public:
|
||||||
void moveAllToFront();
|
void moveAllToFront();
|
||||||
[[nodiscard]] const std::vector<ChatFilter> &list() const;
|
[[nodiscard]] const std::vector<ChatFilter> &list() const;
|
||||||
[[nodiscard]] rpl::producer<> changed() const;
|
[[nodiscard]] rpl::producer<> changed() const;
|
||||||
|
[[nodiscard]] bool loaded() const;
|
||||||
[[nodiscard]] bool has() const;
|
[[nodiscard]] bool has() const;
|
||||||
|
|
||||||
|
[[nodiscard]] FilterId defaultId() const;
|
||||||
|
[[nodiscard]] FilterId lookupId(int index) const;
|
||||||
|
|
||||||
bool loadNextExceptions(bool chatsListLoaded);
|
bool loadNextExceptions(bool chatsListLoaded);
|
||||||
|
|
||||||
void refreshHistory(not_null<History*> history);
|
void refreshHistory(not_null<History*> history);
|
||||||
|
|
|
@ -3205,20 +3205,19 @@ void InnerWidget::setupShortcuts() {
|
||||||
});
|
});
|
||||||
|
|
||||||
if (session().data().chatsFilters().has()) {
|
if (session().data().chatsFilters().has()) {
|
||||||
const auto filters = &session().data().chatsFilters().list();
|
const auto filters = &session().data().chatsFilters();
|
||||||
const auto filtersCount = int(filters->size());
|
const auto filtersCount = int(filters->list().size());
|
||||||
auto &&folders = ranges::views::zip(
|
auto &&folders = ranges::views::zip(
|
||||||
Shortcuts::kShowFolder,
|
Shortcuts::kShowFolder,
|
||||||
ranges::views::ints(0, ranges::unreachable));
|
ranges::views::ints(0, ranges::unreachable));
|
||||||
for (const auto [command, index] : folders) {
|
for (const auto [command, index] : folders) {
|
||||||
const auto select = (command == Command::ShowFolderLast)
|
const auto select = (command == Command::ShowFolderLast)
|
||||||
? filtersCount
|
? (filtersCount - 1)
|
||||||
: std::clamp(index, 0, int(filtersCount));
|
: std::clamp(index, 0, filtersCount - 1);
|
||||||
request->check(command) && request->handle([=] {
|
request->check(command) && request->handle([=] {
|
||||||
if (select <= filtersCount) {
|
if (select <= filtersCount) {
|
||||||
_controller->setActiveChatsFilter((select > 0)
|
_controller->setActiveChatsFilter(
|
||||||
? (*filters)[select - 1].id()
|
filters->lookupId(select));
|
||||||
: 0);
|
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
});
|
});
|
||||||
|
|
|
@ -121,8 +121,12 @@ void FiltersMenu::setup() {
|
||||||
_activeFilterId = _session->activeChatsFilterCurrent();
|
_activeFilterId = _session->activeChatsFilterCurrent();
|
||||||
_session->activeChatsFilter(
|
_session->activeChatsFilter(
|
||||||
) | rpl::filter([=](FilterId id) {
|
) | rpl::filter([=](FilterId id) {
|
||||||
return id != _activeFilterId;
|
return (id != _activeFilterId);
|
||||||
}) | rpl::start_with_next([=](FilterId id) {
|
}) | rpl::start_with_next([=](FilterId id) {
|
||||||
|
if (!_list) {
|
||||||
|
_activeFilterId = id;
|
||||||
|
return;
|
||||||
|
}
|
||||||
const auto i = _filters.find(_activeFilterId);
|
const auto i = _filters.find(_activeFilterId);
|
||||||
if (i != end(_filters)) {
|
if (i != end(_filters)) {
|
||||||
i->second->setActive(false);
|
i->second->setActive(false);
|
||||||
|
|
|
@ -600,6 +600,7 @@ SessionController::SessionController(
|
||||||
_window->widget(),
|
_window->widget(),
|
||||||
this))
|
this))
|
||||||
, _invitePeekTimer([=] { checkInvitePeek(); })
|
, _invitePeekTimer([=] { checkInvitePeek(); })
|
||||||
|
, _activeChatsFilter(session->data().chatsFilters().defaultId())
|
||||||
, _defaultChatTheme(std::make_shared<Ui::ChatTheme>())
|
, _defaultChatTheme(std::make_shared<Ui::ChatTheme>())
|
||||||
, _chatStyle(std::make_unique<Ui::ChatStyle>())
|
, _chatStyle(std::make_unique<Ui::ChatStyle>())
|
||||||
, _cachedReactionIconFactory(std::make_unique<ReactionIconFactory>()) {
|
, _cachedReactionIconFactory(std::make_unique<ReactionIconFactory>()) {
|
||||||
|
@ -657,6 +658,10 @@ SessionController::SessionController(
|
||||||
}, _lifetime);
|
}, _lifetime);
|
||||||
|
|
||||||
session->addWindow(this);
|
session->addWindow(this);
|
||||||
|
|
||||||
|
crl::on_main(this, [=] {
|
||||||
|
activateFirstChatsFilter();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void SessionController::suggestArchiveAndMute() {
|
void SessionController::suggestArchiveAndMute() {
|
||||||
|
@ -772,6 +777,7 @@ rpl::producer<> SessionController::filtersMenuChanged() const {
|
||||||
}
|
}
|
||||||
|
|
||||||
void SessionController::checkOpenedFilter() {
|
void SessionController::checkOpenedFilter() {
|
||||||
|
activateFirstChatsFilter();
|
||||||
if (const auto filterId = activeChatsFilterCurrent()) {
|
if (const auto filterId = activeChatsFilterCurrent()) {
|
||||||
const auto &list = session().data().chatsFilters().list();
|
const auto &list = session().data().chatsFilters().list();
|
||||||
const auto i = ranges::find(list, filterId, &Data::ChatFilter::id);
|
const auto i = ranges::find(list, filterId, &Data::ChatFilter::id);
|
||||||
|
@ -781,6 +787,14 @@ void SessionController::checkOpenedFilter() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SessionController::activateFirstChatsFilter() {
|
||||||
|
if (_filtersActivated || !session().data().chatsFilters().loaded()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
_filtersActivated = true;
|
||||||
|
setActiveChatsFilter(session().data().chatsFilters().defaultId());
|
||||||
|
}
|
||||||
|
|
||||||
bool SessionController::uniqueChatsInSearchResults() const {
|
bool SessionController::uniqueChatsInSearchResults() const {
|
||||||
return session().supportMode()
|
return session().supportMode()
|
||||||
&& !session().settings().supportAllSearchResults()
|
&& !session().settings().supportAllSearchResults()
|
||||||
|
|
|
@ -513,6 +513,7 @@ private:
|
||||||
void refreshFiltersMenu();
|
void refreshFiltersMenu();
|
||||||
void checkOpenedFilter();
|
void checkOpenedFilter();
|
||||||
void suggestArchiveAndMute();
|
void suggestArchiveAndMute();
|
||||||
|
void activateFirstChatsFilter();
|
||||||
|
|
||||||
int minimalThreeColumnWidth() const;
|
int minimalThreeColumnWidth() const;
|
||||||
int countDialogsWidthFromRatio(int bodyWidth) const;
|
int countDialogsWidthFromRatio(int bodyWidth) const;
|
||||||
|
@ -562,6 +563,7 @@ private:
|
||||||
base::Variable<bool> _dialogsListDisplayForced = { false };
|
base::Variable<bool> _dialogsListDisplayForced = { false };
|
||||||
std::deque<Dialogs::RowDescriptor> _chatEntryHistory;
|
std::deque<Dialogs::RowDescriptor> _chatEntryHistory;
|
||||||
int _chatEntryHistoryPosition = -1;
|
int _chatEntryHistoryPosition = -1;
|
||||||
|
bool _filtersActivated = false;
|
||||||
bool _selectingPeer = false;
|
bool _selectingPeer = false;
|
||||||
|
|
||||||
base::Timer _invitePeekTimer;
|
base::Timer _invitePeekTimer;
|
||||||
|
|
Loading…
Add table
Reference in a new issue