aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib
diff options
context:
space:
mode:
authorLibravatar Markus Hatvan <markus_hatvan@aon.at>2021-10-02 09:24:32 +0200
committerLibravatar GitHub <noreply@github.com>2021-10-02 09:24:32 +0200
commitbfe8847d72cd0893230f2e654242658214943e61 (patch)
tree3384b02ebad7a74cbb106ddd95546e0e24ff0bb8 /src/lib
parentfix: Fix navigation shortcut accelerator for non-macos (fixes #1172) (#2012) (diff)
downloadferdium-app-bfe8847d72cd0893230f2e654242658214943e61.tar.gz
ferdium-app-bfe8847d72cd0893230f2e654242658214943e61.tar.zst
ferdium-app-bfe8847d72cd0893230f2e654242658214943e61.zip
chore: convert various files from JS to TS (#2010)
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/DBus.ts (renamed from src/lib/DBus.js)22
-rw-r--r--src/lib/Form.ts (renamed from src/lib/Form.js)0
-rw-r--r--src/lib/TouchBar.ts (renamed from src/lib/TouchBar.js)37
3 files changed, 41 insertions, 18 deletions
diff --git a/src/lib/DBus.js b/src/lib/DBus.ts
index 9baaea014..b1febc2d1 100644
--- a/src/lib/DBus.js
+++ b/src/lib/DBus.ts
@@ -1,10 +1,12 @@
1import { sessionBus } from 'dbus-next'; 1import { MessageBus, sessionBus } from 'dbus-next';
2import { isLinux } from '../environment'; 2import { isLinux } from '../environment';
3 3
4export default class DBus { 4export default class DBus {
5 bus = null; 5 bus: MessageBus | null = null;
6 6
7 constructor(trayIcon) { 7 trayIcon: any;
8
9 constructor(trayIcon: any) {
8 this.trayIcon = trayIcon; 10 this.trayIcon = trayIcon;
9 } 11 }
10 12
@@ -19,15 +21,23 @@ export default class DBus {
19 } 21 }
20 22
21 // HACK Hook onto the MessageBus to track StatusNotifierWatchers 23 // HACK Hook onto the MessageBus to track StatusNotifierWatchers
22 this.bus._addMatch("type='signal',sender='org.freedesktop.DBus',interface='org.freedesktop.DBus',path='/org/freedesktop/DBus',member='NameOwnerChanged'"); 24 // @ts-expect-error Property '_addMatch' does not exist on type 'MessageBus'.
25 this.bus._addMatch(
26 "type='signal',sender='org.freedesktop.DBus',interface='org.freedesktop.DBus',path='/org/freedesktop/DBus',member='NameOwnerChanged'",
27 );
23 const mangled = JSON.stringify({ 28 const mangled = JSON.stringify({
24 path: '/org/freedesktop/DBus', 29 path: '/org/freedesktop/DBus',
25 interface: 'org.freedesktop.DBus', 30 interface: 'org.freedesktop.DBus',
26 member: 'NameOwnerChanged', 31 member: 'NameOwnerChanged',
27 }); 32 });
28 this.bus._signals.on(mangled, (msg) => { 33 // @ts-expect-error Property '_signals' does not exist on type 'MessageBus'.
34 this.bus._signals.on(mangled, (msg: { body: [any, any, any] }) => {
29 const [name, oldOwner, newOwner] = msg.body; 35 const [name, oldOwner, newOwner] = msg.body;
30 if (name === 'org.kde.StatusNotifierWatcher' && oldOwner !== newOwner && newOwner !== '') { 36 if (
37 name === 'org.kde.StatusNotifierWatcher' &&
38 oldOwner !== newOwner &&
39 newOwner !== ''
40 ) {
31 // Leave ample time for the StatusNotifierWatcher to be initialized 41 // Leave ample time for the StatusNotifierWatcher to be initialized
32 setTimeout(() => { 42 setTimeout(() => {
33 this.trayIcon.recreateIfVisible(); 43 this.trayIcon.recreateIfVisible();
diff --git a/src/lib/Form.js b/src/lib/Form.ts
index 9b8321948..9b8321948 100644
--- a/src/lib/Form.js
+++ b/src/lib/Form.ts
diff --git a/src/lib/TouchBar.js b/src/lib/TouchBar.ts
index c80931200..417e20411 100644
--- a/src/lib/TouchBar.js
+++ b/src/lib/TouchBar.ts
@@ -5,7 +5,13 @@ import { autorun } from 'mobx';
5import { isMac, osRelease } from '../environment'; 5import { isMac, osRelease } from '../environment';
6 6
7export default class FranzTouchBar { 7export default class FranzTouchBar {
8 constructor(stores, actions) { 8 stores: any;
9
10 actions: any;
11
12 build: any;
13
14 constructor(stores: any, actions: any) {
9 this.stores = stores; 15 this.stores = stores;
10 this.actions = actions; 16 this.actions = actions;
11 17
@@ -26,18 +32,25 @@ export default class FranzTouchBar {
26 if (this.stores.user.isLoggedIn) { 32 if (this.stores.user.isLoggedIn) {
27 const { TouchBarButton, TouchBarSpacer } = TouchBar; 33 const { TouchBarButton, TouchBarSpacer } = TouchBar;
28 34
29 const buttons = []; 35 const buttons: any[] = [];
30 for (const service of this.stores.services.allDisplayed) { 36 for (const service of this.stores.services.allDisplayed) {
31 buttons.push(new TouchBarButton({ 37 buttons.push(
32 label: `${service.name}${service.unreadDirectMessageCount > 0 38 new TouchBarButton({
33 ? ' 🔴' : ''} ${service.unreadDirectMessageCount === 0 39 label: `${service.name}${
34 && service.unreadIndirectMessageCount > 0 40 service.unreadDirectMessageCount > 0 ? ' 🔴' : ''
35 ? ' ⚪️' : ''}`, 41 } ${
36 backgroundColor: service.isActive ? '#3498DB' : null, 42 service.unreadDirectMessageCount === 0 &&
37 click: () => { 43 service.unreadIndirectMessageCount > 0
38 this.actions.service.setActive({ serviceId: service.id }); 44 ? ' ⚪️'
39 }, 45 : ''
40 }), new TouchBarSpacer({ size: 'small' })); 46 }`,
47 backgroundColor: service.isActive && '#3498DB',
48 click: () => {
49 this.actions.service.setActive({ serviceId: service.id });
50 },
51 }),
52 new TouchBarSpacer({ size: 'small' }),
53 );
41 } 54 }
42 55
43 const touchBar = new TouchBar({ items: buttons }); 56 const touchBar = new TouchBar({ items: buttons });