Skip to content

Commit

Permalink
Fix android support
Browse files Browse the repository at this point in the history
Android was failing because browser context menus are not supported.
It works otherwise.

I think some following updates should be made to make the UI more
responsive/mobile friendly.
  • Loading branch information
PixeLInc committed Dec 20, 2024
1 parent 51e4f7d commit 3a6e81b
Showing 1 changed file with 25 additions and 22 deletions.
47 changes: 25 additions & 22 deletions shared/src/background.js
Original file line number Diff line number Diff line change
Expand Up @@ -265,28 +265,31 @@ function kagiImageSearch(info) {
});
}

// Create a context menu item.
browser.contextMenus.create({
id: 'kagi-summarize',
title: 'Kagi Summarize',
contexts: ['link', 'page'], // Show the menu item when clicked on a link or elsewhere on page with no matching contexts
});
// FF Android does not support context menus
if (browser.contextMenus !== undefined) {
// Create a context menu item.
browser.contextMenus.create({
id: 'kagi-summarize',
title: 'Kagi Summarize',
contexts: ['link', 'page'], // Show the menu item when clicked on a link or elsewhere on page with no matching contexts
});

browser.contextMenus.create({
id: 'kagi-image-search',
title: 'Kagi Image Search',
contexts: ['image'],
});
browser.contextMenus.create({
id: 'kagi-image-search',
title: 'Kagi Image Search',
contexts: ['image'],
});

// Add a listener for the context menu item.
browser.contextMenus.onClicked.addListener(async (info, tab) => {
if (info.menuItemId === 'kagi-summarize') {
if (!IS_CHROME) {
// Attach permission request to user input handler for Firefox
await requestActiveTabPermission();
// Add a listener for the context menu item.
browser.contextMenus.onClicked.addListener(async (info, tab) => {
if (info.menuItemId === 'kagi-summarize') {
if (!IS_CHROME) {
// Attach permission request to user input handler for Firefox
await requestActiveTabPermission();
}
kagiSummarize(info, tab);
} else if (info.menuItemId === 'kagi-image-search') {
kagiImageSearch(info, tab);
}
kagiSummarize(info, tab);
} else if (info.menuItemId === 'kagi-image-search') {
kagiImageSearch(info, tab);
}
});
});
}

0 comments on commit 3a6e81b

Please sign in to comment.