data_user_photos.h 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. /*
  2. This file is part of Telegram Desktop,
  3. the official desktop application for the Telegram messaging service.
  4. For license and copyright information please follow this link:
  5. https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
  6. */
  7. #pragma once
  8. #include "data/data_abstract_sparse_ids.h"
  9. #include "storage/storage_user_photos.h"
  10. #include "base/weak_ptr.h"
  11. class UserData;
  12. namespace Main {
  13. class Session;
  14. } // namespace Main
  15. class UserPhotosSlice final : public AbstractSparseIds<std::deque<PhotoId>> {
  16. public:
  17. using Key = Storage::UserPhotosKey;
  18. UserPhotosSlice(Key key);
  19. UserPhotosSlice(
  20. Key key,
  21. std::deque<PhotoId> &&ids,
  22. std::optional<int> fullCount,
  23. std::optional<int> skippedBefore,
  24. std::optional<int> skippedAfter);
  25. std::optional<int> distance(const Key &a, const Key &b) const;
  26. const Key &key() const { return _key; }
  27. private:
  28. Key _key;
  29. friend class UserPhotosSliceBuilder;
  30. };
  31. rpl::producer<UserPhotosSlice> UserPhotosViewer(
  32. not_null<Main::Session*> session,
  33. UserPhotosSlice::Key key,
  34. int limitBefore,
  35. int limitAfter);
  36. rpl::producer<UserPhotosSlice> UserPhotosReversedViewer(
  37. not_null<Main::Session*> session,
  38. UserPhotosSlice::Key key,
  39. int limitBefore,
  40. int limitAfter);
  41. [[nodiscard]] std::optional<PhotoId> SyncUserFallbackPhotoViewer(
  42. not_null<UserData*> user);