diff options
Diffstat (limited to 'src/webview/dialogTitle.ts')
-rw-r--r-- | src/webview/dialogTitle.ts | 33 |
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 @@ | |||
1 | import { ipcRenderer } from 'electron'; | ||
2 | |||
3 | const debug = require('debug')('Ferdi:Plugin:DialogTitleHandler'); | ||
4 | |||
5 | export 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 | } | ||