Skip to content

Commit

Permalink
f Update TDLib to 1.8.5 and fix the build.
Browse files Browse the repository at this point in the history
  • Loading branch information
john-preston committed Oct 23, 2024
1 parent f4502fe commit 487cd62
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 8 deletions.
28 changes: 24 additions & 4 deletions Telegram/SourceFiles/chat_helpers/stickers_gift_box_pack.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,19 @@ For license and copyright information please follow this link:
*/
#include "chat_helpers/stickers_gift_box_pack.h"

#if 0 // mtp

#include "apiwrap.h"
#include "data/data_document.h"
#include "data/data_file_origin.h"
#include "data/data_session.h"
#include "main/main_session.h"

#include "tdb/tdb_tl_scheme.h"
#include "tdb/tdb_sender.h"

namespace Stickers {

using namespace Tdb;

GiftBoxPack::GiftBoxPack(not_null<Main::Session*> session)
: _session(session)
, _localMonths({ 1, 3, 6, 12, 24 }) {
Expand All @@ -39,6 +42,7 @@ int GiftBoxPack::monthsForStars(int stars) const {
}

DocumentData *GiftBoxPack::lookup(int months) const {
#if 0 // mtp
const auto it = ranges::lower_bound(_localMonths, months);
const auto fallback = _documents.empty() ? nullptr : _documents[0];
if (it == begin(_localMonths)) {
Expand All @@ -53,12 +57,29 @@ DocumentData *GiftBoxPack::lookup(int months) const {
: 0;
const auto index = int(std::distance(begin(_localMonths), it - shift));
return (index >= _documents.size()) ? fallback : _documents[index];
#endif
const auto i = _months.find(months);
if (i == end(_months)) {
_months.emplace(months, nullptr);
_session->sender().request(TLgetPremiumInfoSticker(
tl_int32(months)
)).done([=](const TLsticker &result) {
const auto document = _session->data().processDocument(result);
if (document->sticker()) {
_months[months] = document;
_updated.fire({});
}
}).send();
return nullptr;
}
return i->second;
}

Data::FileOrigin GiftBoxPack::origin() const {
return Data::FileOriginStickerSet(_setId, _accessHash);
}

#if 0 // mtp
void GiftBoxPack::load() {
if (_requestId || !_documents.empty()) {
return;
Expand Down Expand Up @@ -120,7 +141,6 @@ void GiftBoxPack::applySet(const MTPDmessages_stickerSet &data) {
}
_updated.fire({});
}
#endif

} // namespace Stickers

#endif
10 changes: 6 additions & 4 deletions Telegram/SourceFiles/chat_helpers/stickers_gift_box_pack.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ For license and copyright information please follow this link:
*/
#pragma once

#if 0 // mtp

class DocumentData;

namespace Data {
Expand All @@ -26,15 +24,21 @@ class GiftBoxPack final {
explicit GiftBoxPack(not_null<Main::Session*> session);
~GiftBoxPack();

#if 0 // mtp
void load();
#endif
[[nodiscard]] int monthsForStars(int stars) const;
[[nodiscard]] DocumentData *lookup(int months) const;
[[nodiscard]] Data::FileOrigin origin() const;
[[nodiscard]] rpl::producer<> updated() const;

private:
using SetId = uint64;
#if 0 // mtp
void applySet(const MTPDmessages_stickerSet &data);
#endif

mutable base::flat_map<int, DocumentData*> _months;

const not_null<Main::Session*> _session;
const std::vector<int> _localMonths;
Expand All @@ -48,5 +52,3 @@ class GiftBoxPack final {
};

} // namespace Stickers

#endif

0 comments on commit 487cd62

Please sign in to comment.