mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-04-18 23:27:09 +02:00
Added ability to scroll media in section of scheduled messages.
Fixed #8388.
This commit is contained in:
parent
4753a57091
commit
348cf4829c
3 changed files with 65 additions and 25 deletions
|
@ -34,12 +34,13 @@ using Type = Storage::SharedMediaType;
|
|||
|
||||
bool IsItemGoodForType(const not_null<HistoryItem*> item, Type type) {
|
||||
const auto media = item->media();
|
||||
if (!media) {
|
||||
if (!media || media->webpage()) {
|
||||
return false;
|
||||
}
|
||||
const auto photo = media->photo();
|
||||
const auto photoType = (type == Type::Photo);
|
||||
if (photoType && photo) {
|
||||
const auto photoVideoType = (type == Type::PhotoVideo);
|
||||
if ((photoType || photoVideoType) && photo) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -47,10 +48,11 @@ bool IsItemGoodForType(const not_null<HistoryItem*> item, Type type) {
|
|||
if (!document) {
|
||||
return false;
|
||||
}
|
||||
const auto voiceType = (type == Type::VoiceFile)
|
||||
|| (type == Type::RoundVoiceFile);
|
||||
const auto voiceDoc = (document->isVoiceMessage()
|
||||
|| document->isVideoMessage());
|
||||
const auto voiceType = (type == Type::VoiceFile);
|
||||
const auto voiceDoc = document->isVoiceMessage();
|
||||
|
||||
const auto roundType = (type == Type::RoundFile);
|
||||
const auto roundDoc = document->isVideoMessage();
|
||||
|
||||
const auto audioType = (type == Type::MusicFile);
|
||||
const auto audioDoc = document->isAudioFile();
|
||||
|
@ -61,11 +63,18 @@ bool IsItemGoodForType(const not_null<HistoryItem*> item, Type type) {
|
|||
const auto videoType = (type == Type::Video);
|
||||
const auto videoDoc = document->isVideoFile();
|
||||
|
||||
const auto voiceRoundType = (type == Type::RoundVoiceFile);
|
||||
const auto fileType = (type == Type::File);
|
||||
|
||||
return (audioType && audioDoc)
|
||||
|| (voiceType && voiceDoc)
|
||||
|| (roundType && roundDoc)
|
||||
|| (voiceRoundType && (roundDoc || voiceDoc))
|
||||
|| (gifType && gifDoc)
|
||||
|| (videoType && videoDoc)
|
||||
|| (photoType && document->isImage());
|
||||
|| ((videoType || photoVideoType) && videoDoc)
|
||||
|| (fileType && (document->isTheme()
|
||||
|| document->isImage()
|
||||
|| !document->canBeStreamed()));
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
@ -461,12 +470,29 @@ rpl::producer<SharedMediaWithLastSlice> SharedMediaWithLastViewer(
|
|||
int limitBefore,
|
||||
int limitAfter) {
|
||||
return [=](auto consumer) {
|
||||
auto viewerKey = SharedMediaMergedKey(
|
||||
SharedMediaWithLastSlice::ViewerKey(key),
|
||||
key.type);
|
||||
|
||||
if (std::get_if<not_null<PhotoData*>>(&key.universalId)) {
|
||||
return SharedMediaMergedViewer(
|
||||
session,
|
||||
SharedMediaMergedKey(
|
||||
SharedMediaWithLastSlice::ViewerKey(key),
|
||||
key.type),
|
||||
std::move(viewerKey),
|
||||
limitBefore,
|
||||
limitAfter
|
||||
) | rpl::start_with_next([=](SparseIdsMergedSlice &&update) {
|
||||
consumer.put_next(SharedMediaWithLastSlice(
|
||||
session,
|
||||
key,
|
||||
std::move(update),
|
||||
std::nullopt));
|
||||
});
|
||||
}
|
||||
|
||||
if (key.scheduled) {
|
||||
return SharedScheduledMediaViewer(
|
||||
session,
|
||||
std::move(viewerKey),
|
||||
limitBefore,
|
||||
limitAfter
|
||||
) | rpl::start_with_next([=](SparseIdsMergedSlice &&update) {
|
||||
|
@ -480,9 +506,7 @@ rpl::producer<SharedMediaWithLastSlice> SharedMediaWithLastViewer(
|
|||
return rpl::combine(
|
||||
SharedMediaMergedViewer(
|
||||
session,
|
||||
SharedMediaMergedKey(
|
||||
SharedMediaWithLastSlice::ViewerKey(key),
|
||||
key.type),
|
||||
std::move(viewerKey),
|
||||
limitBefore,
|
||||
limitAfter),
|
||||
SharedMediaMergedViewer(
|
||||
|
|
|
@ -77,11 +77,13 @@ public:
|
|||
PeerId peerId,
|
||||
PeerId migratedPeerId,
|
||||
Type type,
|
||||
UniversalMsgId universalId)
|
||||
UniversalMsgId universalId,
|
||||
bool scheduled = false)
|
||||
: peerId(peerId)
|
||||
, migratedPeerId(migratedPeerId)
|
||||
, type(type)
|
||||
, universalId(universalId) {
|
||||
, universalId(universalId)
|
||||
, scheduled(scheduled) {
|
||||
Expects(v::is<MessageId>(universalId) || type == Type::ChatPhoto);
|
||||
}
|
||||
|
||||
|
@ -99,6 +101,7 @@ public:
|
|||
PeerId migratedPeerId = 0;
|
||||
Type type = Type::kCount;
|
||||
UniversalMsgId universalId;
|
||||
bool scheduled = false;
|
||||
|
||||
};
|
||||
|
||||
|
|
|
@ -1822,19 +1822,31 @@ auto OverlayWidget::sharedMediaKey() const -> std::optional<SharedMediaKey> {
|
|||
_photo
|
||||
};
|
||||
}
|
||||
if (!IsServerMsgId(_msgid.msg)) {
|
||||
return std::nullopt;
|
||||
}
|
||||
auto keyForType = [this](SharedMediaType type) -> SharedMediaKey {
|
||||
const auto isServerMsgId = IsServerMsgId(_msgid.msg);
|
||||
const auto isScheduled = [&] {
|
||||
if (isServerMsgId) {
|
||||
return false;
|
||||
}
|
||||
if (const auto item = _session->data().message(_msgid)) {
|
||||
return item->isScheduled();
|
||||
}
|
||||
return false;
|
||||
}();
|
||||
const auto keyForType = [&](SharedMediaType type) -> SharedMediaKey {
|
||||
return {
|
||||
_history->peer->id,
|
||||
_migrated ? _migrated->peer->id : 0,
|
||||
type,
|
||||
(_msgid.channel == _history->channelId()) ? _msgid.msg : (_msgid.msg - ServerMaxMsgId) };
|
||||
(_msgid.channel == _history->channelId())
|
||||
? _msgid.msg
|
||||
: (_msgid.msg - ServerMaxMsgId),
|
||||
isScheduled
|
||||
};
|
||||
};
|
||||
return
|
||||
sharedMediaType()
|
||||
| keyForType;
|
||||
if (!isServerMsgId && !isScheduled) {
|
||||
return std::nullopt;
|
||||
}
|
||||
return sharedMediaType() | keyForType;
|
||||
}
|
||||
|
||||
Data::FileOrigin OverlayWidget::fileOrigin() const {
|
||||
|
@ -1872,7 +1884,8 @@ bool OverlayWidget::validSharedMedia() const {
|
|||
auto inSameDomain = [](const Key &a, const Key &b) {
|
||||
return (a.type == b.type)
|
||||
&& (a.peerId == b.peerId)
|
||||
&& (a.migratedPeerId == b.migratedPeerId);
|
||||
&& (a.migratedPeerId == b.migratedPeerId)
|
||||
&& (a.scheduled == b.scheduled);
|
||||
};
|
||||
auto countDistanceInData = [&](const Key &a, const Key &b) {
|
||||
return [&](const SharedMediaWithLastSlice &data) {
|
||||
|
|
Loading…
Add table
Reference in a new issue