1
0
Fork 0
mirror of https://github.com/miniflux/v2.git synced 2025-06-27 16:36:00 +00:00

fix: deal with navigator.share exceptions

Navigator.share returns a promise that's executed in the background, but
unless we await it explicitly, we won't get the exceptions in the
try/catch block.
This commit is contained in:
Tali Auster 2025-03-30 20:09:09 -07:00
parent 41a5ef8579
commit 9c99efa153

View file

@ -719,11 +719,11 @@ function isPlayerPlaying(element) {
/**
* handle new share entires and already shared entries
*/
function handleShare() {
async function handleShare() {
const link = document.querySelector(':is(a, button)[data-share-status]');
const title = document.querySelector(".entry-header > h1 > a");
if (link.dataset.shareStatus === "shared") {
checkShareAPI(title, link.href);
await checkShareAPI(title, link.href);
}
if (link.dataset.shareStatus === "share") {
const request = new RequestBuilder(link.href);
@ -738,14 +738,14 @@ function handleShare() {
/**
* wrapper for Web Share API
*/
function checkShareAPI(title, url) {
async function checkShareAPI(title, url) {
if (!navigator.canShare) {
console.error("Your browser doesn't support the Web Share API.");
window.location = url;
return;
}
try {
navigator.share({
await navigator.share({
title: title ? title.textContent : url,
url: url
});