aboutsummaryrefslogtreecommitdiffstats
path: root/src/webview/dialogTitle.ts
diff options
context:
space:
mode:
Diffstat (limited to 'src/webview/dialogTitle.ts')
-rw-r--r--src/webview/dialogTitle.ts33
1 files changed, 33 insertions, 0 deletions
diff --git a/src/webview/dialogTitle.ts b/src/webview/dialogTitle.ts
new file mode 100644
index 000000000..f9a1aac6f
--- /dev/null
+++ b/src/webview/dialogTitle.ts
@@ -0,0 +1,33 @@
1import { ipcRenderer } from 'electron';
2
3const debug = require('debug')('Ferdi:Plugin:DialogTitleHandler');
4
5export class DialogTitleHandler {
6 titleCache: { title: string };
7
8 constructor() {
9 this.titleCache = {
10 title: '',
11 };
12 }
13
14 safeGetTitle(title: string | undefined | null) {
15 if (!title) {
16 return '';
17 }
18
19 return title;
20 }
21
22 setDialogTitle(title: string | undefined | null) {
23 const newTitle = this.safeGetTitle(title);
24 if (this.titleCache.title === newTitle) {
25 return;
26 }
27
28 debug('Sending active dialog title to host %s', newTitle);
29 ipcRenderer.sendToHost('active-dialog-title', newTitle);
30
31 this.titleCache.title = newTitle;
32 }
33}