mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-04-16 14:17:12 +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();
|
||||
}
|
||||
|
||||
|
||||
void Session::dialogsRowReplaced(DialogsRowReplacement 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_session.h"
|
||||
#include "data/data_channel.h"
|
||||
#include "data/data_forum_topic.h"
|
||||
#include "data/data_chat.h"
|
||||
#include "data/data_user.h"
|
||||
#include "data/data_peer_values.h"
|
||||
|
@ -201,7 +202,7 @@ InnerWidget::InnerWidget(
|
|||
session().data().chatsListChanges(),
|
||||
session().data().chatsListLoadedEvents()
|
||||
) | rpl::filter([=](Data::Folder *folder) {
|
||||
return (folder == _openedFolder);
|
||||
return !_openedForum && (folder == _openedFolder);
|
||||
}) | rpl::start_with_next([=] {
|
||||
refresh();
|
||||
}, lifetime());
|
||||
|
@ -419,6 +420,10 @@ void InnerWidget::changeOpenedForum(ChannelData *forum) {
|
|||
}
|
||||
stopReorderPinned();
|
||||
clearSelection();
|
||||
|
||||
_filterId = forum
|
||||
? 0
|
||||
: _controller->activeChatsFilterCurrent();
|
||||
_openedForum = forum ? forum->forum() : nullptr;
|
||||
_st = forum ? &st::forumTopicRow : &st::defaultDialogRow;
|
||||
|
||||
|
@ -1211,7 +1216,7 @@ void InnerWidget::checkReorderPinnedStart(QPoint localPosition) {
|
|||
< style::ConvertScale(kStartReorderThreshold)) {
|
||||
return;
|
||||
} else if (_openedForum) {
|
||||
return; // #TODO forum pinned
|
||||
return;
|
||||
}
|
||||
_dragging = _pressed;
|
||||
if (updateReorderIndexGetCount() < 2) {
|
||||
|
@ -1249,6 +1254,9 @@ int InnerWidget::countPinnedIndex(Row *ofRow) {
|
|||
}
|
||||
|
||||
void InnerWidget::savePinnedOrder() {
|
||||
if (_openedForum) {
|
||||
return;
|
||||
}
|
||||
const auto &newOrder = session().data().pinnedChatsOrder(
|
||||
_openedFolder,
|
||||
_filterId);
|
||||
|
@ -1568,7 +1576,13 @@ void InnerWidget::handleChatListEntryRefreshes() {
|
|||
using Event = Data::Session::ChatListEntryRefresh;
|
||||
session().data().chatListEntryRefreshes(
|
||||
) | 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) {
|
||||
const auto offset = dialogsOffset();
|
||||
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.
|
||||
if (!_dragging
|
||||
&& (from != to)
|
||||
&& (entry->folder() == _openedFolder)
|
||||
&& (_state == WidgetState::Default)) {
|
||||
&& (_state == WidgetState::Default)
|
||||
&& (key.topic()
|
||||
? (key.topic()->forum() == _openedForum)
|
||||
: (entry->folder() == _openedFolder))) {
|
||||
_dialogMoved.fire({ from, to });
|
||||
}
|
||||
|
||||
|
@ -1822,10 +1838,10 @@ void InnerWidget::updateSelectedRow(Key key) {
|
|||
}
|
||||
|
||||
not_null<IndexedList*> InnerWidget::shownDialogs() const {
|
||||
return _filterId
|
||||
? session().data().chatsFilters().chatsList(_filterId)->indexed()
|
||||
: _openedForum
|
||||
return _openedForum
|
||||
? _openedForum->topicsList()->indexed()
|
||||
: _filterId
|
||||
? session().data().chatsFilters().chatsList(_filterId)->indexed()
|
||||
: session().data().chatsList(_openedFolder)->indexed();
|
||||
}
|
||||
|
||||
|
|
|
@ -398,10 +398,11 @@ void Widget::chosenRow(const ChosenRow &row) {
|
|||
controller()->showRepliesForMessage(
|
||||
topic->history(),
|
||||
topic->rootId(),
|
||||
ShowAtUnreadMsgId,
|
||||
row.message.fullId.msg,
|
||||
Window::SectionShow::Way::ClearStack);
|
||||
} else if (history && history->peer->isForum()) {
|
||||
} else if (history && history->peer->isForum() && !row.message.fullId) {
|
||||
controller()->openForum(history->peer->asChannel());
|
||||
return;
|
||||
} else if (history) {
|
||||
const auto peer = history->peer;
|
||||
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) {
|
||||
changeOpenedSubsection([&] {
|
||||
if (forum) {
|
||||
cancelSearch();
|
||||
}
|
||||
_openedForum = forum;
|
||||
_inner->changeOpenedForum(forum);
|
||||
}, (forum != nullptr), animated);
|
||||
|
@ -705,9 +709,9 @@ void Widget::refreshFolderTopBar() {
|
|||
}
|
||||
_folderTopBar->setActiveChat(
|
||||
HistoryView::TopBarWidget::ActiveChat{
|
||||
.key = (_openedFolder
|
||||
? Dialogs::Key(_openedFolder)
|
||||
: Dialogs::Key(session().data().history(_openedForum))),
|
||||
.key = (_openedForum
|
||||
? Dialogs::Key(session().data().history(_openedForum))
|
||||
: Dialogs::Key(_openedFolder)),
|
||||
.section = Dialogs::EntryState::Section::ChatsList,
|
||||
},
|
||||
nullptr);
|
||||
|
@ -1852,10 +1856,10 @@ RowDescriptor Widget::resolveChatPrevious(RowDescriptor from) const {
|
|||
|
||||
void Widget::keyPressEvent(QKeyEvent *e) {
|
||||
if (e->key() == Qt::Key_Escape) {
|
||||
if (_openedFolder) {
|
||||
controller()->closeFolder();
|
||||
} else if (_openedForum) {
|
||||
if (_openedForum) {
|
||||
controller()->closeForum();
|
||||
} else if (_openedFolder) {
|
||||
controller()->closeFolder();
|
||||
} else {
|
||||
e->ignore();
|
||||
}
|
||||
|
|
|
@ -895,8 +895,6 @@ void SessionController::openForum(
|
|||
if (_openedForum.current() != forum) {
|
||||
resetFakeUnreadWhileOpened();
|
||||
}
|
||||
setActiveChatsFilter(0, params);
|
||||
closeFolder();
|
||||
_openedForum = forum.get();
|
||||
if (_openedForum.current() == forum) {
|
||||
forum->forum()->destroyed(
|
||||
|
@ -1658,6 +1656,7 @@ void SessionController::setActiveChatsFilter(
|
|||
}
|
||||
_activeChatsFilter.force_assign(id);
|
||||
if (id) {
|
||||
closeForum();
|
||||
closeFolder();
|
||||
}
|
||||
if (adaptive().isOneColumn()) {
|
||||
|
|
Loading…
Add table
Reference in a new issue