mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-07-28 08:22:59 +02:00
Rename RepliesWidget/Memento to ChatWidget/Memento.
This commit is contained in:
parent
abcf7e3a47
commit
40053e3388
8 changed files with 453 additions and 399 deletions
|
@ -836,6 +836,8 @@ PRIVATE
|
||||||
history/view/history_view_bottom_info.h
|
history/view/history_view_bottom_info.h
|
||||||
history/view/history_view_chat_preview.cpp
|
history/view/history_view_chat_preview.cpp
|
||||||
history/view/history_view_chat_preview.h
|
history/view/history_view_chat_preview.h
|
||||||
|
history/view/history_view_chat_section.cpp
|
||||||
|
history/view/history_view_chat_section.h
|
||||||
history/view/history_view_contact_status.cpp
|
history/view/history_view_contact_status.cpp
|
||||||
history/view/history_view_contact_status.h
|
history/view/history_view_contact_status.h
|
||||||
history/view/history_view_context_menu.cpp
|
history/view/history_view_context_menu.cpp
|
||||||
|
@ -870,8 +872,6 @@ PRIVATE
|
||||||
history/view/history_view_pinned_tracker.h
|
history/view/history_view_pinned_tracker.h
|
||||||
history/view/history_view_quick_action.cpp
|
history/view/history_view_quick_action.cpp
|
||||||
history/view/history_view_quick_action.h
|
history/view/history_view_quick_action.h
|
||||||
history/view/history_view_replies_section.cpp
|
|
||||||
history/view/history_view_replies_section.h
|
|
||||||
history/view/history_view_reply.cpp
|
history/view/history_view_reply.cpp
|
||||||
history/view/history_view_reply.h
|
history/view/history_view_reply.h
|
||||||
history/view/history_view_requests_bar.cpp
|
history/view/history_view_requests_bar.cpp
|
||||||
|
|
|
@ -27,7 +27,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "boxes/premium_preview_box.h"
|
#include "boxes/premium_preview_box.h"
|
||||||
#include "main/main_session.h"
|
#include "main/main_session.h"
|
||||||
#include "history/history.h"
|
#include "history/history.h"
|
||||||
#include "history/view/history_view_replies_section.h"
|
#include "history/view/history_view_chat_section.h"
|
||||||
#include "history/view/history_view_sticker_toast.h"
|
#include "history/view/history_view_sticker_toast.h"
|
||||||
#include "lang/lang_keys.h"
|
#include "lang/lang_keys.h"
|
||||||
#include "info/profile/info_profile_emoji_status_panel.h"
|
#include "info/profile/info_profile_emoji_status_panel.h"
|
||||||
|
@ -518,13 +518,15 @@ void EditForumTopicBox(
|
||||||
title->showError();
|
title->showError();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
using namespace HistoryView;
|
||||||
controller->showSection(
|
controller->showSection(
|
||||||
std::make_shared<HistoryView::RepliesMemento>(
|
std::make_shared<ChatMemento>(ChatViewId{
|
||||||
forum,
|
.history = forum,
|
||||||
channel->forum()->reserveCreatingId(
|
.repliesRootId = channel->forum()->reserveCreatingId(
|
||||||
title->getLastText().trimmed(),
|
title->getLastText().trimmed(),
|
||||||
state->defaultIcon.current().colorId,
|
state->defaultIcon.current().colorId,
|
||||||
state->iconId.current())),
|
state->iconId.current()),
|
||||||
|
}),
|
||||||
Window::SectionShow::Way::ClearStack);
|
Window::SectionShow::Way::ClearStack);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -26,7 +26,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "history/history_item.h"
|
#include "history/history_item.h"
|
||||||
#include "history/history_unread_things.h"
|
#include "history/history_unread_things.h"
|
||||||
#include "history/view/history_view_item_preview.h"
|
#include "history/view/history_view_item_preview.h"
|
||||||
#include "history/view/history_view_replies_section.h"
|
#include "history/view/history_view_chat_section.h"
|
||||||
#include "main/main_session.h"
|
#include "main/main_session.h"
|
||||||
#include "base/unixtime.h"
|
#include "base/unixtime.h"
|
||||||
#include "ui/painter.h"
|
#include "ui/painter.h"
|
||||||
|
|
|
@ -5311,7 +5311,7 @@ void HistoryWidget::updateSendButtonType() {
|
||||||
using Type = Ui::SendButton::Type;
|
using Type = Ui::SendButton::Type;
|
||||||
|
|
||||||
const auto type = computeSendButtonType();
|
const auto type = computeSendButtonType();
|
||||||
// This logic is duplicated in RepliesWidget.
|
// This logic is duplicated in ChatWidget.
|
||||||
const auto disabledBySlowmode = _peer
|
const auto disabledBySlowmode = _peer
|
||||||
&& _peer->slowmodeApplied()
|
&& _peer->slowmodeApplied()
|
||||||
&& (_history->latestSendingMessage() != nullptr);
|
&& (_history->latestSendingMessage() != nullptr);
|
||||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -64,7 +64,7 @@ struct VoiceToSend;
|
||||||
|
|
||||||
class Element;
|
class Element;
|
||||||
class TopBarWidget;
|
class TopBarWidget;
|
||||||
class RepliesMemento;
|
class ChatMemento;
|
||||||
class ComposeControls;
|
class ComposeControls;
|
||||||
class ComposeSearch;
|
class ComposeSearch;
|
||||||
class SendActionPainter;
|
class SendActionPainter;
|
||||||
|
@ -74,17 +74,24 @@ class EmptyPainter;
|
||||||
class PinnedTracker;
|
class PinnedTracker;
|
||||||
class TranslateBar;
|
class TranslateBar;
|
||||||
|
|
||||||
class RepliesWidget final
|
struct ChatViewId {
|
||||||
|
not_null<History*> history;
|
||||||
|
MsgId repliesRootId;
|
||||||
|
Data::SavedSublist *sublist = nullptr;
|
||||||
|
|
||||||
|
friend inline bool operator==(ChatViewId, ChatViewId) = default;
|
||||||
|
};
|
||||||
|
|
||||||
|
class ChatWidget final
|
||||||
: public Window::SectionWidget
|
: public Window::SectionWidget
|
||||||
, private WindowListDelegate
|
, private WindowListDelegate
|
||||||
, private CornerButtonsDelegate {
|
, private CornerButtonsDelegate {
|
||||||
public:
|
public:
|
||||||
RepliesWidget(
|
ChatWidget(
|
||||||
QWidget *parent,
|
QWidget *parent,
|
||||||
not_null<Window::SessionController*> controller,
|
not_null<Window::SessionController*> controller,
|
||||||
not_null<History*> history,
|
ChatViewId id);
|
||||||
MsgId rootId);
|
~ChatWidget();
|
||||||
~RepliesWidget();
|
|
||||||
|
|
||||||
[[nodiscard]] not_null<History*> history() const;
|
[[nodiscard]] not_null<History*> history() const;
|
||||||
Dialogs::RowDescriptor activeChat() const override;
|
Dialogs::RowDescriptor activeChat() const override;
|
||||||
|
@ -114,7 +121,7 @@ public:
|
||||||
|
|
||||||
void setInternalState(
|
void setInternalState(
|
||||||
const QRect &geometry,
|
const QRect &geometry,
|
||||||
not_null<RepliesMemento*> memento);
|
not_null<ChatMemento*> memento);
|
||||||
|
|
||||||
// Tabbed selector management.
|
// Tabbed selector management.
|
||||||
bool pushTabbedSelectorToThirdSection(
|
bool pushTabbedSelectorToThirdSection(
|
||||||
|
@ -218,8 +225,8 @@ private:
|
||||||
void updateInnerVisibleArea();
|
void updateInnerVisibleArea();
|
||||||
void updateControlsGeometry();
|
void updateControlsGeometry();
|
||||||
void updateAdaptiveLayout();
|
void updateAdaptiveLayout();
|
||||||
void saveState(not_null<RepliesMemento*> memento);
|
void saveState(not_null<ChatMemento*> memento);
|
||||||
void restoreState(not_null<RepliesMemento*> memento);
|
void restoreState(not_null<ChatMemento*> memento);
|
||||||
void setReplies(std::shared_ptr<Data::RepliesList> replies);
|
void setReplies(std::shared_ptr<Data::RepliesList> replies);
|
||||||
void refreshReplies();
|
void refreshReplies();
|
||||||
void showAtStart();
|
void showAtStart();
|
||||||
|
@ -267,7 +274,7 @@ private:
|
||||||
void chooseAttach(std::optional<bool> overrideSendImagesAsPhotos);
|
void chooseAttach(std::optional<bool> overrideSendImagesAsPhotos);
|
||||||
[[nodiscard]] SendMenu::Details sendMenuDetails() const;
|
[[nodiscard]] SendMenu::Details sendMenuDetails() const;
|
||||||
[[nodiscard]] FullReplyTo replyTo() const;
|
[[nodiscard]] FullReplyTo replyTo() const;
|
||||||
[[nodiscard]] HistoryItem *lookupRoot() const;
|
[[nodiscard]] HistoryItem *lookupRepliesRoot() const;
|
||||||
[[nodiscard]] Data::ForumTopic *lookupTopic();
|
[[nodiscard]] Data::ForumTopic *lookupTopic();
|
||||||
[[nodiscard]] bool computeAreComments() const;
|
[[nodiscard]] bool computeAreComments() const;
|
||||||
void orderWidgets();
|
void orderWidgets();
|
||||||
|
@ -347,16 +354,21 @@ private:
|
||||||
[[nodiscard]] bool showSlowmodeError();
|
[[nodiscard]] bool showSlowmodeError();
|
||||||
|
|
||||||
const not_null<History*> _history;
|
const not_null<History*> _history;
|
||||||
MsgId _rootId = 0;
|
const not_null<PeerData*> _peer;
|
||||||
std::shared_ptr<Ui::ChatTheme> _theme;
|
ChatViewId _id;
|
||||||
HistoryItem *_root = nullptr;
|
|
||||||
|
MsgId _repliesRootId = 0;
|
||||||
|
HistoryItem *_repliesRoot = nullptr;
|
||||||
Data::ForumTopic *_topic = nullptr;
|
Data::ForumTopic *_topic = nullptr;
|
||||||
mutable bool _newTopicDiscarded = false;
|
mutable bool _newTopicDiscarded = false;
|
||||||
|
|
||||||
std::shared_ptr<Data::RepliesList> _replies;
|
std::shared_ptr<Data::RepliesList> _replies;
|
||||||
rpl::lifetime _repliesLifetime;
|
rpl::lifetime _repliesLifetime;
|
||||||
rpl::variable<bool> _areComments = false;
|
rpl::variable<bool> _areComments = false;
|
||||||
|
|
||||||
|
Data::SavedSublist *_sublist = nullptr;
|
||||||
|
|
||||||
std::shared_ptr<SendActionPainter> _sendAction;
|
std::shared_ptr<SendActionPainter> _sendAction;
|
||||||
|
std::shared_ptr<Ui::ChatTheme> _theme;
|
||||||
QPointer<ListWidget> _inner;
|
QPointer<ListWidget> _inner;
|
||||||
object_ptr<TopBarWidget> _topBar;
|
object_ptr<TopBarWidget> _topBar;
|
||||||
object_ptr<Ui::PlainShadow> _topBarShadow;
|
object_ptr<Ui::PlainShadow> _topBarShadow;
|
||||||
|
@ -380,11 +392,11 @@ private:
|
||||||
std::optional<FullMsgId> _minPinnedId;
|
std::optional<FullMsgId> _minPinnedId;
|
||||||
HistoryItem *_shownPinnedItem = nullptr;
|
HistoryItem *_shownPinnedItem = nullptr;
|
||||||
|
|
||||||
std::unique_ptr<Ui::PinnedBar> _rootView;
|
std::unique_ptr<Ui::PinnedBar> _repliesRootView;
|
||||||
int _rootViewHeight = 0;
|
int _repliesRootViewHeight = 0;
|
||||||
bool _rootViewInited = false;
|
bool _repliesRootViewInited = false;
|
||||||
bool _rootViewInitScheduled = false;
|
bool _repliesRootViewInitScheduled = false;
|
||||||
rpl::variable<bool> _rootVisible = false;
|
rpl::variable<bool> _repliesRootVisible = false;
|
||||||
|
|
||||||
std::unique_ptr<Ui::ScrollArea> _scroll;
|
std::unique_ptr<Ui::ScrollArea> _scroll;
|
||||||
std::unique_ptr<HistoryView::StickerToast> _stickerToast;
|
std::unique_ptr<HistoryView::StickerToast> _stickerToast;
|
||||||
|
@ -408,15 +420,18 @@ private:
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class RepliesMemento final : public Window::SectionMemento {
|
class ChatMemento final : public Window::SectionMemento {
|
||||||
public:
|
public:
|
||||||
RepliesMemento(
|
explicit ChatMemento(
|
||||||
not_null<History*> history,
|
ChatViewId id,
|
||||||
MsgId rootId,
|
|
||||||
MsgId highlightId = 0,
|
MsgId highlightId = 0,
|
||||||
const TextWithEntities &highlightPart = {},
|
const TextWithEntities &highlightPart = {},
|
||||||
int highlightPartOffsetHint = 0);
|
int highlightPartOffsetHint = 0);
|
||||||
explicit RepliesMemento(
|
|
||||||
|
struct Comments {
|
||||||
|
};
|
||||||
|
explicit ChatMemento(
|
||||||
|
Comments,
|
||||||
not_null<HistoryItem*> commentsItem,
|
not_null<HistoryItem*> commentsItem,
|
||||||
MsgId commentId = 0);
|
MsgId commentId = 0);
|
||||||
|
|
||||||
|
@ -431,11 +446,8 @@ public:
|
||||||
Window::Column column,
|
Window::Column column,
|
||||||
const QRect &geometry) override;
|
const QRect &geometry) override;
|
||||||
|
|
||||||
[[nodiscard]] not_null<History*> getHistory() const {
|
[[nodiscard]] ChatViewId id() const {
|
||||||
return _history;
|
return _id;
|
||||||
}
|
|
||||||
[[nodiscard]] MsgId getRootId() const {
|
|
||||||
return _rootId;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void setReplies(std::shared_ptr<Data::RepliesList> replies) {
|
void setReplies(std::shared_ptr<Data::RepliesList> replies) {
|
||||||
|
@ -472,8 +484,7 @@ public:
|
||||||
private:
|
private:
|
||||||
void setupTopicViewer();
|
void setupTopicViewer();
|
||||||
|
|
||||||
const not_null<History*> _history;
|
ChatViewId _id;
|
||||||
MsgId _rootId = 0;
|
|
||||||
const TextWithEntities _highlightPart;
|
const TextWithEntities _highlightPart;
|
||||||
const int _highlightPartOffsetHint = 0;
|
const int _highlightPartOffsetHint = 0;
|
||||||
const MsgId _highlightId = 0;
|
const MsgId _highlightId = 0;
|
|
@ -16,7 +16,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "mtproto/mtproto_config.h"
|
#include "mtproto/mtproto_config.h"
|
||||||
#include "history/history.h"
|
#include "history/history.h"
|
||||||
#include "history/history_item_components.h"
|
#include "history/history_item_components.h"
|
||||||
#include "history/view/history_view_replies_section.h"
|
#include "history/view/history_view_chat_section.h"
|
||||||
#include "lang/lang_keys.h"
|
#include "lang/lang_keys.h"
|
||||||
#include "data/notify/data_notify_settings.h"
|
#include "data/notify/data_notify_settings.h"
|
||||||
#include "data/stickers/data_custom_emoji.h"
|
#include "data/stickers/data_custom_emoji.h"
|
||||||
|
@ -1221,11 +1221,12 @@ Window::SessionController *Manager::openNotificationMessage(
|
||||||
if (window) {
|
if (window) {
|
||||||
window->widget()->showFromTray();
|
window->widget()->showFromTray();
|
||||||
if (topic) {
|
if (topic) {
|
||||||
|
using namespace HistoryView;
|
||||||
window->showSection(
|
window->showSection(
|
||||||
std::make_shared<HistoryView::RepliesMemento>(
|
std::make_shared<ChatMemento>(ChatViewId{
|
||||||
history,
|
.history = history,
|
||||||
topic->rootId(),
|
.repliesRootId = topic->rootId(),
|
||||||
itemId),
|
}, itemId),
|
||||||
SectionShow::Way::Forward);
|
SectionShow::Way::Forward);
|
||||||
} else {
|
} else {
|
||||||
window->showPeerHistory(
|
window->showPeerHistory(
|
||||||
|
|
|
@ -25,7 +25,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "history/history_item.h"
|
#include "history/history_item.h"
|
||||||
#include "history/view/reactions/history_view_reactions.h"
|
#include "history/view/reactions/history_view_reactions.h"
|
||||||
//#include "history/view/reactions/history_view_reactions_button.h"
|
//#include "history/view/reactions/history_view_reactions_button.h"
|
||||||
#include "history/view/history_view_replies_section.h"
|
#include "history/view/history_view_chat_section.h"
|
||||||
#include "history/view/history_view_scheduled_section.h"
|
#include "history/view/history_view_scheduled_section.h"
|
||||||
#include "history/view/history_view_sublist_section.h"
|
#include "history/view/history_view_sublist_section.h"
|
||||||
#include "media/player/media_player_instance.h"
|
#include "media/player/media_player_instance.h"
|
||||||
|
@ -1140,9 +1140,12 @@ void SessionNavigation::showRepliesForMessage(
|
||||||
if (const auto topic = history->peer->forumTopicFor(rootId)) {
|
if (const auto topic = history->peer->forumTopicFor(rootId)) {
|
||||||
auto replies = topic->replies();
|
auto replies = topic->replies();
|
||||||
if (replies->unreadCountKnown()) {
|
if (replies->unreadCountKnown()) {
|
||||||
auto memento = std::make_shared<HistoryView::RepliesMemento>(
|
using namespace HistoryView;
|
||||||
history,
|
auto memento = std::make_shared<ChatMemento>(
|
||||||
rootId,
|
ChatViewId{
|
||||||
|
.history = history,
|
||||||
|
.repliesRootId = rootId,
|
||||||
|
},
|
||||||
commentId,
|
commentId,
|
||||||
params.highlightPart,
|
params.highlightPart,
|
||||||
params.highlightPartOffsetHint);
|
params.highlightPartOffsetHint);
|
||||||
|
@ -1156,7 +1159,7 @@ void SessionNavigation::showRepliesForMessage(
|
||||||
&& _showingRepliesRootId == rootId) {
|
&& _showingRepliesRootId == rootId) {
|
||||||
return;
|
return;
|
||||||
} else if (!history->peer->asChannel()) {
|
} else if (!history->peer->asChannel()) {
|
||||||
// HistoryView::RepliesWidget right now handles only channels.
|
// HistoryView::ChatWidget replies right now handles only channels.
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
_api.request(base::take(_showingRepliesRequestId)).cancel();
|
_api.request(base::take(_showingRepliesRequestId)).cancel();
|
||||||
|
@ -1211,14 +1214,16 @@ void SessionNavigation::showRepliesForMessage(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (deleted || item) {
|
if (deleted || item) {
|
||||||
|
using namespace HistoryView;
|
||||||
auto memento = item
|
auto memento = item
|
||||||
? std::make_shared<HistoryView::RepliesMemento>(
|
? std::make_shared<ChatMemento>(
|
||||||
|
ChatMemento::Comments(),
|
||||||
item,
|
item,
|
||||||
commentId)
|
commentId)
|
||||||
: std::make_shared<HistoryView::RepliesMemento>(
|
: std::make_shared<ChatMemento>(ChatViewId{
|
||||||
history,
|
.history = history,
|
||||||
rootId,
|
.repliesRootId = rootId,
|
||||||
commentId);
|
}, commentId);
|
||||||
memento->setReadInformation(
|
memento->setReadInformation(
|
||||||
data.vread_inbox_max_id().value_or_empty(),
|
data.vread_inbox_max_id().value_or_empty(),
|
||||||
data.vunread_count().v,
|
data.vunread_count().v,
|
||||||
|
|
Loading…
Add table
Reference in a new issue