您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

helpers.js 1.0KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. const logger = require('jitsi-meet-logger').getLogger(__filename);
  2. /**
  3. * Create deferred object.
  4. *
  5. * @returns {{promise, resolve, reject}}
  6. */
  7. export function createDeferred() {
  8. const deferred = {};
  9. deferred.promise = new Promise((resolve, reject) => {
  10. deferred.resolve = resolve;
  11. deferred.reject = reject;
  12. });
  13. return deferred;
  14. }
  15. /**
  16. * Reload page.
  17. */
  18. export function reload() {
  19. window.location.reload();
  20. }
  21. /**
  22. * Redirects to a specific new URL by replacing the current location (in the
  23. * history).
  24. *
  25. * @param {string} url the URL pointing to the location where the user should
  26. * be redirected to.
  27. */
  28. export function replace(url) {
  29. window.location.replace(url);
  30. }
  31. /**
  32. * Prints the error and reports it to the global error handler.
  33. *
  34. * @param e {Error} the error
  35. * @param msg {string} [optional] the message printed in addition to the error
  36. */
  37. export function reportError(e, msg = '') {
  38. logger.error(msg, e);
  39. window.onerror && window.onerror(msg, null, null, null, e);
  40. }