mirror of https://github.com/procxx/kepka.git
Improved peer context menu item to archive chat.
This commit is contained in:
parent
f4a63e1e9d
commit
c3c482aa50
|
@ -1965,6 +1965,9 @@ void History::setFolderPointer(Data::Folder *folder) {
|
||||||
if (folder) {
|
if (folder) {
|
||||||
folder->registerOne(this);
|
folder->registerOne(this);
|
||||||
}
|
}
|
||||||
|
Notify::peerUpdatedDelayed(
|
||||||
|
peer,
|
||||||
|
Notify::PeerUpdate::Flag::FolderChanged);
|
||||||
}
|
}
|
||||||
|
|
||||||
void History::applyPinnedUpdate(const MTPDupdateDialogPinned &data) {
|
void History::applyPinnedUpdate(const MTPDupdateDialogPinned &data) {
|
||||||
|
|
|
@ -40,36 +40,37 @@ struct PeerUpdate {
|
||||||
UnreadViewChanged = (1 << 9),
|
UnreadViewChanged = (1 << 9),
|
||||||
PinnedMessageChanged = (1 << 10),
|
PinnedMessageChanged = (1 << 10),
|
||||||
TopPromotedChanged = (1 << 11),
|
TopPromotedChanged = (1 << 11),
|
||||||
|
FolderChanged = (1 << 12),
|
||||||
|
|
||||||
// For chats and channels
|
// For chats and channels
|
||||||
InviteLinkChanged = (1 << 12),
|
InviteLinkChanged = (1 << 13),
|
||||||
MembersChanged = (1 << 13),
|
MembersChanged = (1 << 14),
|
||||||
AdminsChanged = (1 << 14),
|
AdminsChanged = (1 << 15),
|
||||||
BannedUsersChanged = (1 << 15),
|
BannedUsersChanged = (1 << 16),
|
||||||
UnreadMentionsChanged = (1 << 16),
|
UnreadMentionsChanged = (1 << 17),
|
||||||
RightsChanged = (1 << 17),
|
RightsChanged = (1 << 18),
|
||||||
|
|
||||||
// For users
|
// For users
|
||||||
UserCanShareContact = (1 << 18),
|
UserCanShareContact = (1 << 19),
|
||||||
UserIsContact = (1 << 19),
|
UserIsContact = (1 << 20),
|
||||||
UserPhoneChanged = (1 << 20),
|
UserPhoneChanged = (1 << 21),
|
||||||
UserIsBlocked = (1 << 21),
|
UserIsBlocked = (1 << 22),
|
||||||
BotCommandsChanged = (1 << 22),
|
BotCommandsChanged = (1 << 23),
|
||||||
UserOnlineChanged = (1 << 23),
|
UserOnlineChanged = (1 << 24),
|
||||||
BotCanAddToGroups = (1 << 24),
|
BotCanAddToGroups = (1 << 25),
|
||||||
UserCommonChatsChanged = (1 << 25),
|
UserCommonChatsChanged = (1 << 26),
|
||||||
UserHasCalls = (1 << 26),
|
UserHasCalls = (1 << 27),
|
||||||
UserOccupiedChanged = (1 << 27),
|
UserOccupiedChanged = (1 << 28),
|
||||||
UserSupportInfoChanged = (1 << 28),
|
UserSupportInfoChanged = (1 << 29),
|
||||||
|
|
||||||
// For channels
|
// For channels
|
||||||
ChannelAmIn = (1 << 18),
|
ChannelAmIn = (1 << 19),
|
||||||
ChannelStickersChanged = (1 << 19),
|
ChannelStickersChanged = (1 << 20),
|
||||||
ChannelPromotedChanged = (1 << 20),
|
ChannelPromotedChanged = (1 << 21),
|
||||||
ChannelLinkedChat = (1 << 21),
|
ChannelLinkedChat = (1 << 22),
|
||||||
ChannelLocation = (1 << 22),
|
ChannelLocation = (1 << 23),
|
||||||
ChannelSlowmode = (1 << 23),
|
ChannelSlowmode = (1 << 24),
|
||||||
ChannelLocalMessages = (1 << 24),
|
ChannelLocalMessages = (1 << 25),
|
||||||
};
|
};
|
||||||
using Flags = base::flags<Flag>;
|
using Flags = base::flags<Flag>;
|
||||||
friend inline constexpr auto is_flag_type(Flag) { return true; }
|
friend inline constexpr auto is_flag_type(Flag) { return true; }
|
||||||
|
|
|
@ -384,20 +384,30 @@ void Filler::addToggleUnreadMark() {
|
||||||
|
|
||||||
void Filler::addToggleArchive() {
|
void Filler::addToggleArchive() {
|
||||||
const auto peer = _peer;
|
const auto peer = _peer;
|
||||||
const auto archived = [&] {
|
const auto isArchived = [=] {
|
||||||
const auto history = peer->owner().historyLoaded(peer);
|
const auto history = peer->owner().historyLoaded(peer);
|
||||||
return history && history->folder();
|
return history && history->folder();
|
||||||
}();
|
};
|
||||||
const auto toggle = [=] {
|
const auto toggle = [=] {
|
||||||
ToggleHistoryArchived(
|
ToggleHistoryArchived(
|
||||||
peer->owner().history(peer),
|
peer->owner().history(peer),
|
||||||
!archived);
|
!isArchived());
|
||||||
};
|
};
|
||||||
_addAction(
|
const auto archiveAction = _addAction(
|
||||||
(archived
|
(isArchived()
|
||||||
? tr::lng_archived_remove(tr::now)
|
? tr::lng_archived_remove(tr::now)
|
||||||
: tr::lng_archived_add(tr::now)),
|
: tr::lng_archived_add(tr::now)),
|
||||||
toggle);
|
toggle);
|
||||||
|
|
||||||
|
const auto lifetime = Ui::CreateChild<rpl::lifetime>(archiveAction);
|
||||||
|
Notify::PeerUpdateViewer(
|
||||||
|
peer,
|
||||||
|
Notify::PeerUpdate::Flag::FolderChanged
|
||||||
|
) | rpl::start_with_next([=] {
|
||||||
|
archiveAction->setText(isArchived()
|
||||||
|
? tr::lng_archived_remove(tr::now)
|
||||||
|
: tr::lng_archived_add(tr::now));
|
||||||
|
}, *lifetime);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Filler::addBlockUser(not_null<UserData*> user) {
|
void Filler::addBlockUser(not_null<UserData*> user) {
|
||||||
|
|
Loading…
Reference in New Issue