Ask the browser properly whether it can preview a PDF

8086beb6c2
This commit is contained in:
the-djmaze 2026-11-02 18:16:40 +01:00
parent 9b17dd7d41
commit 1246a455f3

View file

@ -104,7 +104,18 @@ export class AttachmentModel extends AbstractModel {
* @returns {boolean}
*/
pdfPreview() {
return null != navigator.mimeTypes['application/pdf'] && FileType.Pdf === this.fileType;
/**
* navigator.pdfViewerEnabled is the supported way to ask this.
* navigator.mimeTypes is deprecated and browsers now expose a PDF entry
* there only while the built in viewer is on, so the old check quietly
* returned false in cases where a preview would have worked and took
* the eye badge with it.
*/
return FileType.Pdf === this.fileType
&& (undefined !== navigator.pdfViewerEnabled
? navigator.pdfViewerEnabled
: null != navigator.mimeTypes['application/pdf']
);
}
/**