Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

openDesktopApp.ts 845B

12345678910111213141516171819202122232425
  1. import { IReduxState } from '../app/types';
  2. import { URI_PROTOCOL_PATTERN } from '../base/util/uri';
  3. /**
  4. * Opens the desktop app.
  5. *
  6. * @param {Object} _state - Object containing current redux state.
  7. * @returns {Promise<boolean>} - Resolves with true if the attempt to open the desktop app was successful and resolves
  8. * with false otherwise.
  9. */
  10. export function _openDesktopApp(_state: Object) {
  11. const state = _state as IReduxState;
  12. const deeplinkingDesktop = state['features/base/config'].deeplinking?.desktop;
  13. if (deeplinkingDesktop?.enabled) {
  14. const { appScheme } = deeplinkingDesktop;
  15. const regex = new RegExp(URI_PROTOCOL_PATTERN, 'gi');
  16. window.location.href = window.location.href.replace(regex, `${appScheme}:`);
  17. return Promise.resolve(true);
  18. }
  19. return Promise.resolve(false);
  20. }