[MM-53847] Expose isDev API to allow webapp to check if the app is in dev mode (#2800)

* [MM-53847] Expose isDev API to allow webapp to check if the app is in dev mode

* Fix test
This commit is contained in:
Devin Binnie
2023-08-29 10:07:33 -04:00
committed by GitHub
parent f581f439df
commit 9c3febd4c9
6 changed files with 16 additions and 2 deletions

View File

@@ -235,7 +235,7 @@ function initializeBeforeAppReady() {
AllowProtocolDialog.init();
if (isDev && process.env.NODE_ENV !== 'test') {
log.info('In development mode, deeplinking is disabled');
app.setAsDefaultProtocolClient('mattermost-dev');
} else if (mainProtocol) {
app.setAsDefaultProtocolClient(mainProtocol);
}

View File

@@ -35,6 +35,8 @@ jest.mock('electron', () => ({
},
}));
jest.mock('electron-is-dev', () => false);
jest.mock('common/config', () => ({
setServers: jest.fn(),
}));

View File

@@ -6,6 +6,7 @@ import path from 'path';
import fs from 'fs-extra';
import {app, BrowserWindow, Menu, Rectangle, Session, session, dialog, nativeImage, screen} from 'electron';
import isDev from 'electron-is-dev';
import {MigrationInfo} from 'types/config';
import {RemoteInfo} from 'types/server';
@@ -72,7 +73,8 @@ export function getDeeplinkingURL(args: string[]) {
if (Array.isArray(args) && args.length) {
// deeplink urls should always be the last argument, but may not be the first (i.e. Windows with the app already running)
const url = args[args.length - 1];
if (url && mainProtocol && url.startsWith(mainProtocol) && isValidURI(url)) {
const protocol = isDev ? 'mattermost-dev' : mainProtocol;
if (url && protocol && url.startsWith(protocol) && isValidURI(url)) {
return url;
}
}