Excluded self-destructing media from external media viewer.

Related commit: 154e45cb55.
This commit is contained in:
23rd
2026-09-04 06:01:35 +03:00
parent 893d5ea3df
commit 7d7fa972d6
2 changed files with 17 additions and 6 deletions

View File

@@ -142,6 +142,12 @@ base::options::toggle OptionExternalMediaViewer({
.description = "Use system media viewer instead of the internal one.",
});
[[nodiscard]] bool HasSavingRestriction(HistoryItem *item) {
return item
&& (item->forbidsSaving()
|| !item->history()->peer->allowsForwarding());
}
class MainWindowShow final : public ChatHelpers::Show {
public:
explicit MainWindowShow(not_null<SessionController*> controller);
@@ -3375,8 +3381,10 @@ void SessionController::hideLayer(anim::type animated) {
bool SessionController::openPhotoExternal(
not_null<PhotoData*> photo,
Data::FileOrigin origin) {
if (!OptionExternalMediaViewer.value()) {
Data::FileOrigin origin,
HistoryItem *item) {
if (!OptionExternalMediaViewer.value()
|| HasSavingRestriction(item)) {
return false;
}
const auto media = photo->createMediaView();
@@ -3415,7 +3423,7 @@ void SessionController::openPhoto(
const auto origin = item
? Data::FileOrigin(item->fullId())
: Data::FileOrigin();
if (openPhotoExternal(photo, origin)) {
if (openPhotoExternal(photo, origin, item)) {
return;
}
_window->openInMediaView(Media::View::OpenRequest(
@@ -3435,7 +3443,7 @@ void SessionController::openPhoto(
peerToUser(peer->id),
photo->id))
: Data::FileOrigin(Data::FileOriginPeerPhoto(peer->id));
if (openPhotoExternal(photo, origin)) {
if (openPhotoExternal(photo, origin, nullptr)) {
return;
}
_window->openInMediaView(Media::View::OpenRequest(this, photo, peer));
@@ -3451,7 +3459,9 @@ void SessionController::openDocument(
if (openSharedStory(item) || openFakeItemStory(message.id, stories)) {
return;
} else if (showInMediaView) {
if (OptionExternalMediaViewer.value() && !document->isTheme()) {
if (OptionExternalMediaViewer.value()
&& !document->isTheme()
&& !HasSavingRestriction(item)) {
const auto filepath = document->filepath();
if (filepath.isEmpty()) {
if (document->loadedInMediaCache()) {

View File

@@ -808,7 +808,8 @@ private:
[[nodiscard]] bool openPhotoExternal(
not_null<PhotoData*> photo,
Data::FileOrigin origin);
Data::FileOrigin origin,
HistoryItem *item);
void handleDrawToReplyRequest(Data::DrawToReplyRequest request);
[[nodiscard]] Data::Thread *resolveDrawToReplyThread(
const Data::DrawToReplyRequest &request) const;