aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorLibravatar Kristóf Marussy <kristof@marussy.com>2024-01-03 03:46:28 +0100
committerLibravatar GitHub <noreply@github.com>2024-01-03 03:46:28 +0100
commitb0b9860f68b0a151841d0c145a11ea39c11fa66a (patch)
treedda676c476500bd08622ca0dc831f6f1da915bcb /src
parent6.7.1-nightly.2 [skip ci] (diff)
downloadferdium-app-b0b9860f68b0a151841d0c145a11ea39c11fa66a.tar.gz
ferdium-app-b0b9860f68b0a151841d0c145a11ea39c11fa66a.tar.zst
ferdium-app-b0b9860f68b0a151841d0c145a11ea39c11fa66a.zip
Rudimentary DBus toggle-to-talk support (#1507)
Adds a ToggleToTalk method to the DBus interface to unmute/mute the microphone in the active service if the recipe supports it. We will need to add support for this feature in recipes.
Diffstat (limited to 'src')
-rw-r--r--src/lib/dbus/Ferdium.ts8
-rw-r--r--src/models/Service.ts4
-rw-r--r--src/stores/ServicesStore.ts6
-rw-r--r--src/webview/lib/RecipeWebview.ts6
-rw-r--r--src/webview/recipe.ts5
5 files changed, 29 insertions, 0 deletions
diff --git a/src/lib/dbus/Ferdium.ts b/src/lib/dbus/Ferdium.ts
index b2a9105f4..853be68e1 100644
--- a/src/lib/dbus/Ferdium.ts
+++ b/src/lib/dbus/Ferdium.ts
@@ -31,6 +31,10 @@ export default class Ferdium extends dbus.interface.Interface {
31 this.dbus.trayIcon._toggleWindow(); 31 this.dbus.trayIcon._toggleWindow();
32 } 32 }
33 33
34 ToggleToTalk(): void {
35 this.dbus.trayIcon.mainWindow?.webContents.send('toggle-to-talk');
36 }
37
34 emitUnreadChanged(): void { 38 emitUnreadChanged(): void {
35 Ferdium.emitPropertiesChanged( 39 Ferdium.emitPropertiesChanged(
36 this, 40 this,
@@ -66,6 +70,10 @@ Ferdium.configureMembers({
66 inSignature: '', 70 inSignature: '',
67 outSignature: '', 71 outSignature: '',
68 }, 72 },
73 ToggleToTalk: {
74 inSignature: '',
75 outSignature: '',
76 },
69 }, 77 },
70 properties: { 78 properties: {
71 Muted: { 79 Muted: {
diff --git a/src/models/Service.ts b/src/models/Service.ts
index b1f0bc271..da9fa43dd 100644
--- a/src/models/Service.ts
+++ b/src/models/Service.ts
@@ -641,4 +641,8 @@ export default class Service {
641 this.unreadDirectMessageCount = 0; 641 this.unreadDirectMessageCount = 0;
642 this.unreadIndirectMessageCount = 0; 642 this.unreadIndirectMessageCount = 0;
643 } 643 }
644
645 toggleToTalk(): void {
646 this.webview?.send('toggle-to-talk');
647 }
644} 648}
diff --git a/src/stores/ServicesStore.ts b/src/stores/ServicesStore.ts
index 95aae6ccb..175a2ce16 100644
--- a/src/stores/ServicesStore.ts
+++ b/src/stores/ServicesStore.ts
@@ -65,6 +65,8 @@ export default class ServicesStore extends TypedStore {
65 // No service ID should be in the list multiple times, not all service IDs have to be in the list 65 // No service ID should be in the list multiple times, not all service IDs have to be in the list
66 @observable lastUsedServices: string[] = []; 66 @observable lastUsedServices: string[] = [];
67 67
68 private toggleToTalkCallback = () => this.active?.toggleToTalk();
69
68 constructor(stores: Stores, api: ApiInterface, actions: Actions) { 70 constructor(stores: Stores, api: ApiInterface, actions: Actions) {
69 super(stores, api, actions); 71 super(stores, api, actions);
70 72
@@ -239,6 +241,8 @@ export default class ServicesStore extends TypedStore {
239 initialize() { 241 initialize() {
240 super.initialize(); 242 super.initialize();
241 243
244 ipcRenderer.on('toggle-to-talk', this.toggleToTalkCallback);
245
242 // Check services to become hibernated 246 // Check services to become hibernated
243 this.serviceMaintenanceTick(); 247 this.serviceMaintenanceTick();
244 } 248 }
@@ -246,6 +250,8 @@ export default class ServicesStore extends TypedStore {
246 teardown() { 250 teardown() {
247 super.teardown(); 251 super.teardown();
248 252
253 ipcRenderer.off('toggle-to-talk', this.toggleToTalkCallback);
254
249 // Stop checking services for hibernation 255 // Stop checking services for hibernation
250 this.serviceMaintenanceTick.cancel(); 256 this.serviceMaintenanceTick.cancel();
251 } 257 }
diff --git a/src/webview/lib/RecipeWebview.ts b/src/webview/lib/RecipeWebview.ts
index 44b3c5ab4..31e9a288d 100644
--- a/src/webview/lib/RecipeWebview.ts
+++ b/src/webview/lib/RecipeWebview.ts
@@ -40,6 +40,8 @@ class RecipeWebview {
40 40
41 loopFunc = () => null; 41 loopFunc = () => null;
42 42
43 toggleToTalkFunc = () => null;
44
43 darkModeHandler: ((darkMode: boolean, config: any) => void) | null = null; 45 darkModeHandler: ((darkMode: boolean, config: any) => void) | null = null;
44 46
45 // TODO Remove this once we implement a proper wrapper. 47 // TODO Remove this once we implement a proper wrapper.
@@ -199,6 +201,10 @@ class RecipeWebview {
199 openNewWindow(url) { 201 openNewWindow(url) {
200 ipcRenderer.sendToHost('new-window', url); 202 ipcRenderer.sendToHost('new-window', url);
201 } 203 }
204
205 toggleToTalk(fn) {
206 this.toggleToTalkFunc = fn;
207 }
202} 208}
203 209
204export default RecipeWebview; 210export default RecipeWebview;
diff --git a/src/webview/recipe.ts b/src/webview/recipe.ts
index b394f1517..f2a13f224 100644
--- a/src/webview/recipe.ts
+++ b/src/webview/recipe.ts
@@ -158,6 +158,7 @@ class RecipeController {
158 'service-settings-update': 'updateServiceSettings', 158 'service-settings-update': 'updateServiceSettings',
159 'get-service-id': 'serviceIdEcho', 159 'get-service-id': 'serviceIdEcho',
160 'find-in-page': 'openFindInPage', 160 'find-in-page': 'openFindInPage',
161 'toggle-to-talk': 'toggleToTalk',
161 }; 162 };
162 163
163 universalDarkModeInjected = false; 164 universalDarkModeInjected = false;
@@ -483,6 +484,10 @@ class RecipeController {
483 }, 225), 484 }, 225),
484 ); 485 );
485 } 486 }
487
488 toggleToTalk() {
489 this.recipe?.toggleToTalkFunc?.();
490 }
486} 491}
487 492
488/* eslint-disable no-new */ 493/* eslint-disable no-new */