Skip to content

Commit

Permalink
Fixes context menus disappearing—now more reliable
Browse files Browse the repository at this point in the history
  • Loading branch information
marlonjames71 committed Dec 15, 2024
1 parent 9f96066 commit 1971d39
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 14 deletions.
41 changes: 28 additions & 13 deletions NiceCopy for Safari/Resources/background.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,19 +61,34 @@ browser.commands.onCommand.addListener((command) => {

// CONTEXT MENUS

browser.runtime.onInstalled.addListener(() => {
browser.contextMenus.create({
id: "context_menu-copy_url",
title: "Copy Page URL",
contexts: ["page"],
});

browser.contextMenus.create({
id: "context_menu-open_app",
title: "Open NiceCopy App",
contexts: ["action"]
})
});
// Create context menus function
function createContextMenus() {
// Remove existing menus first to avoid duplicates
browser.contextMenus
.removeAll()
.then(() => {
browser.contextMenus.create({
id: "context_menu-copy_url",
title: "Copy Page URL",
contexts: ["page"],
});

browser.contextMenus.create({
id: "context_menu-open_app",
title: "Open NiceCopy App",
contexts: ["action"],
});
})
.catch((error) => {
console.error("Error creating context menus:", error);
});
}

// Create menus when extension starts
createContextMenus();

// Also create menus on installation (optional, but good practice)
browser.runtime.onInstalled.addListener(createContextMenus);

function onOpenAppResponse(response) {
console.log(`Open App Received: ${response}`);
Expand Down
3 changes: 2 additions & 1 deletion NiceCopy/NiceCopyApp.swift
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,12 @@ struct NiceCopyApp: App {

Window("NiceCopy", id: "open_app") {
SettingsView()
.frame(width: 500, height: 600)
}
.windowResizability(.contentSize)
.modifiers { scene in
if #available(macOS 15.0, *) {
scene
.windowIdealSize(.fitToContent)
.windowLevel(.floating)
.defaultLaunchBehavior(.suppressed)
}
Expand Down

0 comments on commit 1971d39

Please sign in to comment.