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

Method source

Telegram/SourceFiles/data/data_saved_sublist.cpp:119–165  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

117}
118
119rpl::producer<MessagesSlice> SavedSublist::source(
120 MessagePosition aroundId,
121 int limitBefore,
122 int limitAfter) {
123 const auto around = aroundId.fullId.msg;
124 return [=](auto consumer) {
125 auto lifetime = rpl::lifetime();
126 const auto viewer = lifetime.make_state<Viewer>();
127 const auto push = [=] {
128 if (viewer->scheduled) {
129 viewer->scheduled = false;
130 if (buildFromData(viewer)) {
131 appendClientSideMessages(viewer->slice);
132 consumer.put_next_copy(viewer->slice);
133 }
134 }
135 };
136 const auto pushInstant = [=] {
137 viewer->scheduled = true;
138 push();
139 };
140 const auto pushDelayed = [=] {
141 if (!viewer->scheduled) {
142 viewer->scheduled = true;
143 crl::on_main(&viewer->guard, push);
144 }
145 };
146 viewer->around = around;
147 viewer->limitBefore = limitBefore;
148 viewer->limitAfter = limitAfter;
149
150 const auto history = owningHistory();
151 history->session().changes().historyUpdates(
152 history,
153 HistoryUpdate::Flag::ClientSideMessages
154 ) | rpl::on_next(pushDelayed, lifetime);
155
156 _listChanges.events(
157 ) | rpl::on_next(pushDelayed, lifetime);
158
159 _instantChanges.events(
160 ) | rpl::on_next(pushInstant, lifetime);
161
162 pushInstant();
163 return lifetime;
164 };
165}
166
167not_null<SavedMessages*> SavedSublist::parent() const {
168 return _parent;

Callers

nothing calls this directly

Calls 4

historyUpdatesMethod · 0.80
changesMethod · 0.45
sessionMethod · 0.45
eventsMethod · 0.45

Tested by

no test coverage detected