mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +02:00
Added behavior to hide spoilers when switching sections.
This commit is contained in:
parent
a381439e3e
commit
3aacae2cb2
11 changed files with 54 additions and 0 deletions
|
@ -1596,6 +1596,25 @@ void Session::unloadHeavyViewParts(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Session::registerShownSpoiler(FullMsgId id) {
|
||||||
|
if (const auto item = message(id)) {
|
||||||
|
_shownSpoilers.emplace(item);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void Session::unregisterShownSpoiler(FullMsgId id) {
|
||||||
|
if (const auto item = message(id)) {
|
||||||
|
_shownSpoilers.remove(item);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void Session::hideShownSpoilers() {
|
||||||
|
for (const auto &item : _shownSpoilers) {
|
||||||
|
item->hideSpoilers();
|
||||||
|
}
|
||||||
|
_shownSpoilers = base::flat_set<not_null<HistoryItem*>>();
|
||||||
|
}
|
||||||
|
|
||||||
void Session::removeMegagroupParticipant(
|
void Session::removeMegagroupParticipant(
|
||||||
not_null<ChannelData*> channel,
|
not_null<ChannelData*> channel,
|
||||||
not_null<UserData*> user) {
|
not_null<UserData*> user) {
|
||||||
|
|
|
@ -282,6 +282,10 @@ public:
|
||||||
int from,
|
int from,
|
||||||
int till);
|
int till);
|
||||||
|
|
||||||
|
void registerShownSpoiler(FullMsgId id);
|
||||||
|
void unregisterShownSpoiler(FullMsgId id);
|
||||||
|
void hideShownSpoilers();
|
||||||
|
|
||||||
using MegagroupParticipant = std::tuple<
|
using MegagroupParticipant = std::tuple<
|
||||||
not_null<ChannelData*>,
|
not_null<ChannelData*>,
|
||||||
not_null<UserData*>>;
|
not_null<UserData*>>;
|
||||||
|
@ -943,6 +947,8 @@ private:
|
||||||
rpl::event_stream<InviteToCall> _invitesToCalls;
|
rpl::event_stream<InviteToCall> _invitesToCalls;
|
||||||
base::flat_map<uint64, base::flat_set<not_null<UserData*>>> _invitedToCallUsers;
|
base::flat_map<uint64, base::flat_set<not_null<UserData*>>> _invitedToCallUsers;
|
||||||
|
|
||||||
|
base::flat_set<not_null<HistoryItem*>> _shownSpoilers;
|
||||||
|
|
||||||
History *_topPromoted = nullptr;
|
History *_topPromoted = nullptr;
|
||||||
|
|
||||||
NotifySettings _defaultUserNotifySettings;
|
NotifySettings _defaultUserNotifySettings;
|
||||||
|
|
|
@ -333,6 +333,8 @@ public:
|
||||||
virtual void setRealId(MsgId newId);
|
virtual void setRealId(MsgId newId);
|
||||||
virtual void incrementReplyToTopCounter() {
|
virtual void incrementReplyToTopCounter() {
|
||||||
}
|
}
|
||||||
|
virtual void hideSpoilers() {
|
||||||
|
}
|
||||||
|
|
||||||
[[nodiscard]] bool emptyText() const {
|
[[nodiscard]] bool emptyText() const {
|
||||||
return _text.isEmpty();
|
return _text.isEmpty();
|
||||||
|
|
|
@ -998,6 +998,10 @@ void HistoryMessage::setCommentsItemId(FullMsgId id) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void HistoryMessage::hideSpoilers() {
|
||||||
|
HistoryView::HideSpoilers(_text);
|
||||||
|
}
|
||||||
|
|
||||||
bool HistoryMessage::updateDependencyItem() {
|
bool HistoryMessage::updateDependencyItem() {
|
||||||
if (const auto reply = Get<HistoryMessageReply>()) {
|
if (const auto reply = Get<HistoryMessageReply>()) {
|
||||||
const auto documentId = reply->replyToDocumentId;
|
const auto documentId = reply->replyToDocumentId;
|
||||||
|
|
|
@ -201,6 +201,7 @@ public:
|
||||||
[[nodiscard]] MsgId dependencyMsgId() const override {
|
[[nodiscard]] MsgId dependencyMsgId() const override {
|
||||||
return replyToId();
|
return replyToId();
|
||||||
}
|
}
|
||||||
|
void hideSpoilers() override;
|
||||||
|
|
||||||
void applySentMessage(const MTPDmessage &data) override;
|
void applySentMessage(const MTPDmessage &data) override;
|
||||||
void applySentMessage(
|
void applySentMessage(
|
||||||
|
|
|
@ -998,6 +998,10 @@ void HistoryService::setServiceText(const PreparedText &prepared) {
|
||||||
_textHeight = 0;
|
_textHeight = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void HistoryService::hideSpoilers() {
|
||||||
|
HistoryView::HideSpoilers(_text);
|
||||||
|
}
|
||||||
|
|
||||||
void HistoryService::markMediaAsReadHook() {
|
void HistoryService::markMediaAsReadHook() {
|
||||||
if (const auto selfdestruct = Get<HistoryServiceSelfDestruct>()) {
|
if (const auto selfdestruct = Get<HistoryServiceSelfDestruct>()) {
|
||||||
if (!selfdestruct->destructAt) {
|
if (!selfdestruct->destructAt) {
|
||||||
|
|
|
@ -120,6 +120,8 @@ public:
|
||||||
|
|
||||||
void setServiceText(const PreparedText &prepared);
|
void setServiceText(const PreparedText &prepared);
|
||||||
|
|
||||||
|
void hideSpoilers() override;
|
||||||
|
|
||||||
~HistoryService();
|
~HistoryService();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
|
@ -2007,6 +2007,7 @@ void HistoryWidget::showHistory(
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
session().data().sponsoredMessages().clearItems(_history);
|
session().data().sponsoredMessages().clearItems(_history);
|
||||||
|
session().data().hideShownSpoilers();
|
||||||
}
|
}
|
||||||
session().sendProgressManager().update(
|
session().sendProgressManager().update(
|
||||||
_history,
|
_history,
|
||||||
|
|
|
@ -8,7 +8,10 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "history/view/history_view_spoiler_click_handler.h"
|
#include "history/view/history_view_spoiler_click_handler.h"
|
||||||
|
|
||||||
#include "core/click_handler_types.h" // ClickHandlerContext
|
#include "core/click_handler_types.h" // ClickHandlerContext
|
||||||
|
#include "data/data_session.h"
|
||||||
#include "history/view/history_view_element.h"
|
#include "history/view/history_view_element.h"
|
||||||
|
#include "main/main_session.h"
|
||||||
|
#include "window/window_session_controller.h"
|
||||||
#include "ui/spoiler_click_handler.h"
|
#include "ui/spoiler_click_handler.h"
|
||||||
|
|
||||||
namespace HistoryView {
|
namespace HistoryView {
|
||||||
|
@ -33,6 +36,10 @@ void AnimatedSpoilerClickHandler::onClick(ClickContext context) const {
|
||||||
const auto nonconst = const_cast<AnimatedSpoilerClickHandler*>(this);
|
const auto nonconst = const_cast<AnimatedSpoilerClickHandler*>(this);
|
||||||
nonconst->setStartMs(crl::now());
|
nonconst->setStartMs(crl::now());
|
||||||
SpoilerClickHandler::onClick({});
|
SpoilerClickHandler::onClick({});
|
||||||
|
|
||||||
|
if (const auto controller = my.sessionWindow.get()) {
|
||||||
|
controller->session().data().registerShownSpoiler(my.itemId);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -46,4 +53,10 @@ void FillTextWithAnimatedSpoilers(Ui::Text::String &text) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void HideSpoilers(Ui::Text::String &text) {
|
||||||
|
for (auto i = 0; i < text.spoilersCount(); i++) {
|
||||||
|
text.setSpoilerShown(i + 1, false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace HistoryView
|
} // namespace HistoryView
|
||||||
|
|
|
@ -10,5 +10,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
namespace HistoryView {
|
namespace HistoryView {
|
||||||
|
|
||||||
void FillTextWithAnimatedSpoilers(Ui::Text::String &text);
|
void FillTextWithAnimatedSpoilers(Ui::Text::String &text);
|
||||||
|
void HideSpoilers(Ui::Text::String &text);
|
||||||
|
|
||||||
} // namespace HistoryView
|
} // namespace HistoryView
|
||||||
|
|
|
@ -1276,6 +1276,7 @@ void MainWidget::ui_showPeerHistory(
|
||||||
if (IsServerMsgId(showAtMsgId)
|
if (IsServerMsgId(showAtMsgId)
|
||||||
&& _mainSection
|
&& _mainSection
|
||||||
&& _mainSection->showMessage(peerId, params, showAtMsgId)) {
|
&& _mainSection->showMessage(peerId, params, showAtMsgId)) {
|
||||||
|
session().data().hideShownSpoilers();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue