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

Method source

Telegram/SourceFiles/data/data_replies_list.cpp:163–214  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

161}
162
163rpl::producer<MessagesSlice> RepliesList::source(
164 MessagePosition aroundId,
165 int limitBefore,
166 int limitAfter) {
167 const auto around = aroundId.fullId.msg;
168 return [=](auto consumer) {
169 auto lifetime = rpl::lifetime();
170 const auto viewer = lifetime.make_state<Viewer>();
171 const auto push = [=] {
172 if (viewer->scheduled) {
173 viewer->scheduled = false;
174 if (buildFromData(viewer)) {
175 appendClientSideMessages(viewer->slice);
176 consumer.put_next_copy(viewer->slice);
177 }
178 }
179 };
180 const auto pushInstant = [=] {
181 viewer->scheduled = true;
182 push();
183 };
184 const auto pushDelayed = [=] {
185 if (!viewer->scheduled) {
186 viewer->scheduled = true;
187 crl::on_main(&viewer->guard, push);
188 }
189 };
190 viewer->around = around;
191 viewer->limitBefore = limitBefore;
192 viewer->limitAfter = limitAfter;
193
194 _history->session().changes().historyUpdates(
195 _history,
196 HistoryUpdate::Flag::ClientSideMessages
197 ) | rpl::on_next(pushDelayed, lifetime);
198
199 _history->session().changes().messageUpdates(
200 MessageUpdate::Flag::Destroyed
201 ) | rpl::filter([=](const MessageUpdate &update) {
202 return applyItemDestroyed(viewer, update.item);
203 }) | rpl::on_next(pushDelayed, lifetime);
204
205 _listChanges.events(
206 ) | rpl::on_next(pushDelayed, lifetime);
207
208 _instantChanges.events(
209 ) | rpl::on_next(pushInstant, lifetime);
210
211 pushInstant();
212 return lifetime;
213 };
214}
215
216void RepliesList::appendClientSideMessages(MessagesSlice &slice) {
217 const auto &messages = _history->clientSideMessages();

Callers

nothing calls this directly

Calls 5

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

Tested by

no test coverage detected