mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-04-17 22:57:11 +02:00
Update API scheme. Shared posts in stories.
This commit is contained in:
parent
94e8f2a791
commit
60e72768e1
7 changed files with 68 additions and 13 deletions
|
@ -741,7 +741,8 @@ void ExportTestChatTheme(
|
|||
MTP_int(color(bg.size() > 2 ? bg[2] : Qt::black)),
|
||||
MTP_int(color(bg.size() > 3 ? bg[3] : Qt::black)),
|
||||
MTP_int(fields.paper->patternIntensity()),
|
||||
MTP_int(0)));
|
||||
MTP_int(0), // rotation
|
||||
MTPstring())); // emoticon
|
||||
};
|
||||
const auto light = inputSettings(Data::CloudThemeType::Light);
|
||||
if (!light) {
|
||||
|
|
|
@ -633,6 +633,10 @@ const std::vector<SuggestedReaction> &Story::suggestedReactions() const {
|
|||
return _suggestedReactions;
|
||||
}
|
||||
|
||||
const std::vector<ChannelPost> &Story::channelPosts() const {
|
||||
return _channelPosts;
|
||||
}
|
||||
|
||||
void Story::applyChanges(
|
||||
StoryMedia media,
|
||||
const MTPDstoryItem &data,
|
||||
|
@ -735,9 +739,8 @@ void Story::applyFields(
|
|||
}
|
||||
auto locations = std::vector<StoryLocation>();
|
||||
auto suggestedReactions = std::vector<SuggestedReaction>();
|
||||
auto channelPosts = std::vector<ChannelPost>();
|
||||
if (const auto areas = data.vmedia_areas()) {
|
||||
locations.reserve(areas->v.size());
|
||||
suggestedReactions.reserve(areas->v.size());
|
||||
for (const auto &area : areas->v) {
|
||||
if (const auto location = ParseLocation(area)) {
|
||||
locations.push_back(*location);
|
||||
|
@ -748,6 +751,8 @@ void Story::applyFields(
|
|||
reaction->count = i->second;
|
||||
}
|
||||
suggestedReactions.push_back(*reaction);
|
||||
} else if (auto post = ParseChannelPost(area)) {
|
||||
channelPosts.push_back(*post);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -759,6 +764,7 @@ void Story::applyFields(
|
|||
const auto locationsChanged = (_locations != locations);
|
||||
const auto suggestedReactionsChanged
|
||||
= (_suggestedReactions != suggestedReactions);
|
||||
const auto channelPostsChanged = (_channelPosts != channelPosts);
|
||||
const auto reactionChanged = (_sentReactionId != reaction);
|
||||
|
||||
_out = out;
|
||||
|
@ -781,6 +787,9 @@ void Story::applyFields(
|
|||
if (suggestedReactionsChanged) {
|
||||
_suggestedReactions = std::move(suggestedReactions);
|
||||
}
|
||||
if (channelPostsChanged) {
|
||||
_channelPosts = std::move(channelPosts);
|
||||
}
|
||||
if (reactionChanged) {
|
||||
_sentReactionId = reaction;
|
||||
}
|
||||
|
@ -789,7 +798,8 @@ void Story::applyFields(
|
|||
const auto changed = editedChanged
|
||||
|| captionChanged
|
||||
|| mediaChanged
|
||||
|| locationsChanged;
|
||||
|| locationsChanged
|
||||
|| channelPostsChanged;
|
||||
const auto reactionsChanged = reactionChanged
|
||||
|| suggestedReactionsChanged;
|
||||
if (!initial && (changed || reactionsChanged)) {
|
||||
|
|
|
@ -192,6 +192,8 @@ public:
|
|||
[[nodiscard]] const std::vector<StoryLocation> &locations() const;
|
||||
[[nodiscard]] auto suggestedReactions() const
|
||||
-> const std::vector<SuggestedReaction> &;
|
||||
[[nodiscard]] auto channelPosts() const
|
||||
-> const std::vector<ChannelPost> &;
|
||||
|
||||
void applyChanges(
|
||||
StoryMedia media,
|
||||
|
@ -238,6 +240,7 @@ private:
|
|||
std::vector<not_null<PeerData*>> _recentViewers;
|
||||
std::vector<StoryLocation> _locations;
|
||||
std::vector<SuggestedReaction> _suggestedReactions;
|
||||
std::vector<ChannelPost> _channelPosts;
|
||||
StoryViews _views;
|
||||
StoryViews _channelReactions;
|
||||
const TimeId _date = 0;
|
||||
|
|
|
@ -371,7 +371,8 @@ MTPWallPaperSettings WallPaper::mtpSettings() const {
|
|||
serializeForIndex(2),
|
||||
serializeForIndex(3),
|
||||
MTP_int(_intensity),
|
||||
MTP_int(_rotation));
|
||||
MTP_int(_rotation),
|
||||
MTPstring()); // emoticon
|
||||
}
|
||||
|
||||
WallPaper WallPaper::withUrlParams(
|
||||
|
|
|
@ -119,6 +119,25 @@ struct SameDayRange {
|
|||
int(base::SafeRound(asin * point.x() + acos * point.y())));
|
||||
}
|
||||
|
||||
[[nodiscard]] ClickHandlerPtr MakeChannelPostHandler(
|
||||
not_null<Main::Session*> session,
|
||||
FullMsgId item) {
|
||||
return std::make_shared<LambdaClickHandler>(crl::guard(session, [=] {
|
||||
const auto peer = session->data().peer(item.peer);
|
||||
if (const auto window = Core::App().windowFor(peer)) {
|
||||
if (const auto controller = window->sessionController()) {
|
||||
if (&controller->session() == &peer->session()) {
|
||||
Core::App().hideMediaView();
|
||||
controller->showPeerHistory(
|
||||
item.peer,
|
||||
Window::SectionShow::Way::ClearStack,
|
||||
item.msg);
|
||||
}
|
||||
}
|
||||
}
|
||||
}));
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
class Controller::PhotoPlayback final {
|
||||
|
@ -1024,10 +1043,17 @@ void Controller::updateAreas(Data::Story *story) {
|
|||
const auto &suggestedReactions = story
|
||||
? story->suggestedReactions()
|
||||
: std::vector<Data::SuggestedReaction>();
|
||||
const auto &channelPosts = story
|
||||
? story->channelPosts()
|
||||
: std::vector<Data::ChannelPost>();
|
||||
if (_locations != locations) {
|
||||
_locations = locations;
|
||||
_areas.clear();
|
||||
}
|
||||
if (_channelPosts != channelPosts) {
|
||||
_channelPosts = channelPosts;
|
||||
_areas.clear();
|
||||
}
|
||||
const auto reactionsCount = int(suggestedReactions.size());
|
||||
if (_suggestedReactions.size() == reactionsCount && !_areas.empty()) {
|
||||
for (auto i = 0; i != reactionsCount; ++i) {
|
||||
|
@ -1046,10 +1072,6 @@ void Controller::updateAreas(Data::Story *story) {
|
|||
_suggestedReactions = suggestedReactions;
|
||||
_areas.clear();
|
||||
}
|
||||
if (_areas.empty() || _suggestedReactions.empty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
PauseState Controller::pauseState() const {
|
||||
|
@ -1172,10 +1194,16 @@ void Controller::updatePlayback(const Player::TrackState &state) {
|
|||
|
||||
ClickHandlerPtr Controller::lookupAreaHandler(QPoint point) const {
|
||||
const auto &layout = _layout.current();
|
||||
if ((_locations.empty() && _suggestedReactions.empty()) || !layout) {
|
||||
if (!layout
|
||||
|| (_locations.empty()
|
||||
&& _suggestedReactions.empty()
|
||||
&& _channelPosts.empty())) {
|
||||
return nullptr;
|
||||
} else if (_areas.empty()) {
|
||||
_areas.reserve(_locations.size() + _suggestedReactions.size());
|
||||
const auto now = story();
|
||||
_areas.reserve(_locations.size()
|
||||
+ _suggestedReactions.size()
|
||||
+ _channelPosts.size());
|
||||
for (const auto &location : _locations) {
|
||||
_areas.push_back({
|
||||
.original = location.area.geometry,
|
||||
|
@ -1205,6 +1233,17 @@ ClickHandlerPtr Controller::lookupAreaHandler(QPoint point) const {
|
|||
.reaction = std::move(widget),
|
||||
});
|
||||
}
|
||||
if (const auto session = now ? &now->session() : nullptr) {
|
||||
for (const auto &channelPost : _channelPosts) {
|
||||
_areas.push_back({
|
||||
.original = channelPost.area.geometry,
|
||||
.rotation = channelPost.area.rotation,
|
||||
.handler = MakeChannelPostHandler(
|
||||
session,
|
||||
channelPost.itemId),
|
||||
});
|
||||
}
|
||||
}
|
||||
rebuildActiveAreas(*layout);
|
||||
}
|
||||
|
||||
|
|
|
@ -302,6 +302,7 @@ private:
|
|||
|
||||
std::vector<Data::StoryLocation> _locations;
|
||||
std::vector<Data::SuggestedReaction> _suggestedReactions;
|
||||
std::vector<Data::ChannelPost> _channelPosts;
|
||||
mutable std::vector<ActiveArea> _areas;
|
||||
|
||||
std::vector<CachedSource> _cachedSourcesList;
|
||||
|
|
|
@ -1152,7 +1152,7 @@ account.wallPapers#cdc3858c hash:long wallpapers:Vector<WallPaper> = account.Wal
|
|||
|
||||
codeSettings#ad253d78 flags:# allow_flashcall:flags.0?true current_number:flags.1?true allow_app_hash:flags.4?true allow_missed_call:flags.5?true allow_firebase:flags.7?true logout_tokens:flags.6?Vector<bytes> token:flags.8?string app_sandbox:flags.8?Bool = CodeSettings;
|
||||
|
||||
wallPaperSettings#1dc1bca4 flags:# blur:flags.1?true motion:flags.2?true background_color:flags.0?int second_background_color:flags.4?int third_background_color:flags.5?int fourth_background_color:flags.6?int intensity:flags.3?int rotation:flags.4?int = WallPaperSettings;
|
||||
wallPaperSettings#372efcd0 flags:# blur:flags.1?true motion:flags.2?true background_color:flags.0?int second_background_color:flags.4?int third_background_color:flags.5?int fourth_background_color:flags.6?int intensity:flags.3?int rotation:flags.4?int emoticon:flags.7?string = WallPaperSettings;
|
||||
|
||||
autoDownloadSettings#baa57628 flags:# disabled:flags.0?true video_preload_large:flags.1?true audio_preload_next:flags.2?true phonecalls_less_data:flags.3?true stories_preload:flags.4?true photo_size_max:int video_size_max:long file_size_max:long video_upload_maxbitrate:int small_queue_active_operations_max:int large_queue_active_operations_max:int = AutoDownloadSettings;
|
||||
|
||||
|
@ -1623,7 +1623,7 @@ peerColor#b54b5acf flags:# color:flags.0?int background_emoji_id:flags.1?long =
|
|||
help.peerColorSet#26219a58 colors:Vector<int> = help.PeerColorSet;
|
||||
help.peerColorProfileSet#767d61eb palette_colors:Vector<int> bg_colors:Vector<int> story_colors:Vector<int> = help.PeerColorSet;
|
||||
|
||||
help.peerColorOption#135bd42f flags:# hidden:flags.0?true color_id:int colors:flags.1?help.PeerColorSet dark_colors:flags.2?help.PeerColorSet = help.PeerColorOption;
|
||||
help.peerColorOption#ef8430ab flags:# hidden:flags.0?true color_id:int colors:flags.1?help.PeerColorSet dark_colors:flags.2?help.PeerColorSet channel_min_level:flags.3?int = help.PeerColorOption;
|
||||
|
||||
help.peerColorsNotModified#2ba1f5ce = help.PeerColors;
|
||||
help.peerColors#f8ed08 hash:int colors:Vector<help.PeerColorOption> = help.PeerColors;
|
||||
|
|
Loading…
Add table
Reference in a new issue