mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-03 21:54:05 +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());
|
||||
}, [&](Data::FileOriginStory data) {
|
||||
request(MTPstories_GetStoriesByID(
|
||||
_session->data().peer(data.peerId)->input,
|
||||
MTP_vector<MTPint>(1, MTP_int(data.storyId))));
|
||||
_session->data().peer(data.peer)->input,
|
||||
MTP_vector<MTPint>(1, MTP_int(data.story))));
|
||||
}, [&](v::null_t) {
|
||||
fail();
|
||||
});
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -269,9 +269,7 @@ Main::Session &PhotoThumbnail::session() {
|
|||
StoryThumbnail::Thumb PhotoThumbnail::loaded(FullStoryId id) {
|
||||
if (!_media) {
|
||||
_media = _photo->createMediaView();
|
||||
_media->wanted(
|
||||
Data::PhotoSize::Small,
|
||||
Data::FileOriginStory(id.peer, id.story));
|
||||
_media->wanted(Data::PhotoSize::Small, id);
|
||||
}
|
||||
if (const auto small = _media->image(Data::PhotoSize::Small)) {
|
||||
return { .image = small };
|
||||
|
@ -297,7 +295,7 @@ Main::Session &VideoThumbnail::session() {
|
|||
StoryThumbnail::Thumb VideoThumbnail::loaded(FullStoryId id) {
|
||||
if (!_media) {
|
||||
_media = _video->createMediaView();
|
||||
_media->thumbnailWanted(Data::FileOriginStory(id.peer, id.story));
|
||||
_media->thumbnailWanted(id);
|
||||
}
|
||||
if (const auto small = _media->thumbnail()) {
|
||||
return { .image = small };
|
||||
|
|
|
@ -578,7 +578,7 @@ bool Controller::closeByClickAt(QPoint position) const {
|
|||
}
|
||||
|
||||
Data::FileOrigin Controller::fileOrigin() const {
|
||||
return Data::FileOriginStory(_shown.peer, _shown.story);
|
||||
return _shown;
|
||||
}
|
||||
|
||||
TextWithEntities Controller::captionText() const {
|
||||
|
|
Loading…
Add table
Reference in a new issue