mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-06 15:13:57 +02:00
Simplified FileOriginStory.
This commit is contained in:
parent
32008161a0
commit
0865776d9a
5 changed files with 10 additions and 34 deletions
|
@ -2542,8 +2542,8 @@ void ApiWrap::refreshFileReference(
|
||||||
request(MTPhelp_GetPremiumPromo());
|
request(MTPhelp_GetPremiumPromo());
|
||||||
}, [&](Data::FileOriginStory data) {
|
}, [&](Data::FileOriginStory data) {
|
||||||
request(MTPstories_GetStoriesByID(
|
request(MTPstories_GetStoriesByID(
|
||||||
_session->data().peer(data.peerId)->input,
|
_session->data().peer(data.peer)->input,
|
||||||
MTP_vector<MTPint>(1, MTP_int(data.storyId))));
|
MTP_vector<MTPint>(1, MTP_int(data.story))));
|
||||||
}, [&](v::null_t) {
|
}, [&](v::null_t) {
|
||||||
fail();
|
fail();
|
||||||
});
|
});
|
||||||
|
|
|
@ -13,6 +13,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
namespace Data {
|
namespace Data {
|
||||||
|
|
||||||
using FileOriginMessage = FullMsgId;
|
using FileOriginMessage = FullMsgId;
|
||||||
|
using FileOriginStory = FullStoryId;
|
||||||
|
|
||||||
struct FileOriginUserPhoto {
|
struct FileOriginUserPhoto {
|
||||||
FileOriginUserPhoto(UserId userId, PhotoId photoId)
|
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 {
|
struct FileOrigin {
|
||||||
using Variant = std::variant<
|
using Variant = std::variant<
|
||||||
v::null_t,
|
v::null_t,
|
||||||
|
|
|
@ -139,7 +139,7 @@ StoryPreload::LoadTask::LoadTask(
|
||||||
: DownloadMtprotoTask(
|
: DownloadMtprotoTask(
|
||||||
&document->session().downloader(),
|
&document->session().downloader(),
|
||||||
document->videoPreloadLocation(),
|
document->videoPreloadLocation(),
|
||||||
FileOriginStory(id.peer, id.story))
|
id)
|
||||||
, _done(std::move(done))
|
, _done(std::move(done))
|
||||||
, _full(document->size) {
|
, _full(document->size) {
|
||||||
const auto prefix = document->videoPreloadPrefix();
|
const auto prefix = document->videoPreloadPrefix();
|
||||||
|
@ -291,15 +291,9 @@ bool Story::hasReplyPreview() const {
|
||||||
|
|
||||||
Image *Story::replyPreview() const {
|
Image *Story::replyPreview() const {
|
||||||
return v::match(_media.data, [&](not_null<PhotoData*> photo) {
|
return v::match(_media.data, [&](not_null<PhotoData*> photo) {
|
||||||
return photo->getReplyPreview(
|
return photo->getReplyPreview(fullId(), _peer, false);
|
||||||
Data::FileOriginStory(_peer->id, _id),
|
|
||||||
_peer,
|
|
||||||
false);
|
|
||||||
}, [&](not_null<DocumentData*> document) {
|
}, [&](not_null<DocumentData*> document) {
|
||||||
return document->getReplyPreview(
|
return document->getReplyPreview(fullId(), _peer, false);
|
||||||
Data::FileOriginStory(_peer->id, _id),
|
|
||||||
_peer,
|
|
||||||
false);
|
|
||||||
}, [](v::null_t) {
|
}, [](v::null_t) {
|
||||||
return (Image*)nullptr;
|
return (Image*)nullptr;
|
||||||
});
|
});
|
||||||
|
@ -757,15 +751,12 @@ not_null<Story*> StoryPreload::story() const {
|
||||||
}
|
}
|
||||||
|
|
||||||
void StoryPreload::start() {
|
void StoryPreload::start() {
|
||||||
const auto origin = FileOriginStory(
|
|
||||||
_story->peer()->id,
|
|
||||||
_story->id());
|
|
||||||
if (const auto photo = _story->photo()) {
|
if (const auto photo = _story->photo()) {
|
||||||
_photo = photo->createMediaView();
|
_photo = photo->createMediaView();
|
||||||
if (_photo->loaded()) {
|
if (_photo->loaded()) {
|
||||||
callDone();
|
callDone();
|
||||||
} else {
|
} else {
|
||||||
_photo->automaticLoad(origin, _story->peer());
|
_photo->automaticLoad(_story->fullId(), _story->peer());
|
||||||
photo->session().downloaderTaskFinished(
|
photo->session().downloaderTaskFinished(
|
||||||
) | rpl::filter([=] {
|
) | rpl::filter([=] {
|
||||||
return _photo->loaded();
|
return _photo->loaded();
|
||||||
|
|
|
@ -269,9 +269,7 @@ Main::Session &PhotoThumbnail::session() {
|
||||||
StoryThumbnail::Thumb PhotoThumbnail::loaded(FullStoryId id) {
|
StoryThumbnail::Thumb PhotoThumbnail::loaded(FullStoryId id) {
|
||||||
if (!_media) {
|
if (!_media) {
|
||||||
_media = _photo->createMediaView();
|
_media = _photo->createMediaView();
|
||||||
_media->wanted(
|
_media->wanted(Data::PhotoSize::Small, id);
|
||||||
Data::PhotoSize::Small,
|
|
||||||
Data::FileOriginStory(id.peer, id.story));
|
|
||||||
}
|
}
|
||||||
if (const auto small = _media->image(Data::PhotoSize::Small)) {
|
if (const auto small = _media->image(Data::PhotoSize::Small)) {
|
||||||
return { .image = small };
|
return { .image = small };
|
||||||
|
@ -297,7 +295,7 @@ Main::Session &VideoThumbnail::session() {
|
||||||
StoryThumbnail::Thumb VideoThumbnail::loaded(FullStoryId id) {
|
StoryThumbnail::Thumb VideoThumbnail::loaded(FullStoryId id) {
|
||||||
if (!_media) {
|
if (!_media) {
|
||||||
_media = _video->createMediaView();
|
_media = _video->createMediaView();
|
||||||
_media->thumbnailWanted(Data::FileOriginStory(id.peer, id.story));
|
_media->thumbnailWanted(id);
|
||||||
}
|
}
|
||||||
if (const auto small = _media->thumbnail()) {
|
if (const auto small = _media->thumbnail()) {
|
||||||
return { .image = small };
|
return { .image = small };
|
||||||
|
|
|
@ -578,7 +578,7 @@ bool Controller::closeByClickAt(QPoint position) const {
|
||||||
}
|
}
|
||||||
|
|
||||||
Data::FileOrigin Controller::fileOrigin() const {
|
Data::FileOrigin Controller::fileOrigin() const {
|
||||||
return Data::FileOriginStory(_shown.peer, _shown.story);
|
return _shown;
|
||||||
}
|
}
|
||||||
|
|
||||||
TextWithEntities Controller::captionText() const {
|
TextWithEntities Controller::captionText() const {
|
||||||
|
|
Loading…
Add table
Reference in a new issue