* automatically add protocol to Server URL (#2083) * refactor NewTeamModal to only detect protocol on save * use window.postMessage for intercom + only ping on form save
This commit is contained in:
@@ -33,6 +33,7 @@ import {
|
||||
USER_ACTIVITY_UPDATE,
|
||||
START_UPGRADE,
|
||||
START_DOWNLOAD,
|
||||
PING_DOMAIN,
|
||||
} from 'common/communication';
|
||||
import Config from 'common/config';
|
||||
import urlUtils from 'common/utils/url';
|
||||
@@ -81,6 +82,7 @@ import {
|
||||
handleSwitchServer,
|
||||
handleSwitchTab,
|
||||
handleUpdateLastActive,
|
||||
handlePingDomain,
|
||||
} from './intercom';
|
||||
import {
|
||||
clearAppCache,
|
||||
@@ -253,6 +255,7 @@ function initializeInterCommunicationEventListeners() {
|
||||
ipcMain.handle(GET_DOWNLOAD_LOCATION, handleSelectDownload);
|
||||
ipcMain.on(START_DOWNLOAD, handleStartDownload);
|
||||
ipcMain.on(START_UPGRADE, handleStartUpgrade);
|
||||
ipcMain.handle(PING_DOMAIN, handlePingDomain);
|
||||
}
|
||||
|
||||
function initializeAfterAppReady() {
|
||||
|
@@ -9,6 +9,7 @@ import {MentionData} from 'types/notification';
|
||||
|
||||
import Config from 'common/config';
|
||||
import {getDefaultTeamWithTabsFromTeam} from 'common/tabs/TabView';
|
||||
import {ping} from 'common/utils/requests';
|
||||
|
||||
import {displayMention} from 'main/notifications';
|
||||
import {getLocalPreload, getLocalURLString} from 'main/utils';
|
||||
@@ -256,3 +257,16 @@ export function handleUpdateLastActive(event: IpcMainEvent, serverName: string,
|
||||
Config.set('lastActiveTeam', teams.find((team) => team.name === serverName)?.order || 0);
|
||||
}
|
||||
|
||||
export function handlePingDomain(event: IpcMainInvokeEvent, url: string): Promise<string> {
|
||||
return Promise.allSettled([
|
||||
ping(new URL(`https://${url}`)),
|
||||
ping(new URL(`http://${url}`)),
|
||||
]).then(([https, http]): string => {
|
||||
if (https.status === 'fulfilled') {
|
||||
return 'https';
|
||||
} else if (http.status === 'fulfilled') {
|
||||
return 'http';
|
||||
}
|
||||
throw new Error('Could not find server ' + url);
|
||||
});
|
||||
}
|
||||
|
Reference in New Issue
Block a user