mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +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) {
|
bool IsItemGoodForType(const not_null<HistoryItem*> item, Type type) {
|
||||||
const auto media = item->media();
|
const auto media = item->media();
|
||||||
if (!media) {
|
if (!media || media->webpage()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
const auto photo = media->photo();
|
const auto photo = media->photo();
|
||||||
const auto photoType = (type == Type::Photo);
|
const auto photoType = (type == Type::Photo);
|
||||||
if (photoType && photo) {
|
const auto photoVideoType = (type == Type::PhotoVideo);
|
||||||
|
if ((photoType || photoVideoType) && photo) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -47,10 +48,11 @@ bool IsItemGoodForType(const not_null<HistoryItem*> item, Type type) {
|
||||||
if (!document) {
|
if (!document) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
const auto voiceType = (type == Type::VoiceFile)
|
const auto voiceType = (type == Type::VoiceFile);
|
||||||
|| (type == Type::RoundVoiceFile);
|
const auto voiceDoc = document->isVoiceMessage();
|
||||||
const auto voiceDoc = (document->isVoiceMessage()
|
|
||||||
|| document->isVideoMessage());
|
const auto roundType = (type == Type::RoundFile);
|
||||||
|
const auto roundDoc = document->isVideoMessage();
|
||||||
|
|
||||||
const auto audioType = (type == Type::MusicFile);
|
const auto audioType = (type == Type::MusicFile);
|
||||||
const auto audioDoc = document->isAudioFile();
|
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 videoType = (type == Type::Video);
|
||||||
const auto videoDoc = document->isVideoFile();
|
const auto videoDoc = document->isVideoFile();
|
||||||
|
|
||||||
|
const auto voiceRoundType = (type == Type::RoundVoiceFile);
|
||||||
|
const auto fileType = (type == Type::File);
|
||||||
|
|
||||||
return (audioType && audioDoc)
|
return (audioType && audioDoc)
|
||||||
|| (voiceType && voiceDoc)
|
|| (voiceType && voiceDoc)
|
||||||
|
|| (roundType && roundDoc)
|
||||||
|
|| (voiceRoundType && (roundDoc || voiceDoc))
|
||||||
|| (gifType && gifDoc)
|
|| (gifType && gifDoc)
|
||||||
|| (videoType && videoDoc)
|
|| ((videoType || photoVideoType) && videoDoc)
|
||||||
|| (photoType && document->isImage());
|
|| (fileType && (document->isTheme()
|
||||||
|
|| document->isImage()
|
||||||
|
|| !document->canBeStreamed()));
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
@ -461,12 +470,29 @@ rpl::producer<SharedMediaWithLastSlice> SharedMediaWithLastViewer(
|
||||||
int limitBefore,
|
int limitBefore,
|
||||||
int limitAfter) {
|
int limitAfter) {
|
||||||
return [=](auto consumer) {
|
return [=](auto consumer) {
|
||||||
|
auto viewerKey = SharedMediaMergedKey(
|
||||||
|
SharedMediaWithLastSlice::ViewerKey(key),
|
||||||
|
key.type);
|
||||||
|
|
||||||
if (std::get_if<not_null<PhotoData*>>(&key.universalId)) {
|
if (std::get_if<not_null<PhotoData*>>(&key.universalId)) {
|
||||||
return SharedMediaMergedViewer(
|
return SharedMediaMergedViewer(
|
||||||
session,
|
session,
|
||||||
SharedMediaMergedKey(
|
std::move(viewerKey),
|
||||||
SharedMediaWithLastSlice::ViewerKey(key),
|
limitBefore,
|
||||||
key.type),
|
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,
|
limitBefore,
|
||||||
limitAfter
|
limitAfter
|
||||||
) | rpl::start_with_next([=](SparseIdsMergedSlice &&update) {
|
) | rpl::start_with_next([=](SparseIdsMergedSlice &&update) {
|
||||||
|
@ -480,9 +506,7 @@ rpl::producer<SharedMediaWithLastSlice> SharedMediaWithLastViewer(
|
||||||
return rpl::combine(
|
return rpl::combine(
|
||||||
SharedMediaMergedViewer(
|
SharedMediaMergedViewer(
|
||||||
session,
|
session,
|
||||||
SharedMediaMergedKey(
|
std::move(viewerKey),
|
||||||
SharedMediaWithLastSlice::ViewerKey(key),
|
|
||||||
key.type),
|
|
||||||
limitBefore,
|
limitBefore,
|
||||||
limitAfter),
|
limitAfter),
|
||||||
SharedMediaMergedViewer(
|
SharedMediaMergedViewer(
|
||||||
|
|
|
@ -77,11 +77,13 @@ public:
|
||||||
PeerId peerId,
|
PeerId peerId,
|
||||||
PeerId migratedPeerId,
|
PeerId migratedPeerId,
|
||||||
Type type,
|
Type type,
|
||||||
UniversalMsgId universalId)
|
UniversalMsgId universalId,
|
||||||
|
bool scheduled = false)
|
||||||
: peerId(peerId)
|
: peerId(peerId)
|
||||||
, migratedPeerId(migratedPeerId)
|
, migratedPeerId(migratedPeerId)
|
||||||
, type(type)
|
, type(type)
|
||||||
, universalId(universalId) {
|
, universalId(universalId)
|
||||||
|
, scheduled(scheduled) {
|
||||||
Expects(v::is<MessageId>(universalId) || type == Type::ChatPhoto);
|
Expects(v::is<MessageId>(universalId) || type == Type::ChatPhoto);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -99,6 +101,7 @@ public:
|
||||||
PeerId migratedPeerId = 0;
|
PeerId migratedPeerId = 0;
|
||||||
Type type = Type::kCount;
|
Type type = Type::kCount;
|
||||||
UniversalMsgId universalId;
|
UniversalMsgId universalId;
|
||||||
|
bool scheduled = false;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -1822,19 +1822,31 @@ auto OverlayWidget::sharedMediaKey() const -> std::optional<SharedMediaKey> {
|
||||||
_photo
|
_photo
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
if (!IsServerMsgId(_msgid.msg)) {
|
const auto isServerMsgId = IsServerMsgId(_msgid.msg);
|
||||||
return std::nullopt;
|
const auto isScheduled = [&] {
|
||||||
}
|
if (isServerMsgId) {
|
||||||
auto keyForType = [this](SharedMediaType type) -> SharedMediaKey {
|
return false;
|
||||||
|
}
|
||||||
|
if (const auto item = _session->data().message(_msgid)) {
|
||||||
|
return item->isScheduled();
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}();
|
||||||
|
const auto keyForType = [&](SharedMediaType type) -> SharedMediaKey {
|
||||||
return {
|
return {
|
||||||
_history->peer->id,
|
_history->peer->id,
|
||||||
_migrated ? _migrated->peer->id : 0,
|
_migrated ? _migrated->peer->id : 0,
|
||||||
type,
|
type,
|
||||||
(_msgid.channel == _history->channelId()) ? _msgid.msg : (_msgid.msg - ServerMaxMsgId) };
|
(_msgid.channel == _history->channelId())
|
||||||
|
? _msgid.msg
|
||||||
|
: (_msgid.msg - ServerMaxMsgId),
|
||||||
|
isScheduled
|
||||||
|
};
|
||||||
};
|
};
|
||||||
return
|
if (!isServerMsgId && !isScheduled) {
|
||||||
sharedMediaType()
|
return std::nullopt;
|
||||||
| keyForType;
|
}
|
||||||
|
return sharedMediaType() | keyForType;
|
||||||
}
|
}
|
||||||
|
|
||||||
Data::FileOrigin OverlayWidget::fileOrigin() const {
|
Data::FileOrigin OverlayWidget::fileOrigin() const {
|
||||||
|
@ -1872,7 +1884,8 @@ bool OverlayWidget::validSharedMedia() const {
|
||||||
auto inSameDomain = [](const Key &a, const Key &b) {
|
auto inSameDomain = [](const Key &a, const Key &b) {
|
||||||
return (a.type == b.type)
|
return (a.type == b.type)
|
||||||
&& (a.peerId == b.peerId)
|
&& (a.peerId == b.peerId)
|
||||||
&& (a.migratedPeerId == b.migratedPeerId);
|
&& (a.migratedPeerId == b.migratedPeerId)
|
||||||
|
&& (a.scheduled == b.scheduled);
|
||||||
};
|
};
|
||||||
auto countDistanceInData = [&](const Key &a, const Key &b) {
|
auto countDistanceInData = [&](const Key &a, const Key &b) {
|
||||||
return [&](const SharedMediaWithLastSlice &data) {
|
return [&](const SharedMediaWithLastSlice &data) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue