mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +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)));
|
request(MTPaccount_GetSavedRingtones(MTP_long(0)));
|
||||||
}, [&](Data::FileOriginPremiumPreviews data) {
|
}, [&](Data::FileOriginPremiumPreviews data) {
|
||||||
request(MTPhelp_GetPremiumPromo());
|
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) {
|
}, [&](v::null_t) {
|
||||||
fail();
|
fail();
|
||||||
});
|
});
|
||||||
|
|
|
@ -40,10 +40,8 @@ struct FileReferenceAccumulator {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
void push(const MTPPage &data) {
|
void push(const MTPPage &data) {
|
||||||
data.match([&](const auto &data) {
|
push(data.data().vphotos());
|
||||||
push(data.vphotos());
|
push(data.data().vdocuments());
|
||||||
push(data.vdocuments());
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
void push(const MTPWallPaper &data) {
|
void push(const MTPWallPaper &data) {
|
||||||
data.match([&](const MTPDwallPaper &data) {
|
data.match([&](const MTPDwallPaper &data) {
|
||||||
|
@ -52,14 +50,10 @@ struct FileReferenceAccumulator {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
void push(const MTPTheme &data) {
|
void push(const MTPTheme &data) {
|
||||||
data.match([&](const MTPDtheme &data) {
|
push(data.data().vdocument());
|
||||||
push(data.vdocument());
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
void push(const MTPWebPageAttribute &data) {
|
void push(const MTPWebPageAttribute &data) {
|
||||||
data.match([&](const MTPDwebPageAttributeTheme &data) {
|
push(data.data().vdocuments());
|
||||||
push(data.vdocuments());
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
void push(const MTPWebPage &data) {
|
void push(const MTPWebPage &data) {
|
||||||
data.match([&](const MTPDwebPage &data) {
|
data.match([&](const MTPDwebPage &data) {
|
||||||
|
@ -104,6 +98,13 @@ struct FileReferenceAccumulator {
|
||||||
}, [](const MTPDmessageEmpty &data) {
|
}, [](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) {
|
void push(const MTPmessages_Messages &data) {
|
||||||
data.match([](const MTPDmessages_messagesNotModified &) {
|
data.match([](const MTPDmessages_messagesNotModified &) {
|
||||||
}, [&](const auto &data) {
|
}, [&](const auto &data) {
|
||||||
|
@ -116,9 +117,7 @@ struct FileReferenceAccumulator {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
void push(const MTPusers_UserFull &data) {
|
void push(const MTPusers_UserFull &data) {
|
||||||
data.match([&](const auto &data) {
|
push(data.data().vfull_user().data().vpersonal_photo());
|
||||||
push(data.vfull_user().data().vpersonal_photo());
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
void push(const MTPmessages_RecentStickers &data) {
|
void push(const MTPmessages_RecentStickers &data) {
|
||||||
data.match([&](const MTPDmessages_recentStickers &data) {
|
data.match([&](const MTPDmessages_recentStickers &data) {
|
||||||
|
@ -151,9 +150,10 @@ struct FileReferenceAccumulator {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
void push(const MTPhelp_PremiumPromo &data) {
|
void push(const MTPhelp_PremiumPromo &data) {
|
||||||
data.match([&](const MTPDhelp_premiumPromo &data) {
|
push(data.data().vvideos());
|
||||||
push(data.vvideos());
|
}
|
||||||
});
|
void push(const MTPstories_Stories &data) {
|
||||||
|
push(data.data().vstories());
|
||||||
}
|
}
|
||||||
|
|
||||||
UpdatedFileReferences result;
|
UpdatedFileReferences result;
|
||||||
|
@ -216,6 +216,10 @@ UpdatedFileReferences GetFileReferences(const MTPhelp_PremiumPromo &data) {
|
||||||
return GetFileReferencesHelper(data);
|
return GetFileReferencesHelper(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
UpdatedFileReferences GetFileReferences(const MTPstories_Stories &data) {
|
||||||
|
return GetFileReferencesHelper(data);
|
||||||
|
}
|
||||||
|
|
||||||
UpdatedFileReferences GetFileReferences(const MTPMessageMedia &data) {
|
UpdatedFileReferences GetFileReferences(const MTPMessageMedia &data) {
|
||||||
return GetFileReferencesHelper(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 {
|
struct FileOrigin {
|
||||||
using Variant = std::variant<
|
using Variant = std::variant<
|
||||||
v::null_t,
|
v::null_t,
|
||||||
|
@ -132,7 +146,8 @@ struct FileOrigin {
|
||||||
FileOriginWallpaper,
|
FileOriginWallpaper,
|
||||||
FileOriginTheme,
|
FileOriginTheme,
|
||||||
FileOriginRingtones,
|
FileOriginRingtones,
|
||||||
FileOriginPremiumPreviews>;
|
FileOriginPremiumPreviews,
|
||||||
|
FileOriginStory>;
|
||||||
|
|
||||||
FileOrigin() = default;
|
FileOrigin() = default;
|
||||||
FileOrigin(FileOriginMessage data) : data(data) {
|
FileOrigin(FileOriginMessage data) : data(data) {
|
||||||
|
@ -155,6 +170,8 @@ struct FileOrigin {
|
||||||
}
|
}
|
||||||
FileOrigin(FileOriginPremiumPreviews data) : data(data) {
|
FileOrigin(FileOriginPremiumPreviews data) : data(data) {
|
||||||
}
|
}
|
||||||
|
FileOrigin(FileOriginStory data) : data(data) {
|
||||||
|
}
|
||||||
|
|
||||||
explicit operator bool() const {
|
explicit operator bool() const {
|
||||||
return !v::is_null(data);
|
return !v::is_null(data);
|
||||||
|
@ -204,6 +221,7 @@ UpdatedFileReferences GetFileReferences(const MTPTheme &data);
|
||||||
UpdatedFileReferences GetFileReferences(
|
UpdatedFileReferences GetFileReferences(
|
||||||
const MTPaccount_SavedRingtones &data);
|
const MTPaccount_SavedRingtones &data);
|
||||||
UpdatedFileReferences GetFileReferences(const MTPhelp_PremiumPromo &data);
|
UpdatedFileReferences GetFileReferences(const MTPhelp_PremiumPromo &data);
|
||||||
|
UpdatedFileReferences GetFileReferences(const MTPstories_Stories &data);
|
||||||
|
|
||||||
// Admin Log Event.
|
// Admin Log Event.
|
||||||
UpdatedFileReferences GetFileReferences(const MTPMessageMedia &data);
|
UpdatedFileReferences GetFileReferences(const MTPMessageMedia &data);
|
||||||
|
|
|
@ -10,6 +10,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "base/timer.h"
|
#include "base/timer.h"
|
||||||
#include "base/power_save_blocker.h"
|
#include "base/power_save_blocker.h"
|
||||||
#include "chat_helpers/compose/compose_show.h"
|
#include "chat_helpers/compose/compose_show.h"
|
||||||
|
#include "data/data_file_origin.h"
|
||||||
#include "data/data_session.h"
|
#include "data/data_session.h"
|
||||||
#include "data/data_stories.h"
|
#include "data/data_stories.h"
|
||||||
#include "data/data_user.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 {
|
TextWithEntities Controller::captionText() const {
|
||||||
return _captionText;
|
return _captionText;
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,6 +21,7 @@ struct FileChosen;
|
||||||
|
|
||||||
namespace Data {
|
namespace Data {
|
||||||
struct StoriesList;
|
struct StoriesList;
|
||||||
|
struct FileOrigin;
|
||||||
} // namespace Data
|
} // namespace Data
|
||||||
|
|
||||||
namespace Ui {
|
namespace Ui {
|
||||||
|
@ -80,6 +81,7 @@ public:
|
||||||
[[nodiscard]] Layout layout() const;
|
[[nodiscard]] Layout layout() const;
|
||||||
[[nodiscard]] rpl::producer<Layout> layoutValue() const;
|
[[nodiscard]] rpl::producer<Layout> layoutValue() const;
|
||||||
[[nodiscard]] ContentLayout contentLayout() const;
|
[[nodiscard]] ContentLayout contentLayout() const;
|
||||||
|
[[nodiscard]] Data::FileOrigin fileOrigin() const;
|
||||||
[[nodiscard]] TextWithEntities captionText() const;
|
[[nodiscard]] TextWithEntities captionText() const;
|
||||||
void showFullCaption();
|
void showFullCaption();
|
||||||
|
|
||||||
|
|
|
@ -7,6 +7,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
*/
|
*/
|
||||||
#include "media/stories/media_stories_view.h"
|
#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_controller.h"
|
||||||
#include "media/stories/media_stories_delegate.h"
|
#include "media/stories/media_stories_delegate.h"
|
||||||
#include "media/stories/media_stories_header.h"
|
#include "media/stories/media_stories_header.h"
|
||||||
|
@ -79,6 +80,10 @@ SiblingView View::sibling(SiblingType type) const {
|
||||||
return _controller->sibling(type);
|
return _controller->sibling(type);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Data::FileOrigin View::fileOrigin() const {
|
||||||
|
return _controller->fileOrigin();
|
||||||
|
}
|
||||||
|
|
||||||
TextWithEntities View::captionText() const {
|
TextWithEntities View::captionText() const {
|
||||||
return _controller->captionText();
|
return _controller->captionText();
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,6 +9,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
|
|
||||||
namespace Data {
|
namespace Data {
|
||||||
struct StoriesList;
|
struct StoriesList;
|
||||||
|
struct FileOrigin;
|
||||||
} // namespace Data
|
} // namespace Data
|
||||||
|
|
||||||
namespace Media::Player {
|
namespace Media::Player {
|
||||||
|
@ -62,6 +63,7 @@ public:
|
||||||
[[nodiscard]] rpl::producer<QRect> finalShownGeometryValue() const;
|
[[nodiscard]] rpl::producer<QRect> finalShownGeometryValue() const;
|
||||||
[[nodiscard]] ContentLayout contentLayout() const;
|
[[nodiscard]] ContentLayout contentLayout() const;
|
||||||
[[nodiscard]] SiblingView sibling(SiblingType type) const;
|
[[nodiscard]] SiblingView sibling(SiblingType type) const;
|
||||||
|
[[nodiscard]] Data::FileOrigin fileOrigin() const;
|
||||||
[[nodiscard]] TextWithEntities captionText() const;
|
[[nodiscard]] TextWithEntities captionText() const;
|
||||||
void showFullCaption();
|
void showFullCaption();
|
||||||
|
|
||||||
|
|
|
@ -2584,7 +2584,9 @@ auto OverlayWidget::sharedMediaKey() const -> std::optional<SharedMediaKey> {
|
||||||
}
|
}
|
||||||
|
|
||||||
Data::FileOrigin OverlayWidget::fileOrigin() const {
|
Data::FileOrigin OverlayWidget::fileOrigin() const {
|
||||||
if (_message) {
|
if (_stories) {
|
||||||
|
return _stories->fileOrigin();
|
||||||
|
} else if (_message) {
|
||||||
return _message->fullId();
|
return _message->fullId();
|
||||||
} else if (_photo && _user) {
|
} else if (_photo && _user) {
|
||||||
return Data::FileOriginUserPhoto(peerToUser(_user->id), _photo->id);
|
return Data::FileOriginUserPhoto(peerToUser(_user->id), _photo->id);
|
||||||
|
@ -2828,15 +2830,15 @@ void OverlayWidget::refreshFromLabel() {
|
||||||
void OverlayWidget::refreshCaption() {
|
void OverlayWidget::refreshCaption() {
|
||||||
_caption = Ui::Text::String();
|
_caption = Ui::Text::String();
|
||||||
const auto caption = [&] {
|
const auto caption = [&] {
|
||||||
if (_message) {
|
if (_stories) {
|
||||||
|
return _stories->captionText();
|
||||||
|
} else if (_message) {
|
||||||
if (const auto media = _message->media()) {
|
if (const auto media = _message->media()) {
|
||||||
if (media->webpage()) {
|
if (media->webpage()) {
|
||||||
return TextWithEntities();
|
return TextWithEntities();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return _message->translatedText();
|
return _message->translatedText();
|
||||||
} else if (_stories) {
|
|
||||||
return _stories->captionText();
|
|
||||||
}
|
}
|
||||||
return TextWithEntities();
|
return TextWithEntities();
|
||||||
}();
|
}();
|
||||||
|
|
Loading…
Add table
Reference in a new issue