2020-12-18 17:06:38 +01:00
|
|
|
import {settings, Settings} from "tc-shared/settings";
|
|
|
|
import {EventType, TypeInfo} from "tc-shared/connectionlog/Definitions";
|
2020-07-23 19:31:31 +02:00
|
|
|
|
2020-12-18 17:06:38 +01:00
|
|
|
const focusDefaultStatus: {[T in keyof TypeInfo]?: boolean} = {};
|
|
|
|
focusDefaultStatus["client.poke.received"] = true;
|
2020-07-23 19:31:31 +02:00
|
|
|
|
|
|
|
export function requestWindowFocus() {
|
2020-07-23 20:00:25 +02:00
|
|
|
if(__build.target === "web") {
|
|
|
|
window.focus();
|
|
|
|
} else {
|
|
|
|
/* TODO: Abstract that! */
|
|
|
|
const { remote } = __non_webpack_require__("electron");
|
|
|
|
remote.getCurrentWindow().show();
|
|
|
|
}
|
2020-07-23 19:31:31 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
export function isFocusRequestEnabled(type: EventType) {
|
2021-01-10 16:13:15 +01:00
|
|
|
return settings.getValue(Settings.FN_EVENTS_FOCUS_ENABLED(type), focusDefaultStatus[type as any] || false);
|
2020-07-23 19:31:31 +02:00
|
|
|
}
|