Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

utils.js 1.0KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. // @flow
  2. import Platform from '../react/Platform';
  3. /**
  4. * Returns whether or not the current environment is a mobile device.
  5. *
  6. * @returns {boolean}
  7. */
  8. export function isMobileBrowser() {
  9. return Platform.OS === 'android' || Platform.OS === 'ios';
  10. }
  11. /**
  12. * Checks whether the chrome extensions defined in the config file are installed or not.
  13. *
  14. * @param {Object} config - Objects containing info about the configured extensions.
  15. *
  16. * @returns {Promise[]}
  17. */
  18. export function checkChromeExtensionsInstalled(config: Object = {}) {
  19. const isExtensionInstalled = info => new Promise(resolve => {
  20. const img = new Image();
  21. img.src = `chrome-extension://${info.id}/${info.path}`;
  22. img.onload = function() {
  23. resolve(true);
  24. };
  25. img.onerror = function() {
  26. resolve(false);
  27. };
  28. });
  29. const extensionInstalledFunction = info => isExtensionInstalled(info);
  30. return Promise.all(
  31. (config.chromeExtensionsInfo || []).map(info => extensionInstalledFunction(info))
  32. );
  33. }