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

Method appendChatsSlice

Telegram/SourceFiles/export/export_api_wrap.cpp:1818–1867  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1816}
1817
1818void ApiWrap::appendChatsSlice(
1819 ChatsProcess &process,
1820 std::vector<Data::DialogInfo> &to,
1821 std::vector<Data::DialogInfo> &&from,
1822 int splitIndex) {
1823 Expects(_settings != nullptr);
1824
1825 const auto types = _settings->types;
1826 const auto goodByTypes = [&](const Data::DialogInfo &info) {
1827 return ((types & SettingsFromDialogsType(info.type)) != 0);
1828 };
1829 auto filtered = ranges::views::all(
1830 from
1831 ) | ranges::views::filter([&](const Data::DialogInfo &info) {
1832 if (goodByTypes(info)) {
1833 return true;
1834 } else if (info.migratedToChannelId
1835 && (((types & Settings::Type::PublicGroups) != 0)
1836 || ((types & Settings::Type::PrivateGroups) != 0))) {
1837 return true;
1838 }
1839 return false;
1840 });
1841 to.reserve(to.size() + from.size());
1842 for (auto &info : filtered) {
1843 const auto nextIndex = to.size();
1844 if (info.migratedToChannelId) {
1845 const auto toPeerId = PeerId(info.migratedToChannelId);
1846 const auto i = process.indexByPeer.find(toPeerId);
1847 if (i != process.indexByPeer.end()
1848 && Data::AddMigrateFromSlice(
1849 to[i->second],
1850 info,
1851 splitIndex,
1852 int(_splits.size()))) {
1853 continue;
1854 } else if (!goodByTypes(info)) {
1855 continue;
1856 }
1857 }
1858 const auto &[i, ok] = process.indexByPeer.emplace(
1859 info.peerId,
1860 nextIndex);
1861 if (ok) {
1862 to.push_back(std::move(info));
1863 }
1864 to[i->second].splits.push_back(splitIndex);
1865 to[i->second].messagesCountPerSplit.push_back(0);
1866 }
1867}
1868
1869void ApiWrap::requestMessagesSlice() {
1870 Expects(_chatProcess != nullptr);

Callers

nothing calls this directly

Calls 7

SettingsFromDialogsTypeFunction · 0.85
PeerIdClass · 0.85
AddMigrateFromSliceFunction · 0.85
emplaceMethod · 0.80
sizeMethod · 0.45
findMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected