Desktop support (#4484)
* Remove home link on desktop app * Spellcheck, installation toasts, background styling, … * Add email,slack, auth support * More desktop style tweaks * Move redirect to client * cleanup * Record desktop usage * docs * fix: Selection state in search input when double clicking header
This commit is contained in:
36
app/utils/Desktop.ts
Normal file
36
app/utils/Desktop.ts
Normal file
@@ -0,0 +1,36 @@
|
||||
import { isMac, isWindows } from "./browser";
|
||||
|
||||
export default class Desktop {
|
||||
/**
|
||||
* Returns true if the client has inset/floating window controls.
|
||||
*/
|
||||
static hasInsetTitlebar() {
|
||||
return this.isMacApp();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the client is running in the macOS app.
|
||||
*/
|
||||
static isMacApp() {
|
||||
return this.isElectron() && isMac();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the client is running in the Windows app.
|
||||
*/
|
||||
static isWindowsApp() {
|
||||
return this.isElectron() && isWindows();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the client is running in a desktop app.
|
||||
*/
|
||||
static isElectron() {
|
||||
return navigator?.userAgent?.includes("Electron");
|
||||
}
|
||||
|
||||
/**
|
||||
* The bridge provides secure access to API's in desktop wrapper.
|
||||
*/
|
||||
static bridge = window.DesktopBridge;
|
||||
}
|
||||
@@ -12,8 +12,14 @@ export function isTouchDevice(): boolean {
|
||||
* Returns true if the client is running on a Mac.
|
||||
*/
|
||||
export function isMac(): boolean {
|
||||
const SSR = typeof window === "undefined";
|
||||
return !SSR && window.navigator.platform === "MacIntel";
|
||||
return window.navigator.platform === "MacIntel";
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the client is running on Windows.
|
||||
*/
|
||||
export function isWindows(): boolean {
|
||||
return window.navigator.platform === "Win32";
|
||||
}
|
||||
|
||||
let supportsPassive = false;
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { i18n } from "i18next";
|
||||
import Desktop from "./Desktop";
|
||||
|
||||
export function detectLanguage() {
|
||||
const [ln, r] = navigator.language.split("-");
|
||||
@@ -13,6 +14,9 @@ export function changeLanguage(
|
||||
if (toLanguageString && i18n.language !== toLanguageString) {
|
||||
// Languages are stored in en_US format in the database, however the
|
||||
// frontend translation framework (i18next) expects en-US
|
||||
i18n.changeLanguage(toLanguageString.replace("_", "-"));
|
||||
const locale = toLanguageString.replace("_", "-");
|
||||
i18n.changeLanguage(locale);
|
||||
|
||||
Desktop.bridge?.setSpellCheckerLanguages(["en-US", locale]);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user