mirror of
https://github.com/kotatogram/kotatogram-desktop
synced 2025-08-31 06:35:14 +00:00
Support default General topic in forums.
This commit is contained in:
@@ -404,12 +404,13 @@ void InnerWidget::changeOpenedFolder(Data::Folder *folder) {
|
||||
}
|
||||
|
||||
void InnerWidget::changeOpenedForum(ChannelData *forum) {
|
||||
if (_openedForum == forum) {
|
||||
const auto now = _openedForum ? _openedForum->channel().get() : nullptr;
|
||||
if (now == forum) {
|
||||
return;
|
||||
}
|
||||
stopReorderPinned();
|
||||
clearSelection();
|
||||
_openedForum = forum;
|
||||
_openedForum = forum ? forum->forum() : nullptr;
|
||||
|
||||
_openedForumLifetime.destroy();
|
||||
if (forum) {
|
||||
@@ -1791,7 +1792,7 @@ not_null<IndexedList*> InnerWidget::shownDialogs() const {
|
||||
return _filterId
|
||||
? session().data().chatsFilters().chatsList(_filterId)->indexed()
|
||||
: _openedForum
|
||||
? _openedForum->forum()->topicsList()->indexed()
|
||||
? _openedForum->topicsList()->indexed()
|
||||
: session().data().chatsList(_openedFolder)->indexed();
|
||||
}
|
||||
|
||||
@@ -2296,7 +2297,7 @@ Data::Folder *InnerWidget::shownFolder() const {
|
||||
return _openedFolder;
|
||||
}
|
||||
|
||||
ChannelData *InnerWidget::shownForum() const {
|
||||
Data::Forum *InnerWidget::shownForum() const {
|
||||
return _openedForum;
|
||||
}
|
||||
|
||||
@@ -2410,7 +2411,7 @@ void InnerWidget::refreshEmptyLabel() {
|
||||
} else if (_emptyState == EmptyState::EmptyFolder) {
|
||||
editOpenedFilter();
|
||||
} else if (_emptyState == EmptyState::EmptyForum) {
|
||||
Data::ShowAddForumTopic(_controller, _openedForum);
|
||||
Data::ShowAddForumTopic(_controller, _openedForum->channel());
|
||||
}
|
||||
});
|
||||
_empty->setVisible(_state == WidgetState::Default);
|
||||
@@ -3286,7 +3287,9 @@ void InnerWidget::setupShortcuts() {
|
||||
});
|
||||
request->check(Command::ChatSelf) && request->handle([=] {
|
||||
if (_openedForum) {
|
||||
Data::ShowAddForumTopic(_controller, _openedForum);
|
||||
Data::ShowAddForumTopic(
|
||||
_controller,
|
||||
_openedForum->channel());
|
||||
} else {
|
||||
_controller->content()->choosePeer(
|
||||
session().userPeerId(),
|
||||
|
@@ -36,6 +36,8 @@ class SessionController;
|
||||
|
||||
namespace Data {
|
||||
class CloudImageView;
|
||||
class Folder;
|
||||
class Forum;
|
||||
} // namespace Data
|
||||
|
||||
namespace Dialogs::Ui {
|
||||
@@ -110,7 +112,7 @@ public:
|
||||
void scrollToEntry(const RowDescriptor &entry);
|
||||
|
||||
Data::Folder *shownFolder() const;
|
||||
ChannelData *shownForum() const;
|
||||
Data::Forum *shownForum() const;
|
||||
int32 lastSearchDate() const;
|
||||
PeerData *lastSearchPeer() const;
|
||||
MsgId lastSearchId() const;
|
||||
@@ -351,7 +353,7 @@ private:
|
||||
Qt::MouseButton _pressButton = Qt::LeftButton;
|
||||
|
||||
Data::Folder *_openedFolder = nullptr;
|
||||
ChannelData *_openedForum = nullptr;
|
||||
Data::Forum *_openedForum = nullptr;
|
||||
rpl::lifetime _openedForumLifetime;
|
||||
|
||||
std::vector<std::unique_ptr<CollapsedRow>> _collapsedRows;
|
||||
|
@@ -260,50 +260,7 @@ Widget::Widget(
|
||||
}, lifetime());
|
||||
_inner->chosenRow(
|
||||
) | rpl::start_with_next([=](const ChosenRow &row) {
|
||||
const auto openSearchResult = !controller->selectingPeer()
|
||||
&& row.filteredRow;
|
||||
const auto history = row.key.history();
|
||||
if (const auto topic = row.key.topic()) {
|
||||
controller->showRepliesForMessage(
|
||||
topic->forum(),
|
||||
topic->rootId());
|
||||
} else if (history && history->peer->isForum()) {
|
||||
controller->openForum(history->peer->asChannel());
|
||||
} else if (history) {
|
||||
const auto peer = history->peer;
|
||||
const auto showAtMsgId = controller->uniqueChatsInSearchResults()
|
||||
? ShowAtUnreadMsgId
|
||||
: row.message.fullId.msg;
|
||||
if (row.newWindow && controller->canShowSeparateWindow(peer)) {
|
||||
const auto active = controller->activeChatCurrent();
|
||||
const auto fromActive = active.history()
|
||||
? (active.history()->peer == peer)
|
||||
: false;
|
||||
const auto toSeparate = [=] {
|
||||
Core::App().ensureSeparateWindowForPeer(
|
||||
peer,
|
||||
showAtMsgId);
|
||||
};
|
||||
if (fromActive) {
|
||||
controller->window().preventOrInvoke([=] {
|
||||
controller->content()->ui_showPeerHistory(
|
||||
0,
|
||||
Window::SectionShow::Way::ClearStack,
|
||||
0);
|
||||
toSeparate();
|
||||
});
|
||||
} else {
|
||||
toSeparate();
|
||||
}
|
||||
} else {
|
||||
controller->content()->choosePeer(peer->id, showAtMsgId);
|
||||
}
|
||||
} else if (const auto folder = row.key.folder()) {
|
||||
controller->openFolder(folder);
|
||||
}
|
||||
if (openSearchResult && !session().supportMode()) {
|
||||
escape();
|
||||
}
|
||||
chosenRow(row);
|
||||
}, lifetime());
|
||||
|
||||
_scroll->geometryChanged(
|
||||
@@ -422,6 +379,53 @@ Widget::Widget(
|
||||
setupDownloadBar();
|
||||
}
|
||||
|
||||
void Widget::chosenRow(const ChosenRow &row) {
|
||||
const auto openSearchResult = !controller()->selectingPeer()
|
||||
&& row.filteredRow;
|
||||
const auto history = row.key.history();
|
||||
if (const auto topic = row.key.topic()) {
|
||||
controller()->showRepliesForMessage(
|
||||
topic->forum(),
|
||||
topic->rootId());
|
||||
} else if (history && history->peer->isForum()) {
|
||||
controller()->openForum(history->peer->asChannel());
|
||||
} else if (history) {
|
||||
const auto peer = history->peer;
|
||||
const auto showAtMsgId = controller()->uniqueChatsInSearchResults()
|
||||
? ShowAtUnreadMsgId
|
||||
: row.message.fullId.msg;
|
||||
if (row.newWindow && controller()->canShowSeparateWindow(peer)) {
|
||||
const auto active = controller()->activeChatCurrent();
|
||||
const auto fromActive = active.history()
|
||||
? (active.history()->peer == peer)
|
||||
: false;
|
||||
const auto toSeparate = [=] {
|
||||
Core::App().ensureSeparateWindowForPeer(
|
||||
peer,
|
||||
showAtMsgId);
|
||||
};
|
||||
if (fromActive) {
|
||||
controller()->window().preventOrInvoke([=] {
|
||||
controller()->content()->ui_showPeerHistory(
|
||||
0,
|
||||
Window::SectionShow::Way::ClearStack,
|
||||
0);
|
||||
toSeparate();
|
||||
});
|
||||
} else {
|
||||
toSeparate();
|
||||
}
|
||||
} else {
|
||||
controller()->content()->choosePeer(peer->id, showAtMsgId);
|
||||
}
|
||||
} else if (const auto folder = row.key.folder()) {
|
||||
controller()->openFolder(folder);
|
||||
}
|
||||
if (openSearchResult && !session().supportMode()) {
|
||||
escape();
|
||||
}
|
||||
}
|
||||
|
||||
void Widget::setGeometryWithTopMoved(
|
||||
const QRect &newGeometry,
|
||||
int topDelta) {
|
||||
|
@@ -116,6 +116,7 @@ private:
|
||||
Internal,
|
||||
};
|
||||
|
||||
void chosenRow(const ChosenRow &row);
|
||||
void listScrollUpdated();
|
||||
void cancelSearchInChat();
|
||||
void filterCursorMoved(int from = -1, int to = -1);
|
||||
|
Reference in New Issue
Block a user