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

Method load

Telegram/SourceFiles/api/api_transcribes.cpp:173–237  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

171}
172
173void Transcribes::load(not_null<HistoryItem*> item) {
174 if (!item->isHistoryEntry() || item->isLocal()) {
175 return;
176 }
177 const auto toggleRound = [](not_null<HistoryItem*> item, Entry &entry) {
178 if (const auto media = item->media()) {
179 if (const auto document = media->document()) {
180 if (document->isVideoMessage()) {
181 entry.roundview = true;
182 document->owner().requestItemViewRefresh(item);
183 }
184 }
185 }
186 };
187 const auto id = item->fullId();
188 const auto requestId = _api.request(MTPmessages_TranscribeAudio(
189 item->history()->peer->input(),
190 MTP_int(item->id)
191 )).done([=](const MTPmessages_TranscribedAudio &result) {
192 const auto &data = result.data();
193
194 {
195 const auto trialsCountChanged = data.vtrial_remains_num()
196 && (_trialsCount != data.vtrial_remains_num()->v);
197 if (trialsCountChanged) {
198 _trialsCount = data.vtrial_remains_num()->v;
199 }
200 const auto refreshAtChanged = data.vtrial_remains_until_date()
201 && (_trialsRefreshAt != data.vtrial_remains_until_date()->v);
202 if (refreshAtChanged) {
203 _trialsRefreshAt = data.vtrial_remains_until_date()->v;
204 }
205 if (trialsCountChanged) {
206 ShowTrialTranscribesToast(_trialsCount, _trialsRefreshAt);
207 }
208 }
209
210 auto &entry = _map[id];
211 entry.requestId = 0;
212 entry.pending = data.is_pending();
213 entry.result = qs(data.vtext());
214 _ids.emplace(data.vtranscription_id().v, id);
215 if (const auto item = _session->data().message(id)) {
216 toggleRound(item, entry);
217 _session->data().requestItemResize(item);
218 }
219 }).fail([=](const MTP::Error &error) {
220 auto &entry = _map[id];
221 entry.requestId = 0;
222 entry.pending = false;
223 entry.failed = true;
224 if (error.type() == u"MSG_VOICE_TOO_LONG"_q) {
225 entry.toolong = true;
226 }
227 if (const auto item = _session->data().message(id)) {
228 toggleRound(item, entry);
229 _session->data().requestItemResize(item);
230 }

Callers 2

ConfirmApprovalFunction · 0.45
ConfirmSubscriptionBoxFunction · 0.45

Calls 15

qsFunction · 0.85
isHistoryEntryMethod · 0.80
isVideoMessageMethod · 0.80
emplaceMethod · 0.80
requestItemResizeMethod · 0.80
MTP_intFunction · 0.50
isLocalMethod · 0.45
mediaMethod · 0.45
documentMethod · 0.45
ownerMethod · 0.45

Tested by

no test coverage detected