parent
b3667d69a1
commit
2c75fe033c
|
@ -286,10 +286,6 @@ void ResolveDocument(
|
||||||
|| document->isVoiceMessage()
|
|| document->isVoiceMessage()
|
||||||
|| document->isVideoMessage()) {
|
|| document->isVideoMessage()) {
|
||||||
::Media::Player::instance()->playPause({ document, msgId });
|
::Media::Player::instance()->playPause({ document, msgId });
|
||||||
} else if (item
|
|
||||||
&& document->isAnimation()
|
|
||||||
&& HistoryView::Gif::CanPlayInline(document)) {
|
|
||||||
document->owner().requestAnimationPlayInline(item);
|
|
||||||
} else {
|
} else {
|
||||||
showDocument();
|
showDocument();
|
||||||
}
|
}
|
||||||
|
|
|
@ -1695,29 +1695,12 @@ void Session::requestItemTextRefresh(not_null<HistoryItem*> item) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Session::requestAnimationPlayInline(not_null<HistoryItem*> item) {
|
|
||||||
_animationPlayInlineRequest.fire_copy(item);
|
|
||||||
|
|
||||||
if (const auto media = item->media()) {
|
|
||||||
if (const auto data = media->document()) {
|
|
||||||
if (data && data->isVideoMessage()) {
|
|
||||||
const auto msgId = item->fullId();
|
|
||||||
::Media::Player::instance()->playPause({ data, msgId });
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void Session::requestUnreadReactionsAnimation(not_null<HistoryItem*> item) {
|
void Session::requestUnreadReactionsAnimation(not_null<HistoryItem*> item) {
|
||||||
enumerateItemViews(item, [&](not_null<ViewElement*> view) {
|
enumerateItemViews(item, [&](not_null<ViewElement*> view) {
|
||||||
view->animateUnreadReactions();
|
view->animateUnreadReactions();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
rpl::producer<not_null<HistoryItem*>> Session::animationPlayInlineRequest() const {
|
|
||||||
return _animationPlayInlineRequest.events();
|
|
||||||
}
|
|
||||||
|
|
||||||
rpl::producer<not_null<const HistoryItem*>> Session::itemRemoved() const {
|
rpl::producer<not_null<const HistoryItem*>> Session::itemRemoved() const {
|
||||||
return _itemRemoved.events();
|
return _itemRemoved.events();
|
||||||
}
|
}
|
||||||
|
|
|
@ -275,9 +275,7 @@ public:
|
||||||
void requestItemViewRefresh(not_null<HistoryItem*> item);
|
void requestItemViewRefresh(not_null<HistoryItem*> item);
|
||||||
[[nodiscard]] rpl::producer<not_null<HistoryItem*>> itemViewRefreshRequest() const;
|
[[nodiscard]] rpl::producer<not_null<HistoryItem*>> itemViewRefreshRequest() const;
|
||||||
void requestItemTextRefresh(not_null<HistoryItem*> item);
|
void requestItemTextRefresh(not_null<HistoryItem*> item);
|
||||||
void requestAnimationPlayInline(not_null<HistoryItem*> item);
|
|
||||||
void requestUnreadReactionsAnimation(not_null<HistoryItem*> item);
|
void requestUnreadReactionsAnimation(not_null<HistoryItem*> item);
|
||||||
[[nodiscard]] rpl::producer<not_null<HistoryItem*>> animationPlayInlineRequest() const;
|
|
||||||
void notifyHistoryUnloaded(not_null<const History*> history);
|
void notifyHistoryUnloaded(not_null<const History*> history);
|
||||||
[[nodiscard]] rpl::producer<not_null<const History*>> historyUnloaded() const;
|
[[nodiscard]] rpl::producer<not_null<const History*>> historyUnloaded() const;
|
||||||
void notifyItemDataChange(not_null<HistoryItem*> item);
|
void notifyItemDataChange(not_null<HistoryItem*> item);
|
||||||
|
@ -861,7 +859,6 @@ private:
|
||||||
rpl::event_stream<not_null<HistoryItem*>> _itemViewRefreshRequest;
|
rpl::event_stream<not_null<HistoryItem*>> _itemViewRefreshRequest;
|
||||||
rpl::event_stream<not_null<HistoryItem*>> _itemTextRefreshRequest;
|
rpl::event_stream<not_null<HistoryItem*>> _itemTextRefreshRequest;
|
||||||
rpl::event_stream<not_null<HistoryItem*>> _itemDataChanges;
|
rpl::event_stream<not_null<HistoryItem*>> _itemDataChanges;
|
||||||
rpl::event_stream<not_null<HistoryItem*>> _animationPlayInlineRequest;
|
|
||||||
rpl::event_stream<not_null<const HistoryItem*>> _itemRemoved;
|
rpl::event_stream<not_null<const HistoryItem*>> _itemRemoved;
|
||||||
rpl::event_stream<not_null<const ViewElement*>> _viewRemoved;
|
rpl::event_stream<not_null<const ViewElement*>> _viewRemoved;
|
||||||
rpl::event_stream<not_null<const History*>> _historyUnloaded;
|
rpl::event_stream<not_null<const History*>> _historyUnloaded;
|
||||||
|
|
|
@ -294,14 +294,6 @@ InnerWidget::InnerWidget(
|
||||||
view->itemDataChanged();
|
view->itemDataChanged();
|
||||||
}
|
}
|
||||||
}, lifetime());
|
}, lifetime());
|
||||||
session().data().animationPlayInlineRequest(
|
|
||||||
) | rpl::start_with_next([=](auto item) {
|
|
||||||
if (const auto view = viewForItem(item)) {
|
|
||||||
if (const auto media = view->media()) {
|
|
||||||
media->playAnimation();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}, lifetime());
|
|
||||||
session().data().itemVisibilityQueries(
|
session().data().itemVisibilityQueries(
|
||||||
) | rpl::filter([=](
|
) | rpl::filter([=](
|
||||||
const Data::Session::ItemVisibilityQuery &query) {
|
const Data::Session::ItemVisibilityQuery &query) {
|
||||||
|
|
|
@ -553,15 +553,6 @@ HistoryWidget::HistoryWidget(
|
||||||
});
|
});
|
||||||
}, lifetime());
|
}, lifetime());
|
||||||
|
|
||||||
session().data().animationPlayInlineRequest(
|
|
||||||
) | rpl::start_with_next([=](not_null<HistoryItem*> item) {
|
|
||||||
if (const auto view = item->mainView()) {
|
|
||||||
if (const auto media = view->media()) {
|
|
||||||
media->playAnimation();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}, lifetime());
|
|
||||||
|
|
||||||
session().data().webPageUpdates(
|
session().data().webPageUpdates(
|
||||||
) | rpl::filter([=](not_null<WebPageData*> page) {
|
) | rpl::filter([=](not_null<WebPageData*> page) {
|
||||||
return (_previewData == page.get());
|
return (_previewData == page.get());
|
||||||
|
|
|
@ -341,14 +341,6 @@ ListWidget::ListWidget(
|
||||||
view->itemDataChanged();
|
view->itemDataChanged();
|
||||||
}
|
}
|
||||||
}, lifetime());
|
}, lifetime());
|
||||||
session().data().animationPlayInlineRequest(
|
|
||||||
) | rpl::start_with_next([this](auto item) {
|
|
||||||
if (const auto view = viewForItem(item)) {
|
|
||||||
if (const auto media = view->media()) {
|
|
||||||
media->playAnimation();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}, lifetime());
|
|
||||||
|
|
||||||
session().downloaderTaskFinished(
|
session().downloaderTaskFinished(
|
||||||
) | rpl::start_with_next([=] {
|
) | rpl::start_with_next([=] {
|
||||||
|
|
|
@ -117,13 +117,16 @@ void File::checkAnimationFinished() const {
|
||||||
}
|
}
|
||||||
void File::setDocumentLinks(
|
void File::setDocumentLinks(
|
||||||
not_null<DocumentData*> document,
|
not_null<DocumentData*> document,
|
||||||
not_null<HistoryItem*> realParent) {
|
not_null<HistoryItem*> realParent,
|
||||||
|
Fn<bool()> openHook) {
|
||||||
const auto context = realParent->fullId();
|
const auto context = realParent->fullId();
|
||||||
setLinks(
|
setLinks(
|
||||||
std::make_shared<DocumentOpenClickHandler>(
|
std::make_shared<DocumentOpenClickHandler>(
|
||||||
document,
|
document,
|
||||||
crl::guard(this, [=](FullMsgId id) {
|
crl::guard(this, [=](FullMsgId id) {
|
||||||
_parent->delegate()->elementOpenDocument(document, id);
|
if (!openHook || !openHook()) {
|
||||||
|
_parent->delegate()->elementOpenDocument(document, id);
|
||||||
|
}
|
||||||
}),
|
}),
|
||||||
context),
|
context),
|
||||||
std::make_shared<DocumentSaveClickHandler>(document, context),
|
std::make_shared<DocumentSaveClickHandler>(document, context),
|
||||||
|
|
|
@ -52,7 +52,8 @@ protected:
|
||||||
FileClickHandlerPtr &&cancell);
|
FileClickHandlerPtr &&cancell);
|
||||||
void setDocumentLinks(
|
void setDocumentLinks(
|
||||||
not_null<DocumentData*> document,
|
not_null<DocumentData*> document,
|
||||||
not_null<HistoryItem*> realParent);
|
not_null<HistoryItem*> realParent,
|
||||||
|
Fn<bool()> openHook = nullptr);
|
||||||
|
|
||||||
// >= 0 will contain download / upload string, _statusSize = loaded bytes
|
// >= 0 will contain download / upload string, _statusSize = loaded bytes
|
||||||
// < 0 will contain played string, _statusSize = -(seconds + 1) played
|
// < 0 will contain played string, _statusSize = -(seconds + 1) played
|
||||||
|
|
|
@ -89,7 +89,15 @@ Gif::Gif(
|
||||||
, _caption(st::minPhotoSize - st::msgPadding.left() - st::msgPadding.right())
|
, _caption(st::minPhotoSize - st::msgPadding.left() - st::msgPadding.right())
|
||||||
, _spoiler(spoiler ? std::make_unique<MediaSpoiler>() : nullptr)
|
, _spoiler(spoiler ? std::make_unique<MediaSpoiler>() : nullptr)
|
||||||
, _downloadSize(Ui::FormatSizeText(_data->size)) {
|
, _downloadSize(Ui::FormatSizeText(_data->size)) {
|
||||||
setDocumentLinks(_data, realParent);
|
setDocumentLinks(_data, realParent, [=] {
|
||||||
|
if (!_data->createMediaView()->canBePlayed(realParent)
|
||||||
|
|| !_data->isAnimation()
|
||||||
|
|| !CanPlayInline(_data)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
playAnimation(false);
|
||||||
|
return true;
|
||||||
|
});
|
||||||
setStatusSize(Ui::FileStatusSizeReady);
|
setStatusSize(Ui::FileStatusSizeReady);
|
||||||
|
|
||||||
if (_spoiler) {
|
if (_spoiler) {
|
||||||
|
|
Loading…
Reference in New Issue