Ability to restore previously hidden pinned message
This commit is contained in:
parent
e4fbc383af
commit
bb143a26f2
4 changed files with 54 additions and 0 deletions
|
|
@ -5643,6 +5643,32 @@ void HistoryWidget::updatePinnedBar(bool force) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool HistoryWidget::hasHiddenPinnedMessage(not_null<PeerData*> peer) {
|
||||||
|
auto result = false;
|
||||||
|
auto pinnedId = peer->pinnedMessageId();
|
||||||
|
if (pinnedId) {
|
||||||
|
auto it = Global::HiddenPinnedMessages().constFind(peer->id);
|
||||||
|
if (it != Global::HiddenPinnedMessages().cend()) {
|
||||||
|
result = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool HistoryWidget::unhidePinnedMessage(not_null<PeerData*> peer) {
|
||||||
|
auto result = false;
|
||||||
|
auto pinnedId = peer->pinnedMessageId();
|
||||||
|
if (pinnedId) {
|
||||||
|
auto it = Global::HiddenPinnedMessages().constFind(peer->id);
|
||||||
|
if (it != Global::HiddenPinnedMessages().cend()) {
|
||||||
|
Global::RefHiddenPinnedMessages().remove(peer->id);
|
||||||
|
Local::writeUserSettings();
|
||||||
|
result = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
bool HistoryWidget::pinnedMsgVisibilityUpdated() {
|
bool HistoryWidget::pinnedMsgVisibilityUpdated() {
|
||||||
auto result = false;
|
auto result = false;
|
||||||
auto pinnedId = _peer->pinnedMessageId();
|
auto pinnedId = _peer->pinnedMessageId();
|
||||||
|
|
|
||||||
|
|
@ -137,6 +137,8 @@ public:
|
||||||
void sendFileConfirmed(const std::shared_ptr<FileLoadResult> &file,
|
void sendFileConfirmed(const std::shared_ptr<FileLoadResult> &file,
|
||||||
const std::optional<FullMsgId> &oldId = std::nullopt);
|
const std::optional<FullMsgId> &oldId = std::nullopt);
|
||||||
|
|
||||||
|
static bool hasHiddenPinnedMessage(not_null<PeerData*> peer);
|
||||||
|
static bool unhidePinnedMessage(not_null<PeerData*> peer);
|
||||||
void updateControlsVisibility();
|
void updateControlsVisibility();
|
||||||
void updateControlsGeometry();
|
void updateControlsGeometry();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -29,6 +29,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "history/history.h"
|
#include "history/history.h"
|
||||||
#include "history/history_item.h"
|
#include "history/history_item.h"
|
||||||
#include "history/history_message.h" // GetErrorTextForSending.
|
#include "history/history_message.h" // GetErrorTextForSending.
|
||||||
|
#include "history/history_widget.h"
|
||||||
#include "window/window_session_controller.h"
|
#include "window/window_session_controller.h"
|
||||||
#include "window/window_controller.h"
|
#include "window/window_controller.h"
|
||||||
#include "support/support_helper.h"
|
#include "support/support_helper.h"
|
||||||
|
|
@ -387,6 +388,11 @@ void Filler::addUserActions(not_null<UserData*> user) {
|
||||||
user->session().supportHelper().editInfo(user);
|
user->session().supportHelper().editInfo(user);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
if (user->isSelf() && HistoryWidget::hasHiddenPinnedMessage(user)) {
|
||||||
|
_addAction(
|
||||||
|
tr::lng_pinned_message(tr::now),
|
||||||
|
[=] { PeerMenuUnhidePinnedMessage(user); });
|
||||||
|
}
|
||||||
if (!user->isContact() && !user->isSelf() && !user->isBot()) {
|
if (!user->isContact() && !user->isSelf() && !user->isBot()) {
|
||||||
_addAction(
|
_addAction(
|
||||||
tr::lng_info_add_as_contact(tr::now),
|
tr::lng_info_add_as_contact(tr::now),
|
||||||
|
|
@ -439,6 +445,11 @@ void Filler::addChatActions(not_null<ChatData*> chat) {
|
||||||
controller->showEditPeerBox(chat);
|
controller->showEditPeerBox(chat);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
if (HistoryWidget::hasHiddenPinnedMessage(chat)) {
|
||||||
|
_addAction(
|
||||||
|
tr::lng_pinned_message(tr::now),
|
||||||
|
[=] { PeerMenuUnhidePinnedMessage(chat); });
|
||||||
|
}
|
||||||
if (chat->canAddMembers()) {
|
if (chat->canAddMembers()) {
|
||||||
_addAction(
|
_addAction(
|
||||||
tr::lng_profile_add_participant(tr::now),
|
tr::lng_profile_add_participant(tr::now),
|
||||||
|
|
@ -485,6 +496,11 @@ void Filler::addChannelActions(not_null<ChannelData*> channel) {
|
||||||
controller->showEditPeerBox(channel);
|
controller->showEditPeerBox(channel);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
if (HistoryWidget::hasHiddenPinnedMessage(channel)) {
|
||||||
|
_addAction(
|
||||||
|
tr::lng_pinned_message(tr::now),
|
||||||
|
[=] { PeerMenuUnhidePinnedMessage(channel); });
|
||||||
|
}
|
||||||
if (channel->canAddMembers()) {
|
if (channel->canAddMembers()) {
|
||||||
_addAction(
|
_addAction(
|
||||||
tr::lng_channel_add_members(tr::now),
|
tr::lng_channel_add_members(tr::now),
|
||||||
|
|
@ -637,6 +653,15 @@ void FolderFiller::addTogglesForArchive() {
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
|
void PeerMenuUnhidePinnedMessage(not_null<PeerData*> peer) {
|
||||||
|
auto unhidden = HistoryWidget::unhidePinnedMessage(peer);
|
||||||
|
if (unhidden) {
|
||||||
|
Notify::peerUpdatedDelayed(
|
||||||
|
peer,
|
||||||
|
Notify::PeerUpdate::Flag::PinnedMessageChanged);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void PeerMenuExportChat(not_null<PeerData*> peer) {
|
void PeerMenuExportChat(not_null<PeerData*> peer) {
|
||||||
peer->owner().startExport(peer);
|
peer->owner().startExport(peer);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -48,6 +48,7 @@ void PeerMenuAddMuteAction(
|
||||||
not_null<PeerData*> peer,
|
not_null<PeerData*> peer,
|
||||||
const PeerMenuCallback &addAction);
|
const PeerMenuCallback &addAction);
|
||||||
|
|
||||||
|
void PeerMenuUnhidePinnedMessage(not_null<PeerData*> peer);
|
||||||
void PeerMenuExportChat(not_null<PeerData*> peer);
|
void PeerMenuExportChat(not_null<PeerData*> peer);
|
||||||
void PeerMenuDeleteContact(not_null<UserData*> user);
|
void PeerMenuDeleteContact(not_null<UserData*> user);
|
||||||
void PeerMenuShareContactBox(
|
void PeerMenuShareContactBox(
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue