2
0
mirror of https://github.com/telegramdesktop/tdesktop synced 2025-08-31 06:26:18 +00:00

Simplified FileOriginStory.

This commit is contained in:
23rd
2023-11-22 07:55:58 +03:00
committed by John Preston
parent 32008161a0
commit 0865776d9a
5 changed files with 10 additions and 34 deletions

View File

@@ -13,6 +13,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
namespace Data {
using FileOriginMessage = FullMsgId;
using FileOriginStory = FullStoryId;
struct FileOriginUserPhoto {
FileOriginUserPhoto(UserId userId, PhotoId photoId)
@@ -120,20 +121,6 @@ struct FileOriginPremiumPreviews {
}
};
struct FileOriginStory {
FileOriginStory(PeerId peerId, StoryId storyId)
: peerId(peerId)
, storyId(storyId) {
}
PeerId peerId = 0;
StoryId storyId = 0;
friend inline auto operator<=>(
FileOriginStory,
FileOriginStory) = default;
};
struct FileOrigin {
using Variant = std::variant<
v::null_t,

View File

@@ -139,7 +139,7 @@ StoryPreload::LoadTask::LoadTask(
: DownloadMtprotoTask(
&document->session().downloader(),
document->videoPreloadLocation(),
FileOriginStory(id.peer, id.story))
id)
, _done(std::move(done))
, _full(document->size) {
const auto prefix = document->videoPreloadPrefix();
@@ -291,15 +291,9 @@ bool Story::hasReplyPreview() const {
Image *Story::replyPreview() const {
return v::match(_media.data, [&](not_null<PhotoData*> photo) {
return photo->getReplyPreview(
Data::FileOriginStory(_peer->id, _id),
_peer,
false);
return photo->getReplyPreview(fullId(), _peer, false);
}, [&](not_null<DocumentData*> document) {
return document->getReplyPreview(
Data::FileOriginStory(_peer->id, _id),
_peer,
false);
return document->getReplyPreview(fullId(), _peer, false);
}, [](v::null_t) {
return (Image*)nullptr;
});
@@ -757,15 +751,12 @@ not_null<Story*> StoryPreload::story() const {
}
void StoryPreload::start() {
const auto origin = FileOriginStory(
_story->peer()->id,
_story->id());
if (const auto photo = _story->photo()) {
_photo = photo->createMediaView();
if (_photo->loaded()) {
callDone();
} else {
_photo->automaticLoad(origin, _story->peer());
_photo->automaticLoad(_story->fullId(), _story->peer());
photo->session().downloaderTaskFinished(
) | rpl::filter([=] {
return _photo->loaded();