You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

functions.js 1.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. /* global APP */
  2. import HttpConfigFetch from '../../../modules/config/HttpConfigFetch';
  3. /**
  4. * Promise wrapper on obtain config method.
  5. * When HttpConfigFetch will be moved to React app
  6. * it's better to use load config instead.
  7. *
  8. * @param {string} location - URL of the domain.
  9. * @param {string} room - Room name.
  10. * @returns {Promise}
  11. */
  12. export function obtainConfig(location, room) {
  13. return new Promise((resolve, reject) => {
  14. HttpConfigFetch.obtainConfig(location, room, (success, error) => {
  15. if (success) {
  16. resolve();
  17. } else {
  18. reject(error);
  19. }
  20. });
  21. });
  22. }
  23. /**
  24. * If JWT token data it will be used for local user settings.
  25. *
  26. * @returns {void}
  27. */
  28. export function setTokenData() {
  29. const localUser = APP.tokenData.caller;
  30. if (localUser) {
  31. const email = localUser.getEmail();
  32. const avatarUrl = localUser.getAvatarUrl();
  33. const name = localUser.getName();
  34. APP.settings.setEmail((email || '').trim(), true);
  35. APP.settings.setAvatarUrl((avatarUrl || '').trim());
  36. APP.settings.setDisplayName((name || '').trim(), true);
  37. }
  38. }