Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions src/background/modules/ContextMenu.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import * as BrowserCommunication from "/common/modules/BrowserCommunication/BrowserCommunication.js";
import { COMMUNICATION_MESSAGE_TYPE } from "/common/modules/data/BrowserCommunicationTypes.js";
import { createMenu } from "/common/modules/ContextMenu.js";

Expand Down Expand Up @@ -149,15 +150,15 @@ export function init() {
return createItems().then(() => {
browser.menus.onClicked.addListener(menuClicked);
browser.menus.onShown.addListener(menuShown);
browser.runtime.onMessage.addListener((message) => {
if (message.action === "enableContextMenu") {

BrowserCommunication.addListener(COMMUNICATION_MESSAGE_TYPE.SET_QR_TEXT, (request) => {
if (request.value) {
browser.menus.update(CONVERT_PAGE_URL, { visible: true });
console.log("Context menu enabled");
} else if (message.action === "disableContextMenu") {
} else {
browser.menus.update(CONVERT_PAGE_URL, { visible: false });
console.log("Context menu disabled");
}
browser.menus.refresh();
});
});
});
}
3 changes: 2 additions & 1 deletion src/common/modules/data/BrowserCommunicationTypes.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,6 @@
export const COMMUNICATION_MESSAGE_TYPE = Object.freeze({
SET_QR_TEXT: "setQrText",
SAVE_FILE_AS: "saveFileAs",
SAVE_FILE_AS_STOP_RETRY: "saveFileAsStopRetry"
SAVE_FILE_AS_STOP_RETRY: "saveFileAsStopRetry",
CONTEXT_MENU_CHANGE: "contextMenuChange"
});
18 changes: 7 additions & 11 deletions src/options/modules/CustomOptionTriggers.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import * as CommonMessages from "/common/modules/MessageHandler/CommonMessages.j
import * as CustomMessages from "/common/modules/MessageHandler/CustomMessages.js";
import { MESSAGE_LEVEL } from "/common/modules/data/MessageLevel.js";
import * as PermissionRequest from "/common/modules/PermissionRequest/PermissionRequest.js";
import { COMMUNICATION_MESSAGE_TYPE } from "/common/modules/data/BrowserCommunicationTypes.js";

// used to apply options
import * as Colors from "/common/modules/Colors.js";
Expand Down Expand Up @@ -89,15 +90,10 @@ function applyPopupIconColor(optionValue) {
* @returns {void}
*/
function applyContextMenuEnabled(optionValue) {
if (optionValue) {
console.log("Context menu is enabled");
// Call the logic to enable the context menu
browser.runtime.sendMessage({ action: "enableContextMenu" });
} else {
console.log("Context menu is disabled");
// Call the logic to disable the context menu
browser.runtime.sendMessage({ action: "disableContextMenu" });
}
browser.runtime.sendMessage({
type: COMMUNICATION_MESSAGE_TYPE.SET_QR_TEXT,
value: optionValue
});
}

/**
Expand Down Expand Up @@ -278,10 +274,10 @@ function applyClipboardContent(optionValue, event={}) {
event,
{retry: true}
);
}
}
PermissionRequest.cancelPermissionPrompt(CLIPBOARD_READ_PERMISSION,MESSAGE_CLIPBOARD_READ_PERMISSION);
return Promise.resolve();
}
}

/**
* Binds the triggers.
Expand Down
Loading