Skip to content

Commit

Permalink
fix: update image sharing
Browse files Browse the repository at this point in the history
  • Loading branch information
dessant committed Oct 23, 2023
1 parent caefb90 commit ae19e2c
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 13 deletions.
5 changes: 3 additions & 2 deletions src/background/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -819,7 +819,7 @@ async function searchClickTarget(session) {
async function handleParseResults(session, images) {
if (!images.length) {
await showNotification({messageId: 'error_imageNotFound'});
} else if (images.length > 1) {
} else if (images.length > 1 || images[0].mustConfirm) {
await openContentView({session, images}, 'confirm');
} else {
if (session.sessionType === 'search') {
Expand Down Expand Up @@ -1193,7 +1193,8 @@ async function processMessage(request, sender) {
} else if (request.id === 'pageParseSubmit') {
if (
request.session.sessionOrigin === 'action' &&
request.images.length <= 1
request.images.length <= 1 &&
!request.images[0]?.mustConfirm
) {
browser.tabs.sendMessage(
sender.tab.id,
Expand Down
1 change: 1 addition & 0 deletions src/content/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ function addViewFrame() {
shadowRoot.appendChild(css);

const viewFrame = document.createElement('iframe');
viewFrame.setAttribute('allow', 'web-share');
viewFrame.classList.add('hidden');

css.addEventListener(
Expand Down
29 changes: 18 additions & 11 deletions src/parse/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -402,18 +402,25 @@ self.initParse = async function (session) {
const images = await parse(session);

if (session.sessionType === 'share' && images.length === 1) {
await shareImage(images[0], {
convert: session.options.convertSharedImage
});
} else {
await sendLargeMessage({
message: {
id: 'pageParseSubmit',
images,
session
}
});
// Safari 17: transient activation does not always propagate to
// the content script context, navigator.userActivation.isActive is false.
if (targetEnv === 'safari') {
images[0].mustConfirm = true;
} else {
await shareImage(images[0], {
convert: session.options.convertSharedImage
});
return;
}
}

await sendLargeMessage({
message: {
id: 'pageParseSubmit',
images,
session
}
});
} catch (err) {
console.log(err.toString());

Expand Down

0 comments on commit ae19e2c

Please sign in to comment.