Device manager - tweak string formatting of default device name (#23457)
* tweak string formatting of default device name * cheaters path to beating quality gate * more electronplatform test coverage * remove test that throw errors * cover some more window.electrons * more coverage * empty line
This commit is contained in:
parent
44eeb6fddc
commit
0e8e472138
6 changed files with 297 additions and 21 deletions
|
@ -45,7 +45,6 @@ import VectorBasePlatform from './VectorBasePlatform';
|
|||
import { SeshatIndexManager } from "./SeshatIndexManager";
|
||||
import { IPCManager } from "./IPCManager";
|
||||
|
||||
const electron = window.electron;
|
||||
const isMac = navigator.platform.toUpperCase().includes('MAC');
|
||||
|
||||
function platformFriendlyName(): string {
|
||||
|
@ -70,7 +69,7 @@ function platformFriendlyName(): string {
|
|||
function onAction(payload: ActionPayload): void {
|
||||
// Whitelist payload actions, no point sending most across
|
||||
if (['call_state'].includes(payload.action)) {
|
||||
electron.send('app_onAction', payload);
|
||||
window.electron.send('app_onAction', payload);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -103,7 +102,7 @@ export default class ElectronPlatform extends VectorBasePlatform {
|
|||
false if there is not
|
||||
or the error if one is encountered
|
||||
*/
|
||||
electron.on('check_updates', (event, status) => {
|
||||
window.electron.on('check_updates', (event, status) => {
|
||||
dis.dispatch<CheckUpdatesPayload>({
|
||||
action: Action.CheckUpdates,
|
||||
...getUpdateCheckStatus(status),
|
||||
|
@ -111,27 +110,27 @@ export default class ElectronPlatform extends VectorBasePlatform {
|
|||
});
|
||||
|
||||
// try to flush the rageshake logs to indexeddb before quit.
|
||||
electron.on('before-quit', function() {
|
||||
window.electron.on('before-quit', function() {
|
||||
logger.log('element-desktop closing');
|
||||
rageshake.flush();
|
||||
});
|
||||
|
||||
electron.on('update-downloaded', this.onUpdateDownloaded);
|
||||
window.electron.on('update-downloaded', this.onUpdateDownloaded);
|
||||
|
||||
electron.on('preferences', () => {
|
||||
window.electron.on('preferences', () => {
|
||||
dis.fire(Action.ViewUserSettings);
|
||||
});
|
||||
|
||||
electron.on('userDownloadCompleted', (ev, { id, name }) => {
|
||||
window.electron.on('userDownloadCompleted', (ev, { id, name }) => {
|
||||
const key = `DOWNLOAD_TOAST_${id}`;
|
||||
|
||||
const onAccept = () => {
|
||||
electron.send('userDownloadAction', { id, open: true });
|
||||
window.electron.send('userDownloadAction', { id, open: true });
|
||||
ToastStore.sharedInstance().dismissToast(key);
|
||||
};
|
||||
|
||||
const onDismiss = () => {
|
||||
electron.send('userDownloadAction', { id });
|
||||
window.electron.send('userDownloadAction', { id });
|
||||
};
|
||||
|
||||
ToastStore.sharedInstance().addOrReplaceToast({
|
||||
|
@ -187,7 +186,7 @@ export default class ElectronPlatform extends VectorBasePlatform {
|
|||
if (this.notificationCount === count) return;
|
||||
super.setNotificationCount(count);
|
||||
|
||||
electron.send('setBadgeCount', count);
|
||||
window.electron.send('setBadgeCount', count);
|
||||
}
|
||||
|
||||
public supportsNotifications(): boolean {
|
||||
|
@ -233,7 +232,7 @@ export default class ElectronPlatform extends VectorBasePlatform {
|
|||
}
|
||||
|
||||
public loudNotification(ev: MatrixEvent, room: Room) {
|
||||
electron.send('loudNotification');
|
||||
window.electron.send('loudNotification');
|
||||
}
|
||||
|
||||
public needsUrlTooltips(): boolean {
|
||||
|
@ -269,19 +268,19 @@ export default class ElectronPlatform extends VectorBasePlatform {
|
|||
|
||||
public startUpdateCheck() {
|
||||
super.startUpdateCheck();
|
||||
electron.send('check_updates');
|
||||
window.electron.send('check_updates');
|
||||
}
|
||||
|
||||
public installUpdate() {
|
||||
// IPC to the main process to install the update, since quitAndInstall
|
||||
// doesn't fire the before-quit event so the main process needs to know
|
||||
// it should exit.
|
||||
electron.send('install_update');
|
||||
window.electron.send('install_update');
|
||||
}
|
||||
|
||||
public getDefaultDeviceDisplayName(): string {
|
||||
const brand = SdkConfig.get().brand;
|
||||
return _t('%(brand)s Desktop (%(platformName)s)', {
|
||||
return _t('%(brand)s Desktop: %(platformName)s', {
|
||||
brand,
|
||||
platformName: platformFriendlyName(),
|
||||
});
|
||||
|
|
|
@ -19,8 +19,6 @@ import { logger } from "matrix-js-sdk/src/logger";
|
|||
|
||||
import { ElectronChannel } from "../../@types/global";
|
||||
|
||||
const electron = window.electron;
|
||||
|
||||
interface IPCPayload {
|
||||
id?: number;
|
||||
error?: string;
|
||||
|
@ -35,7 +33,7 @@ export class IPCManager {
|
|||
private readonly sendChannel: ElectronChannel = "ipcCall",
|
||||
private readonly recvChannel: ElectronChannel = "ipcReply",
|
||||
) {
|
||||
electron.on(this.recvChannel, this.onIpcReply);
|
||||
window.electron.on(this.recvChannel, this.onIpcReply);
|
||||
}
|
||||
|
||||
public async call(name: string, ...args: any[]): Promise<any> {
|
||||
|
|
|
@ -210,7 +210,7 @@ export default class WebPlatform extends VectorBasePlatform {
|
|||
let osName = ua.getOS().name || "unknown OS";
|
||||
// Stylise the value from the parser to match Apple's current branding.
|
||||
if (osName === "Mac OS") osName = "macOS";
|
||||
return _t('%(appName)s (%(browserName)s, %(osName)s)', {
|
||||
return _t('%(appName)s: %(browserName)s on %(osName)s', {
|
||||
appName,
|
||||
browserName,
|
||||
osName,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue