2
0
mirror of https://github.com/telegramdesktop/tdesktop synced 2025-08-31 22:46:10 +00:00

Allow editing tag names in Saved Messages.

This commit is contained in:
John Preston
2024-01-26 13:38:38 +04:00
parent 32462fca9b
commit d116c8fea0
13 changed files with 289 additions and 15 deletions

View File

@@ -295,6 +295,16 @@ Session::Session(not_null<Main::Session*> session)
}
}, _lifetime);
_reactions->myTagRenamed(
) | rpl::start_with_next([=](const ReactionId &id) {
const auto i = _viewsByTag.find(id);
if (i != end(_viewsByTag)) {
for (const auto &view : i->second) {
notifyItemDataChange(view->data());
}
}
}, _lifetime);
Spellchecker::HighlightReady(
) | rpl::start_with_next([=](uint64 processId) {
highlightProcessDone(processId);
@@ -4608,6 +4618,28 @@ rpl::producer<not_null<PeerData*>> Session::peerDecorationsUpdated() const {
return _peerDecorationsUpdated.events();
}
void Session::viewTagsChanged(
not_null<ViewElement*> view,
std::vector<Data::ReactionId> &&was,
std::vector<Data::ReactionId> &&now) {
for (const auto &id : now) {
const auto i = ranges::remove(was, id);
if (i != end(was)) {
was.erase(i, end(was));
} else {
_viewsByTag[id].emplace(view);
}
}
for (const auto &id : was) {
const auto i = _viewsByTag.find(id);
if (i != end(_viewsByTag)
&& i->second.remove(view)
&& i->second.empty()) {
_viewsByTag.erase(i);
}
}
}
void Session::clearLocalStorage() {
_cache->close();
_cache->clear();