mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +02:00
Allow opening forums from archive / filters.
This commit is contained in:
parent
7cdf20a7c5
commit
a292f8a34e
4 changed files with 37 additions and 19 deletions
|
@ -3944,7 +3944,6 @@ auto Session::chatListEntryRefreshes() const
|
||||||
return _chatListEntryRefreshes.events();
|
return _chatListEntryRefreshes.events();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Session::dialogsRowReplaced(DialogsRowReplacement replacement) {
|
void Session::dialogsRowReplaced(DialogsRowReplacement replacement) {
|
||||||
_dialogsRowReplacements.fire(std::move(replacement));
|
_dialogsRowReplacements.fire(std::move(replacement));
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,6 +27,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "data/data_forum.h"
|
#include "data/data_forum.h"
|
||||||
#include "data/data_session.h"
|
#include "data/data_session.h"
|
||||||
#include "data/data_channel.h"
|
#include "data/data_channel.h"
|
||||||
|
#include "data/data_forum_topic.h"
|
||||||
#include "data/data_chat.h"
|
#include "data/data_chat.h"
|
||||||
#include "data/data_user.h"
|
#include "data/data_user.h"
|
||||||
#include "data/data_peer_values.h"
|
#include "data/data_peer_values.h"
|
||||||
|
@ -201,7 +202,7 @@ InnerWidget::InnerWidget(
|
||||||
session().data().chatsListChanges(),
|
session().data().chatsListChanges(),
|
||||||
session().data().chatsListLoadedEvents()
|
session().data().chatsListLoadedEvents()
|
||||||
) | rpl::filter([=](Data::Folder *folder) {
|
) | rpl::filter([=](Data::Folder *folder) {
|
||||||
return (folder == _openedFolder);
|
return !_openedForum && (folder == _openedFolder);
|
||||||
}) | rpl::start_with_next([=] {
|
}) | rpl::start_with_next([=] {
|
||||||
refresh();
|
refresh();
|
||||||
}, lifetime());
|
}, lifetime());
|
||||||
|
@ -419,6 +420,10 @@ void InnerWidget::changeOpenedForum(ChannelData *forum) {
|
||||||
}
|
}
|
||||||
stopReorderPinned();
|
stopReorderPinned();
|
||||||
clearSelection();
|
clearSelection();
|
||||||
|
|
||||||
|
_filterId = forum
|
||||||
|
? 0
|
||||||
|
: _controller->activeChatsFilterCurrent();
|
||||||
_openedForum = forum ? forum->forum() : nullptr;
|
_openedForum = forum ? forum->forum() : nullptr;
|
||||||
_st = forum ? &st::forumTopicRow : &st::defaultDialogRow;
|
_st = forum ? &st::forumTopicRow : &st::defaultDialogRow;
|
||||||
|
|
||||||
|
@ -1211,7 +1216,7 @@ void InnerWidget::checkReorderPinnedStart(QPoint localPosition) {
|
||||||
< style::ConvertScale(kStartReorderThreshold)) {
|
< style::ConvertScale(kStartReorderThreshold)) {
|
||||||
return;
|
return;
|
||||||
} else if (_openedForum) {
|
} else if (_openedForum) {
|
||||||
return; // #TODO forum pinned
|
return;
|
||||||
}
|
}
|
||||||
_dragging = _pressed;
|
_dragging = _pressed;
|
||||||
if (updateReorderIndexGetCount() < 2) {
|
if (updateReorderIndexGetCount() < 2) {
|
||||||
|
@ -1249,6 +1254,9 @@ int InnerWidget::countPinnedIndex(Row *ofRow) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void InnerWidget::savePinnedOrder() {
|
void InnerWidget::savePinnedOrder() {
|
||||||
|
if (_openedForum) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
const auto &newOrder = session().data().pinnedChatsOrder(
|
const auto &newOrder = session().data().pinnedChatsOrder(
|
||||||
_openedFolder,
|
_openedFolder,
|
||||||
_filterId);
|
_filterId);
|
||||||
|
@ -1568,7 +1576,13 @@ void InnerWidget::handleChatListEntryRefreshes() {
|
||||||
using Event = Data::Session::ChatListEntryRefresh;
|
using Event = Data::Session::ChatListEntryRefresh;
|
||||||
session().data().chatListEntryRefreshes(
|
session().data().chatListEntryRefreshes(
|
||||||
) | rpl::filter([=](const Event &event) {
|
) | rpl::filter([=](const Event &event) {
|
||||||
return (event.filterId == _filterId);
|
if (event.filterId != _filterId) {
|
||||||
|
return false;
|
||||||
|
} else if (const auto topic = event.key.topic()) {
|
||||||
|
return (topic->forum() == _openedForum);
|
||||||
|
} else {
|
||||||
|
return !_openedForum;
|
||||||
|
}
|
||||||
}) | rpl::start_with_next([=](const Event &event) {
|
}) | rpl::start_with_next([=](const Event &event) {
|
||||||
const auto offset = dialogsOffset();
|
const auto offset = dialogsOffset();
|
||||||
const auto from = offset + event.moved.from * _st->height;
|
const auto from = offset + event.moved.from * _st->height;
|
||||||
|
@ -1579,8 +1593,10 @@ void InnerWidget::handleChatListEntryRefreshes() {
|
||||||
// Don't jump in chats list scroll position while dragging.
|
// Don't jump in chats list scroll position while dragging.
|
||||||
if (!_dragging
|
if (!_dragging
|
||||||
&& (from != to)
|
&& (from != to)
|
||||||
&& (entry->folder() == _openedFolder)
|
&& (_state == WidgetState::Default)
|
||||||
&& (_state == WidgetState::Default)) {
|
&& (key.topic()
|
||||||
|
? (key.topic()->forum() == _openedForum)
|
||||||
|
: (entry->folder() == _openedFolder))) {
|
||||||
_dialogMoved.fire({ from, to });
|
_dialogMoved.fire({ from, to });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1822,10 +1838,10 @@ void InnerWidget::updateSelectedRow(Key key) {
|
||||||
}
|
}
|
||||||
|
|
||||||
not_null<IndexedList*> InnerWidget::shownDialogs() const {
|
not_null<IndexedList*> InnerWidget::shownDialogs() const {
|
||||||
return _filterId
|
return _openedForum
|
||||||
? session().data().chatsFilters().chatsList(_filterId)->indexed()
|
|
||||||
: _openedForum
|
|
||||||
? _openedForum->topicsList()->indexed()
|
? _openedForum->topicsList()->indexed()
|
||||||
|
: _filterId
|
||||||
|
? session().data().chatsFilters().chatsList(_filterId)->indexed()
|
||||||
: session().data().chatsList(_openedFolder)->indexed();
|
: session().data().chatsList(_openedFolder)->indexed();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -398,10 +398,11 @@ void Widget::chosenRow(const ChosenRow &row) {
|
||||||
controller()->showRepliesForMessage(
|
controller()->showRepliesForMessage(
|
||||||
topic->history(),
|
topic->history(),
|
||||||
topic->rootId(),
|
topic->rootId(),
|
||||||
ShowAtUnreadMsgId,
|
row.message.fullId.msg,
|
||||||
Window::SectionShow::Way::ClearStack);
|
Window::SectionShow::Way::ClearStack);
|
||||||
} else if (history && history->peer->isForum()) {
|
} else if (history && history->peer->isForum() && !row.message.fullId) {
|
||||||
controller()->openForum(history->peer->asChannel());
|
controller()->openForum(history->peer->asChannel());
|
||||||
|
return;
|
||||||
} else if (history) {
|
} else if (history) {
|
||||||
const auto peer = history->peer;
|
const auto peer = history->peer;
|
||||||
const auto showAtMsgId = controller()->uniqueChatsInSearchResults()
|
const auto showAtMsgId = controller()->uniqueChatsInSearchResults()
|
||||||
|
@ -692,6 +693,9 @@ void Widget::changeOpenedFolder(Data::Folder *folder, anim::type animated) {
|
||||||
|
|
||||||
void Widget::changeOpenedForum(ChannelData *forum, anim::type animated) {
|
void Widget::changeOpenedForum(ChannelData *forum, anim::type animated) {
|
||||||
changeOpenedSubsection([&] {
|
changeOpenedSubsection([&] {
|
||||||
|
if (forum) {
|
||||||
|
cancelSearch();
|
||||||
|
}
|
||||||
_openedForum = forum;
|
_openedForum = forum;
|
||||||
_inner->changeOpenedForum(forum);
|
_inner->changeOpenedForum(forum);
|
||||||
}, (forum != nullptr), animated);
|
}, (forum != nullptr), animated);
|
||||||
|
@ -705,9 +709,9 @@ void Widget::refreshFolderTopBar() {
|
||||||
}
|
}
|
||||||
_folderTopBar->setActiveChat(
|
_folderTopBar->setActiveChat(
|
||||||
HistoryView::TopBarWidget::ActiveChat{
|
HistoryView::TopBarWidget::ActiveChat{
|
||||||
.key = (_openedFolder
|
.key = (_openedForum
|
||||||
? Dialogs::Key(_openedFolder)
|
? Dialogs::Key(session().data().history(_openedForum))
|
||||||
: Dialogs::Key(session().data().history(_openedForum))),
|
: Dialogs::Key(_openedFolder)),
|
||||||
.section = Dialogs::EntryState::Section::ChatsList,
|
.section = Dialogs::EntryState::Section::ChatsList,
|
||||||
},
|
},
|
||||||
nullptr);
|
nullptr);
|
||||||
|
@ -1852,10 +1856,10 @@ RowDescriptor Widget::resolveChatPrevious(RowDescriptor from) const {
|
||||||
|
|
||||||
void Widget::keyPressEvent(QKeyEvent *e) {
|
void Widget::keyPressEvent(QKeyEvent *e) {
|
||||||
if (e->key() == Qt::Key_Escape) {
|
if (e->key() == Qt::Key_Escape) {
|
||||||
if (_openedFolder) {
|
if (_openedForum) {
|
||||||
controller()->closeFolder();
|
|
||||||
} else if (_openedForum) {
|
|
||||||
controller()->closeForum();
|
controller()->closeForum();
|
||||||
|
} else if (_openedFolder) {
|
||||||
|
controller()->closeFolder();
|
||||||
} else {
|
} else {
|
||||||
e->ignore();
|
e->ignore();
|
||||||
}
|
}
|
||||||
|
|
|
@ -895,8 +895,6 @@ void SessionController::openForum(
|
||||||
if (_openedForum.current() != forum) {
|
if (_openedForum.current() != forum) {
|
||||||
resetFakeUnreadWhileOpened();
|
resetFakeUnreadWhileOpened();
|
||||||
}
|
}
|
||||||
setActiveChatsFilter(0, params);
|
|
||||||
closeFolder();
|
|
||||||
_openedForum = forum.get();
|
_openedForum = forum.get();
|
||||||
if (_openedForum.current() == forum) {
|
if (_openedForum.current() == forum) {
|
||||||
forum->forum()->destroyed(
|
forum->forum()->destroyed(
|
||||||
|
@ -1658,6 +1656,7 @@ void SessionController::setActiveChatsFilter(
|
||||||
}
|
}
|
||||||
_activeChatsFilter.force_assign(id);
|
_activeChatsFilter.force_assign(id);
|
||||||
if (id) {
|
if (id) {
|
||||||
|
closeForum();
|
||||||
closeFolder();
|
closeFolder();
|
||||||
}
|
}
|
||||||
if (adaptive().isOneColumn()) {
|
if (adaptive().isOneColumn()) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue