mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-04-16 06:07:06 +02:00
Support stories file reference refreshing.
This commit is contained in:
parent
7a042c23e9
commit
b195ec4fd5
8 changed files with 68 additions and 21 deletions
|
@ -2509,6 +2509,15 @@ void ApiWrap::refreshFileReference(
|
|||
request(MTPaccount_GetSavedRingtones(MTP_long(0)));
|
||||
}, [&](Data::FileOriginPremiumPreviews data) {
|
||||
request(MTPhelp_GetPremiumPromo());
|
||||
}, [&](Data::FileOriginStory data) {
|
||||
const auto user = _session->data().peer(data.peerId)->asUser();
|
||||
if (user) {
|
||||
request(MTPstories_GetStoriesByID(
|
||||
user->inputUser,
|
||||
MTP_vector<MTPint>(1, MTP_int(data.storyId))));
|
||||
} else {
|
||||
fail();
|
||||
}
|
||||
}, [&](v::null_t) {
|
||||
fail();
|
||||
});
|
||||
|
|
|
@ -40,10 +40,8 @@ struct FileReferenceAccumulator {
|
|||
});
|
||||
}
|
||||
void push(const MTPPage &data) {
|
||||
data.match([&](const auto &data) {
|
||||
push(data.vphotos());
|
||||
push(data.vdocuments());
|
||||
});
|
||||
push(data.data().vphotos());
|
||||
push(data.data().vdocuments());
|
||||
}
|
||||
void push(const MTPWallPaper &data) {
|
||||
data.match([&](const MTPDwallPaper &data) {
|
||||
|
@ -52,14 +50,10 @@ struct FileReferenceAccumulator {
|
|||
});
|
||||
}
|
||||
void push(const MTPTheme &data) {
|
||||
data.match([&](const MTPDtheme &data) {
|
||||
push(data.vdocument());
|
||||
});
|
||||
push(data.data().vdocument());
|
||||
}
|
||||
void push(const MTPWebPageAttribute &data) {
|
||||
data.match([&](const MTPDwebPageAttributeTheme &data) {
|
||||
push(data.vdocuments());
|
||||
});
|
||||
push(data.data().vdocuments());
|
||||
}
|
||||
void push(const MTPWebPage &data) {
|
||||
data.match([&](const MTPDwebPage &data) {
|
||||
|
@ -104,6 +98,13 @@ struct FileReferenceAccumulator {
|
|||
}, [](const MTPDmessageEmpty &data) {
|
||||
});
|
||||
}
|
||||
void push(const MTPStoryItem &data) {
|
||||
data.match([&](const MTPDstoryItem &data) {
|
||||
push(data.vmedia());
|
||||
}, [](const MTPDstoryItemDeleted &) {
|
||||
}, [](const MTPDstoryItemSkipped &) {
|
||||
});
|
||||
}
|
||||
void push(const MTPmessages_Messages &data) {
|
||||
data.match([](const MTPDmessages_messagesNotModified &) {
|
||||
}, [&](const auto &data) {
|
||||
|
@ -116,9 +117,7 @@ struct FileReferenceAccumulator {
|
|||
});
|
||||
}
|
||||
void push(const MTPusers_UserFull &data) {
|
||||
data.match([&](const auto &data) {
|
||||
push(data.vfull_user().data().vpersonal_photo());
|
||||
});
|
||||
push(data.data().vfull_user().data().vpersonal_photo());
|
||||
}
|
||||
void push(const MTPmessages_RecentStickers &data) {
|
||||
data.match([&](const MTPDmessages_recentStickers &data) {
|
||||
|
@ -151,9 +150,10 @@ struct FileReferenceAccumulator {
|
|||
});
|
||||
}
|
||||
void push(const MTPhelp_PremiumPromo &data) {
|
||||
data.match([&](const MTPDhelp_premiumPromo &data) {
|
||||
push(data.vvideos());
|
||||
});
|
||||
push(data.data().vvideos());
|
||||
}
|
||||
void push(const MTPstories_Stories &data) {
|
||||
push(data.data().vstories());
|
||||
}
|
||||
|
||||
UpdatedFileReferences result;
|
||||
|
@ -216,6 +216,10 @@ UpdatedFileReferences GetFileReferences(const MTPhelp_PremiumPromo &data) {
|
|||
return GetFileReferencesHelper(data);
|
||||
}
|
||||
|
||||
UpdatedFileReferences GetFileReferences(const MTPstories_Stories &data) {
|
||||
return GetFileReferencesHelper(data);
|
||||
}
|
||||
|
||||
UpdatedFileReferences GetFileReferences(const MTPMessageMedia &data) {
|
||||
return GetFileReferencesHelper(data);
|
||||
}
|
||||
|
|
|
@ -120,6 +120,20 @@ 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,
|
||||
|
@ -132,7 +146,8 @@ struct FileOrigin {
|
|||
FileOriginWallpaper,
|
||||
FileOriginTheme,
|
||||
FileOriginRingtones,
|
||||
FileOriginPremiumPreviews>;
|
||||
FileOriginPremiumPreviews,
|
||||
FileOriginStory>;
|
||||
|
||||
FileOrigin() = default;
|
||||
FileOrigin(FileOriginMessage data) : data(data) {
|
||||
|
@ -155,6 +170,8 @@ struct FileOrigin {
|
|||
}
|
||||
FileOrigin(FileOriginPremiumPreviews data) : data(data) {
|
||||
}
|
||||
FileOrigin(FileOriginStory data) : data(data) {
|
||||
}
|
||||
|
||||
explicit operator bool() const {
|
||||
return !v::is_null(data);
|
||||
|
@ -204,6 +221,7 @@ UpdatedFileReferences GetFileReferences(const MTPTheme &data);
|
|||
UpdatedFileReferences GetFileReferences(
|
||||
const MTPaccount_SavedRingtones &data);
|
||||
UpdatedFileReferences GetFileReferences(const MTPhelp_PremiumPromo &data);
|
||||
UpdatedFileReferences GetFileReferences(const MTPstories_Stories &data);
|
||||
|
||||
// Admin Log Event.
|
||||
UpdatedFileReferences GetFileReferences(const MTPMessageMedia &data);
|
||||
|
|
|
@ -10,6 +10,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "base/timer.h"
|
||||
#include "base/power_save_blocker.h"
|
||||
#include "chat_helpers/compose/compose_show.h"
|
||||
#include "data/data_file_origin.h"
|
||||
#include "data/data_session.h"
|
||||
#include "data/data_stories.h"
|
||||
#include "data/data_user.h"
|
||||
|
@ -317,6 +318,10 @@ ContentLayout Controller::contentLayout() const {
|
|||
};
|
||||
}
|
||||
|
||||
Data::FileOrigin Controller::fileOrigin() const {
|
||||
return Data::FileOriginStory(_shown.peer, _shown.story);
|
||||
}
|
||||
|
||||
TextWithEntities Controller::captionText() const {
|
||||
return _captionText;
|
||||
}
|
||||
|
|
|
@ -21,6 +21,7 @@ struct FileChosen;
|
|||
|
||||
namespace Data {
|
||||
struct StoriesList;
|
||||
struct FileOrigin;
|
||||
} // namespace Data
|
||||
|
||||
namespace Ui {
|
||||
|
@ -80,6 +81,7 @@ public:
|
|||
[[nodiscard]] Layout layout() const;
|
||||
[[nodiscard]] rpl::producer<Layout> layoutValue() const;
|
||||
[[nodiscard]] ContentLayout contentLayout() const;
|
||||
[[nodiscard]] Data::FileOrigin fileOrigin() const;
|
||||
[[nodiscard]] TextWithEntities captionText() const;
|
||||
void showFullCaption();
|
||||
|
||||
|
|
|
@ -7,6 +7,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
*/
|
||||
#include "media/stories/media_stories_view.h"
|
||||
|
||||
#include "data/data_file_origin.h"
|
||||
#include "media/stories/media_stories_controller.h"
|
||||
#include "media/stories/media_stories_delegate.h"
|
||||
#include "media/stories/media_stories_header.h"
|
||||
|
@ -79,6 +80,10 @@ SiblingView View::sibling(SiblingType type) const {
|
|||
return _controller->sibling(type);
|
||||
}
|
||||
|
||||
Data::FileOrigin View::fileOrigin() const {
|
||||
return _controller->fileOrigin();
|
||||
}
|
||||
|
||||
TextWithEntities View::captionText() const {
|
||||
return _controller->captionText();
|
||||
}
|
||||
|
|
|
@ -9,6 +9,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
|
||||
namespace Data {
|
||||
struct StoriesList;
|
||||
struct FileOrigin;
|
||||
} // namespace Data
|
||||
|
||||
namespace Media::Player {
|
||||
|
@ -62,6 +63,7 @@ public:
|
|||
[[nodiscard]] rpl::producer<QRect> finalShownGeometryValue() const;
|
||||
[[nodiscard]] ContentLayout contentLayout() const;
|
||||
[[nodiscard]] SiblingView sibling(SiblingType type) const;
|
||||
[[nodiscard]] Data::FileOrigin fileOrigin() const;
|
||||
[[nodiscard]] TextWithEntities captionText() const;
|
||||
void showFullCaption();
|
||||
|
||||
|
|
|
@ -2584,7 +2584,9 @@ auto OverlayWidget::sharedMediaKey() const -> std::optional<SharedMediaKey> {
|
|||
}
|
||||
|
||||
Data::FileOrigin OverlayWidget::fileOrigin() const {
|
||||
if (_message) {
|
||||
if (_stories) {
|
||||
return _stories->fileOrigin();
|
||||
} else if (_message) {
|
||||
return _message->fullId();
|
||||
} else if (_photo && _user) {
|
||||
return Data::FileOriginUserPhoto(peerToUser(_user->id), _photo->id);
|
||||
|
@ -2828,15 +2830,15 @@ void OverlayWidget::refreshFromLabel() {
|
|||
void OverlayWidget::refreshCaption() {
|
||||
_caption = Ui::Text::String();
|
||||
const auto caption = [&] {
|
||||
if (_message) {
|
||||
if (_stories) {
|
||||
return _stories->captionText();
|
||||
} else if (_message) {
|
||||
if (const auto media = _message->media()) {
|
||||
if (media->webpage()) {
|
||||
return TextWithEntities();
|
||||
}
|
||||
}
|
||||
return _message->translatedText();
|
||||
} else if (_stories) {
|
||||
return _stories->captionText();
|
||||
}
|
||||
return TextWithEntities();
|
||||
}();
|
||||
|
|
Loading…
Add table
Reference in a new issue