mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +02:00
Fix crash in topics disabling.
This commit is contained in:
parent
37454b4ff4
commit
7caabb8f5a
8 changed files with 56 additions and 12 deletions
|
@ -84,6 +84,10 @@ object_ptr<Window::SectionWidget> PinnedMemento::createWidget(
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Data::ForumTopic *PinnedMemento::topicForRemoveRequests() const {
|
||||||
|
return _thread->asTopic();
|
||||||
|
}
|
||||||
|
|
||||||
PinnedWidget::PinnedWidget(
|
PinnedWidget::PinnedWidget(
|
||||||
QWidget *parent,
|
QWidget *parent,
|
||||||
not_null<Window::SessionController*> controller,
|
not_null<Window::SessionController*> controller,
|
||||||
|
|
|
@ -210,6 +210,8 @@ public:
|
||||||
return _highlightId;
|
return _highlightId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Data::ForumTopic *topicForRemoveRequests() const override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
const not_null<Data::Thread*> _thread;
|
const not_null<Data::Thread*> _thread;
|
||||||
const UniversalMsgId _highlightId = 0;
|
const UniversalMsgId _highlightId = 0;
|
||||||
|
|
|
@ -153,6 +153,11 @@ void RepliesMemento::setFromTopic(not_null<Data::ForumTopic*> topic) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Data::ForumTopic *RepliesMemento::topicForRemoveRequests() const {
|
||||||
|
return _history->peer->forumTopicFor(_rootId);
|
||||||
|
}
|
||||||
|
|
||||||
void RepliesMemento::setReadInformation(
|
void RepliesMemento::setReadInformation(
|
||||||
MsgId inboxReadTillId,
|
MsgId inboxReadTillId,
|
||||||
int unreadCount,
|
int unreadCount,
|
||||||
|
|
|
@ -408,6 +408,8 @@ public:
|
||||||
return _replyReturns;
|
return _replyReturns;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Data::ForumTopic *topicForRemoveRequests() const override;
|
||||||
|
|
||||||
[[nodiscard]] not_null<ListMemento*> list() {
|
[[nodiscard]] not_null<ListMemento*> list() {
|
||||||
return &_list;
|
return &_list;
|
||||||
}
|
}
|
||||||
|
|
|
@ -112,8 +112,6 @@ public:
|
||||||
|
|
||||||
rpl::producer<int> desiredHeightValue() const override;
|
rpl::producer<int> desiredHeightValue() const override;
|
||||||
|
|
||||||
void updateInternalState(not_null<Memento*> memento);
|
|
||||||
|
|
||||||
// Float player interface.
|
// Float player interface.
|
||||||
bool floatPlayerHandleWheelEvent(QEvent *e) override;
|
bool floatPlayerHandleWheelEvent(QEvent *e) override;
|
||||||
QRect floatPlayerAvailableRect() override;
|
QRect floatPlayerAvailableRect() override;
|
||||||
|
|
|
@ -13,6 +13,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "data/data_document.h"
|
#include "data/data_document.h"
|
||||||
#include "data/data_document_media.h"
|
#include "data/data_document_media.h"
|
||||||
#include "data/data_document_resolver.h"
|
#include "data/data_document_resolver.h"
|
||||||
|
#include "data/data_forum_topic.h"
|
||||||
#include "data/data_wall_paper.h"
|
#include "data/data_wall_paper.h"
|
||||||
#include "data/data_web_page.h"
|
#include "data/data_web_page.h"
|
||||||
#include "data/data_game.h"
|
#include "data/data_game.h"
|
||||||
|
@ -150,13 +151,20 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
[[nodiscard]] virtual StackItemType type() const = 0;
|
[[nodiscard]] virtual StackItemType type() const = 0;
|
||||||
[[nodiscard]] virtual rpl::producer<> removeRequests() const = 0;
|
[[nodiscard]] rpl::producer<> removeRequests() const {
|
||||||
|
return rpl::merge(
|
||||||
|
_thirdSectionRemoveRequests.events(),
|
||||||
|
sectionRemoveRequests());
|
||||||
|
}
|
||||||
virtual ~StackItem() = default;
|
virtual ~StackItem() = default;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
[[nodiscard]] virtual rpl::producer<> sectionRemoveRequests() const = 0;
|
||||||
|
|
||||||
PeerData *_peer = nullptr;
|
PeerData *_peer = nullptr;
|
||||||
QPointer<Window::SectionWidget> _thirdSectionWeak;
|
QPointer<Window::SectionWidget> _thirdSectionWeak;
|
||||||
std::shared_ptr<Window::SectionMemento> _thirdSectionMemento;
|
std::shared_ptr<Window::SectionMemento> _thirdSectionMemento;
|
||||||
|
rpl::event_stream<> _thirdSectionRemoveRequests;
|
||||||
|
|
||||||
rpl::lifetime _lifetime;
|
rpl::lifetime _lifetime;
|
||||||
|
|
||||||
|
@ -177,14 +185,16 @@ public:
|
||||||
StackItemType type() const override {
|
StackItemType type() const override {
|
||||||
return HistoryStackItem;
|
return HistoryStackItem;
|
||||||
}
|
}
|
||||||
rpl::producer<> removeRequests() const override {
|
|
||||||
return rpl::never<>();
|
|
||||||
}
|
|
||||||
|
|
||||||
not_null<History*> history;
|
not_null<History*> history;
|
||||||
MsgId msgId;
|
MsgId msgId;
|
||||||
QVector<FullMsgId> replyReturns;
|
QVector<FullMsgId> replyReturns;
|
||||||
|
|
||||||
|
private:
|
||||||
|
rpl::producer<> sectionRemoveRequests() const override {
|
||||||
|
return rpl::never<>();
|
||||||
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class StackItemSection : public StackItem {
|
class StackItemSection : public StackItem {
|
||||||
|
@ -195,14 +205,13 @@ public:
|
||||||
StackItemType type() const override {
|
StackItemType type() const override {
|
||||||
return SectionStackItem;
|
return SectionStackItem;
|
||||||
}
|
}
|
||||||
rpl::producer<> removeRequests() const override {
|
|
||||||
return _memento->removeRequests();
|
|
||||||
}
|
|
||||||
std::shared_ptr<Window::SectionMemento> takeMemento() {
|
std::shared_ptr<Window::SectionMemento> takeMemento() {
|
||||||
return std::move(_memento);
|
return std::move(_memento);
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
rpl::producer<> sectionRemoveRequests() const override;
|
||||||
|
|
||||||
std::shared_ptr<Window::SectionMemento> _memento;
|
std::shared_ptr<Window::SectionMemento> _memento;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
@ -210,6 +219,10 @@ private:
|
||||||
void StackItem::setThirdSectionMemento(
|
void StackItem::setThirdSectionMemento(
|
||||||
std::shared_ptr<Window::SectionMemento> memento) {
|
std::shared_ptr<Window::SectionMemento> memento) {
|
||||||
_thirdSectionMemento = std::move(memento);
|
_thirdSectionMemento = std::move(memento);
|
||||||
|
if (const auto memento = _thirdSectionMemento.get()) {
|
||||||
|
memento->removeRequests(
|
||||||
|
) | rpl::start_to_stream(_thirdSectionRemoveRequests, _lifetime);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
StackItemSection::StackItemSection(
|
StackItemSection::StackItemSection(
|
||||||
|
@ -218,6 +231,13 @@ StackItemSection::StackItemSection(
|
||||||
, _memento(std::move(memento)) {
|
, _memento(std::move(memento)) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
rpl::producer<> StackItemSection::sectionRemoveRequests() const {
|
||||||
|
if (const auto topic = _memento->topicForRemoveRequests()) {
|
||||||
|
return rpl::merge(_memento->removeRequests(), topic->destroyed());
|
||||||
|
}
|
||||||
|
return _memento->removeRequests();
|
||||||
|
}
|
||||||
|
|
||||||
struct MainWidget::SettingBackground {
|
struct MainWidget::SettingBackground {
|
||||||
explicit SettingBackground(const Data::WallPaper &data);
|
explicit SettingBackground(const Data::WallPaper &data);
|
||||||
|
|
||||||
|
|
|
@ -11,6 +11,10 @@ namespace Ui {
|
||||||
class LayerWidget;
|
class LayerWidget;
|
||||||
} // namespace Ui
|
} // namespace Ui
|
||||||
|
|
||||||
|
namespace Data {
|
||||||
|
class ForumTopic;
|
||||||
|
} // namespace Data
|
||||||
|
|
||||||
namespace Window {
|
namespace Window {
|
||||||
|
|
||||||
class SessionController;
|
class SessionController;
|
||||||
|
@ -34,6 +38,9 @@ public:
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[[nodiscard]] virtual Data::ForumTopic *topicForRemoveRequests() const {
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
[[nodiscard]] virtual rpl::producer<> removeRequests() const {
|
[[nodiscard]] virtual rpl::producer<> removeRequests() const {
|
||||||
return rpl::never<>();
|
return rpl::never<>();
|
||||||
}
|
}
|
||||||
|
|
|
@ -1001,10 +1001,16 @@ void SessionController::showForum(
|
||||||
}
|
}
|
||||||
forum->destroyed(
|
forum->destroyed(
|
||||||
) | rpl::start_with_next([=, history = forum->history()] {
|
) | rpl::start_with_next([=, history = forum->history()] {
|
||||||
|
const auto now = activeChatCurrent().owningHistory();
|
||||||
|
const auto showHistory = !now || (now == history);
|
||||||
closeForum();
|
closeForum();
|
||||||
showPeerHistory(
|
if (showHistory) {
|
||||||
history,
|
showPeerHistory(history, {
|
||||||
{ anim::type::normal, anim::activation::background });
|
SectionShow::Way::Backward,
|
||||||
|
anim::type::normal,
|
||||||
|
anim::activation::background,
|
||||||
|
});
|
||||||
|
}
|
||||||
}, _shownForumLifetime);
|
}, _shownForumLifetime);
|
||||||
content()->showForum(forum, params);
|
content()->showForum(forum, params);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue