Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

Settings.js 6.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210
  1. /* global JitsiMeetJS */
  2. const logger = require('jitsi-meet-logger').getLogger(__filename);
  3. import UIUtil from '../UI/util/UIUtil';
  4. import jitsiLocalStorage from '../util/JitsiLocalStorage';
  5. import { randomHexString } from '../../react/features/base/util';
  6. let avatarUrl = '';
  7. let email = UIUtil.unescapeHtml(jitsiLocalStorage.getItem('email') || '');
  8. let avatarId = UIUtil.unescapeHtml(jitsiLocalStorage.getItem('avatarId') || '');
  9. if (!avatarId) {
  10. // if there is no avatar id, we generate a unique one and use it forever
  11. avatarId = randomHexString(32);
  12. jitsiLocalStorage.setItem('avatarId', avatarId);
  13. }
  14. let localFlipX = JSON.parse(jitsiLocalStorage.getItem('localFlipX') || true);
  15. let displayName = UIUtil.unescapeHtml(
  16. jitsiLocalStorage.getItem('displayname') || '');
  17. let cameraDeviceId = jitsiLocalStorage.getItem('cameraDeviceId') || '';
  18. let micDeviceId = jitsiLocalStorage.getItem('micDeviceId') || '';
  19. let welcomePageDisabled = JSON.parse(
  20. jitsiLocalStorage.getItem('welcomePageDisabled') || false);
  21. // Currently audio output device change is supported only in Chrome and
  22. // default output always has 'default' device ID
  23. const audioOutputDeviceId = jitsiLocalStorage.getItem('audioOutputDeviceId')
  24. || 'default';
  25. if (audioOutputDeviceId
  26. !== JitsiMeetJS.mediaDevices.getAudioOutputDevice()) {
  27. JitsiMeetJS.mediaDevices.setAudioOutputDevice(audioOutputDeviceId)
  28. .catch(ex => {
  29. logger.warn('Failed to set audio output device from local '
  30. + 'storage. Default audio output device will be used'
  31. + 'instead.', ex);
  32. });
  33. }
  34. export default {
  35. /**
  36. * Sets the local user display name and saves it to local storage
  37. *
  38. * @param {string} newDisplayName unescaped display name for the local user
  39. * @param {boolean} disableLocalStore disables local store the display name
  40. */
  41. setDisplayName(newDisplayName, disableLocalStore) {
  42. displayName = newDisplayName;
  43. if (!disableLocalStore) {
  44. jitsiLocalStorage.setItem('displayname',
  45. UIUtil.escapeHtml(displayName));
  46. }
  47. },
  48. /**
  49. * Returns the escaped display name currently used by the user
  50. * @returns {string} currently valid user display name.
  51. */
  52. getDisplayName() {
  53. return displayName;
  54. },
  55. /**
  56. * Sets new email for local user and saves it to the local storage.
  57. * @param {string} newEmail new email for the local user
  58. * @param {boolean} disableLocalStore disables local store the email
  59. */
  60. setEmail(newEmail, disableLocalStore) {
  61. email = newEmail;
  62. if (!disableLocalStore) {
  63. jitsiLocalStorage.setItem('email', UIUtil.escapeHtml(newEmail));
  64. }
  65. },
  66. /**
  67. * Returns email address of the local user.
  68. * @returns {string} email
  69. */
  70. getEmail() {
  71. return email;
  72. },
  73. /**
  74. * Returns avatar id of the local user.
  75. * @returns {string} avatar id
  76. */
  77. getAvatarId() {
  78. return avatarId;
  79. },
  80. /**
  81. * Sets new avatarUrl for local user and saves it to the local storage.
  82. * @param {string} newAvatarUrl new avatarUrl for the local user
  83. */
  84. setAvatarUrl(newAvatarUrl) {
  85. avatarUrl = newAvatarUrl;
  86. },
  87. /**
  88. * Returns avatarUrl address of the local user.
  89. * @returns {string} avatarUrl
  90. */
  91. getAvatarUrl() {
  92. return avatarUrl;
  93. },
  94. /**
  95. * Sets new flipX state of local video and saves it to the local storage.
  96. * @param {string} val flipX state of local video
  97. */
  98. setLocalFlipX(val) {
  99. localFlipX = val;
  100. jitsiLocalStorage.setItem('localFlipX', val);
  101. },
  102. /**
  103. * Returns flipX state of local video.
  104. * @returns {string} flipX
  105. */
  106. getLocalFlipX() {
  107. return localFlipX;
  108. },
  109. /**
  110. * Get device id of the camera which is currently in use.
  111. * Empty string stands for default device.
  112. * @returns {String}
  113. */
  114. getCameraDeviceId() {
  115. return cameraDeviceId;
  116. },
  117. /**
  118. * Set device id of the camera which is currently in use.
  119. * Empty string stands for default device.
  120. * @param {string} newId new camera device id
  121. * @param {boolean} whether we need to store the value
  122. */
  123. setCameraDeviceId(newId, store) {
  124. cameraDeviceId = newId;
  125. if (store) {
  126. jitsiLocalStorage.setItem('cameraDeviceId', newId);
  127. }
  128. },
  129. /**
  130. * Get device id of the microphone which is currently in use.
  131. * Empty string stands for default device.
  132. * @returns {String}
  133. */
  134. getMicDeviceId() {
  135. return micDeviceId;
  136. },
  137. /**
  138. * Set device id of the microphone which is currently in use.
  139. * Empty string stands for default device.
  140. * @param {string} newId new microphone device id
  141. * @param {boolean} whether we need to store the value
  142. */
  143. setMicDeviceId(newId, store) {
  144. micDeviceId = newId;
  145. if (store) {
  146. jitsiLocalStorage.setItem('micDeviceId', newId);
  147. }
  148. },
  149. /**
  150. * Get device id of the audio output device which is currently in use.
  151. * Empty string stands for default device.
  152. * @returns {String}
  153. */
  154. getAudioOutputDeviceId() {
  155. return JitsiMeetJS.mediaDevices.getAudioOutputDevice();
  156. },
  157. /**
  158. * Set device id of the audio output device which is currently in use.
  159. * Empty string stands for default device.
  160. * @param {string} newId='default' - new audio output device id
  161. * @returns {Promise}
  162. */
  163. setAudioOutputDeviceId(newId = 'default') {
  164. return JitsiMeetJS.mediaDevices.setAudioOutputDevice(newId)
  165. .then(() =>
  166. jitsiLocalStorage.setItem('audioOutputDeviceId', newId));
  167. },
  168. /**
  169. * Check if welcome page is enabled or not.
  170. * @returns {boolean}
  171. */
  172. isWelcomePageEnabled() {
  173. return !welcomePageDisabled;
  174. },
  175. /**
  176. * Enable or disable welcome page.
  177. * @param {boolean} enabled if welcome page should be enabled or not
  178. */
  179. setWelcomePageEnabled(enabled) {
  180. welcomePageDisabled = !enabled;
  181. jitsiLocalStorage.setItem('welcomePageDisabled', welcomePageDisabled);
  182. }
  183. };