diff --git a/public/locales/en/translation.json b/public/locales/en/translation.json
index 5a03d14..ce55a22 100644
--- a/public/locales/en/translation.json
+++ b/public/locales/en/translation.json
@@ -46,6 +46,7 @@
"Name": "Name",
"Theme": "Theme",
"Notifications": "Notifications",
+ "Microphone and Camera": "Microphone and Camera",
"Sound": "Sound",
"Spellcheck": "Spellcheck",
"Use custom tab color": "Use custom tab color",
diff --git a/public/locales/pt/translation.json b/public/locales/pt/translation.json
index 70c301a..c68e171 100644
--- a/public/locales/pt/translation.json
+++ b/public/locales/pt/translation.json
@@ -46,6 +46,7 @@
"Name": "Nome",
"Theme": "Tema",
"Notifications": "Notificações",
+ "Microphone and Camera": "Microfone e Câmera",
"Sound": "Som",
"Spellcheck": "Verificação Ortográfica",
"Use custom tab color": "Usar cor personalizada para a aba",
diff --git a/src/components/TabEditDialog.tsx b/src/components/TabEditDialog.tsx
index 1d4d98c..7ac5240 100644
--- a/src/components/TabEditDialog.tsx
+++ b/src/components/TabEditDialog.tsx
@@ -118,6 +118,22 @@ const TabEditDialog: Component<{
{t("Notifications")}
+
+ {
+ updateAndSyncTabStore(
+ "tabs",
+ (t) => t.id === props.tabToEdit().id,
+ "config",
+ "media",
+ value
+ );
+ }}
+ >
+ {t("Microphone and Camera")}
+
+
= (props) => {
if (!didStopLoading()) return;
window.toggleNotifications(tab.config.notifications, `persist:${tab.id}`);
+ window.toggleMediaPermission(tab.config.media, `persist:${tab.id}`);
});
createEffect(() => {
diff --git a/src/contextBridge.d.ts b/src/contextBridge.d.ts
index 274ce49..60365ed 100644
--- a/src/contextBridge.d.ts
+++ b/src/contextBridge.d.ts
@@ -12,6 +12,7 @@ declare global {
electronSettingsStore: ElectronSettingsStoreIpcApi;
whatsappPreloadPath: string;
toggleNotifications: (enabled: boolean, partition: string) => Promise;
+ toggleMediaPermission: (enabled: boolean, partition: string) => Promise;
electronIPCHandlers: {
onOpenSettings: (callback: () => void) => Electron.IpcRenderer;
onEditActiveTab: (callback: () => void) => Electron.IpcRenderer;
diff --git a/src/main.ts b/src/main.ts
index 8a2b994..a2c2c4f 100644
--- a/src/main.ts
+++ b/src/main.ts
@@ -444,6 +444,20 @@ function addIPCHandlers(mainWindow: BrowserWindow) {
}
);
+ ipcMain.handle(
+ "toggle-media-permission",
+ (_event, enabled: boolean, partition: string) => {
+ session
+ .fromPartition(partition)
+ .setPermissionRequestHandler((webContents, permission, callback) => {
+ if (permission === "media") {
+ callback(enabled);
+ }
+ });
+ }
+ );
+
+
ipcMain.on("open-link", (_event, url: string) => {
shell.openExternal(url);
});
diff --git a/src/preload.ts b/src/preload.ts
index 6216dd4..86cb10f 100644
--- a/src/preload.ts
+++ b/src/preload.ts
@@ -29,6 +29,10 @@ const toggleNotifications = async (enabled: boolean, partition: string) => {
await ipcRenderer.invoke("toggle-notifications", enabled, partition);
};
+const toggleMediaPermission = async (enabled: boolean, partition: string) => {
+ await ipcRenderer.invoke("toggle-media-permission", enabled, partition);
+};
+
contextBridge.exposeInMainWorld("electronTabStore", electronTabStoreIpcApi);
contextBridge.exposeInMainWorld("electronThemeStore", electronThemeStoreIpcApi);
contextBridge.exposeInMainWorld(
@@ -36,6 +40,7 @@ contextBridge.exposeInMainWorld(
electronSettingsStoreIpcApi
);
contextBridge.exposeInMainWorld("toggleNotifications", toggleNotifications);
+contextBridge.exposeInMainWorld("toggleMediaPermission", toggleMediaPermission);
contextBridge.exposeInMainWorld("electronIPCHandlers", {
onOpenSettings: (callback: () => void) =>
diff --git a/src/stores/tabs/common.ts b/src/stores/tabs/common.ts
index 15bba17..3698250 100644
--- a/src/stores/tabs/common.ts
+++ b/src/stores/tabs/common.ts
@@ -6,6 +6,7 @@ export type Tab = {
messageCount?: number;
config: {
theme: string;
+ media: boolean;
notifications: boolean;
sound: boolean;
color: string | null;
@@ -26,6 +27,7 @@ export const getDefaultTab = (): Tab => ({
config: {
theme: "dark",
notifications: true,
+ media: false,
sound: true,
color: null,
spellChecker: true,
diff --git a/yarn.lock b/yarn.lock
index f928eec..fcf32ef 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -2051,9 +2051,9 @@ camelcase-css@^2.0.1:
integrity sha512-QOSvevhslijgYwRx6Rv7zKdMF8lbRmx+uQGx2+vDc+KI/eBnsy9kit5aj23AgGu3pa4t9AgwbnXWqS+iOY+2aA==
caniuse-lite@^1.0.30001517, caniuse-lite@^1.0.30001520:
- version "1.0.30001525"
- resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30001525.tgz#d2e8fdec6116ffa36284ca2c33ef6d53612fe1c8"
- integrity sha512-/3z+wB4icFt3r0USMwxujAqRvaD/B7rvGTsKhbhSQErVrJvkZCLhgNLJxU8MevahQVH6hCU9FsHdNUFbiwmE7Q==
+ version "1.0.30001668"
+ resolved "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001668.tgz"
+ integrity sha512-nWLrdxqCdblixUO+27JtGJJE/txpJlyUy5YN1u53wLZkP0emYCo5zgS6QYft7VUYR42LGgi/S5hdLZTrnyIddw==
chalk@^2.4.2:
version "2.4.2"
@@ -5623,7 +5623,16 @@ stream-buffers@~2.2.0:
resolved "https://registry.yarnpkg.com/stream-buffers/-/stream-buffers-2.2.0.tgz#91d5f5130d1cef96dcfa7f726945188741d09ee4"
integrity sha512-uyQK/mx5QjHun80FLJTfaWE7JtwfRMKBLkMne6udYOmvH0CawotVa7TfgYHzAnpphn4+TweIx1QKMnRIbipmUg==
-"string-width-cjs@npm:string-width@^4.2.0", "string-width@^1.0.2 || 2 || 3 || 4", string-width@^4.1.0, string-width@^4.2.0, string-width@^4.2.3:
+"string-width-cjs@npm:string-width@^4.2.0":
+ version "4.2.3"
+ resolved "https://registry.yarnpkg.com/string-width/-/string-width-4.2.3.tgz#269c7117d27b05ad2e536830a8ec895ef9c6d010"
+ integrity sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==
+ dependencies:
+ emoji-regex "^8.0.0"
+ is-fullwidth-code-point "^3.0.0"
+ strip-ansi "^6.0.1"
+
+"string-width@^1.0.2 || 2 || 3 || 4", string-width@^4.1.0, string-width@^4.2.0, string-width@^4.2.3:
version "4.2.3"
resolved "https://registry.yarnpkg.com/string-width/-/string-width-4.2.3.tgz#269c7117d27b05ad2e536830a8ec895ef9c6d010"
integrity sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==
@@ -5675,7 +5684,14 @@ string_decoder@^1.1.1:
dependencies:
safe-buffer "~5.2.0"
-"strip-ansi-cjs@npm:strip-ansi@^6.0.1", strip-ansi@^6.0.0, strip-ansi@^6.0.1:
+"strip-ansi-cjs@npm:strip-ansi@^6.0.1":
+ version "6.0.1"
+ resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-6.0.1.tgz#9e26c63d30f53443e9489495b2105d37b67a85d9"
+ integrity sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==
+ dependencies:
+ ansi-regex "^5.0.1"
+
+strip-ansi@^6.0.0, strip-ansi@^6.0.1:
version "6.0.1"
resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-6.0.1.tgz#9e26c63d30f53443e9489495b2105d37b67a85d9"
integrity sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==
@@ -6244,7 +6260,7 @@ winreg@1.2.4:
resolved "https://registry.yarnpkg.com/winreg/-/winreg-1.2.4.tgz#ba065629b7a925130e15779108cf540990e98d1b"
integrity sha512-IHpzORub7kYlb8A43Iig3reOvlcBJGX9gZ0WycHhghHtA65X0LYnMRuJs+aH1abVnMJztQkvQNlltnbPi5aGIA==
-"wrap-ansi-cjs@npm:wrap-ansi@^7.0.0", wrap-ansi@^7.0.0:
+"wrap-ansi-cjs@npm:wrap-ansi@^7.0.0":
version "7.0.0"
resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-7.0.0.tgz#67e145cff510a6a6984bdf1152911d69d2eb9e43"
integrity sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==
@@ -6262,6 +6278,15 @@ wrap-ansi@^6.2.0:
string-width "^4.1.0"
strip-ansi "^6.0.0"
+wrap-ansi@^7.0.0:
+ version "7.0.0"
+ resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-7.0.0.tgz#67e145cff510a6a6984bdf1152911d69d2eb9e43"
+ integrity sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==
+ dependencies:
+ ansi-styles "^4.0.0"
+ string-width "^4.1.0"
+ strip-ansi "^6.0.0"
+
wrap-ansi@^8.1.0:
version "8.1.0"
resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-8.1.0.tgz#56dc22368ee570face1b49819975d9b9a5ead214"