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

PageReloadOverlay.js 3.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. /* global $, APP, AJS */
  2. const logger = require("jitsi-meet-logger").getLogger(__filename);
  3. import Overlay from '../overlay/Overlay';
  4. /**
  5. * An overlay dialog which is shown before the conference is reloaded. Shows
  6. * a warning message and counts down towards the reload.
  7. */
  8. class PageReloadOverlayImpl extends Overlay{
  9. /**
  10. * Creates new <tt>PageReloadOverlayImpl</tt>
  11. * @param {number} timeoutSeconds how long the overlay dialog will be
  12. * displayed, before the conference will be reloaded.
  13. */
  14. constructor(timeoutSeconds) {
  15. super();
  16. /**
  17. * Conference reload counter in seconds.
  18. * @type {number}
  19. */
  20. this.timeLeft = timeoutSeconds;
  21. /**
  22. * Conference reload timeout in seconds.
  23. * @type {number}
  24. */
  25. this.timeout = timeoutSeconds;
  26. }
  27. /**
  28. * Constructs overlay body with the warning message and count down towards
  29. * the conference reload.
  30. * @override
  31. */
  32. _buildOverlayContent() {
  33. return `
  34. <span data-i18n='dialog.conferenceReloadTitle'
  35. class='reload_overlay_title'></span>
  36. <span data-i18n='dialog.conferenceReloadMsg'
  37. class='reload_overlay_msg'></span>
  38. <div>
  39. <div id='reloadProgressBar' class="aui-progress-indicator">
  40. <span class="aui-progress-indicator-value"></span>
  41. </div>
  42. <span id='reloadSecRemaining'
  43. data-i18n="dialog.conferenceReloadTimeLeft"
  44. class='reload_overlay_msg'>
  45. </span>
  46. </div>`;
  47. }
  48. /**
  49. * Updates the progress indicator position and the label with the time left.
  50. */
  51. updateDisplay() {
  52. APP.translation.translateElement(
  53. $("#reloadSecRemaining"), { seconds: this.timeLeft });
  54. const ratio = (this.timeout - this.timeLeft) / this.timeout;
  55. AJS.progressBars.update("#reloadProgressBar", ratio);
  56. }
  57. /**
  58. * Starts the reload countdown with the animation.
  59. * @override
  60. */
  61. _onShow() {
  62. // Initialize displays
  63. this.updateDisplay();
  64. var intervalId = window.setInterval(function() {
  65. if (this.timeLeft >= 1) {
  66. this.timeLeft -= 1;
  67. }
  68. this.updateDisplay();
  69. if (this.timeLeft === 0) {
  70. window.clearInterval(intervalId);
  71. APP.ConferenceUrl.reload();
  72. }
  73. }.bind(this), 1000);
  74. logger.info(
  75. "The conference will be reloaded after "
  76. + this.timeLeft + " seconds.");
  77. }
  78. }
  79. /**
  80. * Holds the page reload overlay instance.
  81. *
  82. * {@type PageReloadOverlayImpl}
  83. */
  84. let overlay;
  85. export default {
  86. /**
  87. * Checks whether the page reload overlay has been displayed.
  88. * @return {boolean} <tt>true</tt> if the page reload overlay is currently
  89. * visible or <tt>false</tt> otherwise.
  90. */
  91. isVisible() {
  92. return overlay && overlay.isVisible();
  93. },
  94. /**
  95. * Shows the page reload overlay which will do the conference reload after
  96. * the given amount of time.
  97. *
  98. * @param {number} timeoutSeconds how many seconds before the conference
  99. * reload will happen.
  100. */
  101. show(timeoutSeconds) {
  102. if (!overlay) {
  103. overlay = new PageReloadOverlayImpl(timeoutSeconds);
  104. }
  105. // Log the page reload event
  106. if (!this.isVisible()) {
  107. // FIXME (CallStats - issue) this event will not make it to
  108. // the CallStats, because the log queue is not flushed, before
  109. // "fabric terminated" is sent to the backed
  110. APP.conference.logEvent('page.reload');
  111. }
  112. overlay.show();
  113. }
  114. };