2025-07-10 18:56:32 -05:00
|
|
|
import { executeAfterLoad } from '../app/functions.web';
|
2024-01-21 21:02:16 +01:00
|
|
|
import { IReduxState } from '../app/types';
|
|
|
|
|
import { URI_PROTOCOL_PATTERN } from '../base/util/uri';
|
|
|
|
|
|
2019-05-24 15:38:07 +01:00
|
|
|
/**
|
|
|
|
|
* Opens the desktop app.
|
|
|
|
|
*
|
2023-04-07 13:59:25 +03:00
|
|
|
* @param {Object} _state - Object containing current redux state.
|
2019-05-24 15:38:07 +01:00
|
|
|
* @returns {Promise<boolean>} - Resolves with true if the attempt to open the desktop app was successful and resolves
|
|
|
|
|
* with false otherwise.
|
|
|
|
|
*/
|
2023-04-07 13:59:25 +03:00
|
|
|
export function _openDesktopApp(_state: Object) {
|
2024-01-21 21:02:16 +01:00
|
|
|
const state = _state as IReduxState;
|
|
|
|
|
const deeplinkingDesktop = state['features/base/config'].deeplinking?.desktop;
|
|
|
|
|
|
|
|
|
|
if (deeplinkingDesktop?.enabled) {
|
|
|
|
|
const { appScheme } = deeplinkingDesktop;
|
|
|
|
|
const regex = new RegExp(URI_PROTOCOL_PATTERN, 'gi');
|
|
|
|
|
|
2025-07-09 14:48:21 -05:00
|
|
|
// This is needed to workaround https://issues.chromium.org/issues/41398687
|
|
|
|
|
executeAfterLoad(() => {
|
|
|
|
|
window.location.href = window.location.href.replace(regex, `${appScheme}:`);
|
|
|
|
|
});
|
2024-01-21 21:02:16 +01:00
|
|
|
|
|
|
|
|
return Promise.resolve(true);
|
|
|
|
|
}
|
|
|
|
|
|
2019-05-24 15:38:07 +01:00
|
|
|
return Promise.resolve(false);
|
|
|
|
|
}
|