MCPcopy Create free account
hub / github.com/TDesktop-x64/tdesktop / _stack

Function _stack

Telegram/SourceFiles/info/info_memento.cpp:77–117  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

75
76Memento::Memento(std::vector<std::shared_ptr<ContentMemento>> stack)
77: _stack(std::move(stack)) {
78 auto topics = base::flat_set<not_null<Data::ForumTopic*>>();
79 auto sublists = base::flat_set<not_null<Data::SavedSublist*>>();
80 for (auto &entry : _stack) {
81 if (const auto topic = entry->topic()) {
82 topics.emplace(topic);
83 } else if (const auto sublist = entry->sublist()) {
84 sublists.emplace(sublist);
85 }
86 }
87 for (const auto &topic : topics) {
88 topic->destroyed(
89 ) | rpl::on_next([=] {
90 for (auto i = begin(_stack); i != end(_stack);) {
91 if (i->get()->topic() == topic) {
92 i = _stack.erase(i);
93 } else {
94 ++i;
95 }
96 }
97 if (_stack.empty()) {
98 _removeRequests.fire({});
99 }
100 }, _lifetime);
101 }
102 for (const auto &sublist : sublists) {
103 sublist->destroyed(
104 ) | rpl::on_next([=] {
105 for (auto i = begin(_stack); i != end(_stack);) {
106 if (i->get()->sublist() == sublist) {
107 i = _stack.erase(i);
108 } else {
109 ++i;
110 }
111 }
112 if (_stack.empty()) {
113 _removeRequests.fire({});
114 }
115 }, _lifetime);
116 }
117}
118
119std::vector<std::shared_ptr<ContentMemento>> Memento::DefaultStack(
120 not_null<PeerData*> peer,

Callers

nothing calls this directly

Calls 8

emplaceMethod · 0.80
topicMethod · 0.45
sublistMethod · 0.45
destroyedMethod · 0.45
getMethod · 0.45
eraseMethod · 0.45
emptyMethod · 0.45
fireMethod · 0.45

Tested by

no test coverage detected