mirror of
https://github.com/zulip/zulip.git
synced 2025-11-13 02:17:19 +00:00
Display a message and disable compose while reloading.
(imported from commit f998d2e4053e7e2d676f7fe08ee274118dd9faba)
This commit is contained in:
@@ -116,9 +116,11 @@ var people_list = [
|
|||||||
<button type="button" class="btn btn-large btn-block" id="new_message_button" onclick="compose_button('stream');">New Message</button>
|
<button type="button" class="btn btn-large btn-block" id="new_message_button" onclick="compose_button('stream');">New Message</button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="alert alert_sidebar alert-error" id="connection-error">
|
<div class="alert alert_sidebar alert-error home-error-bar" id="connection-error">
|
||||||
<strong>Can't receive messages</strong> — try reloading the page.
|
<strong>Can't receive messages</strong> — try reloading the page.
|
||||||
</div>
|
</div>
|
||||||
|
<div class="alert alert_sidebar alert-error home-error-bar" id="reloading-application">
|
||||||
|
</div>
|
||||||
<div class="alert alert_sidebar" id="home-error"></div>
|
<div class="alert alert_sidebar" id="home-error"></div>
|
||||||
<div class="alert alert_sidebar" id="stream-dne">
|
<div class="alert alert_sidebar" id="stream-dne">
|
||||||
<p>The stream <span class="streamname" id="stream-dne-name"></span> does not exist.</p>
|
<p>The stream <span class="streamname" id="stream-dne-name"></span> does not exist.</p>
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ var globals =
|
|||||||
|
|
||||||
// ui.js
|
// ui.js
|
||||||
+ ' register_onclick hide_email show_email'
|
+ ' register_onclick hide_email show_email'
|
||||||
+ ' report_error report_success clicking mouse_moved'
|
+ ' report_error report_success report_message clicking mouse_moved'
|
||||||
+ ' update_autocomplete autocomplete_needs_update'
|
+ ' update_autocomplete autocomplete_needs_update'
|
||||||
|
|
||||||
// zephyr.js
|
// zephyr.js
|
||||||
@@ -47,7 +47,7 @@ var globals =
|
|||||||
+ ' select_message select_message_by_id'
|
+ ' select_message select_message_by_id'
|
||||||
+ ' scroll_to_selected select_and_show_by_id'
|
+ ' scroll_to_selected select_and_show_by_id'
|
||||||
+ ' selected_message selected_message_id'
|
+ ' selected_message selected_message_id'
|
||||||
+ ' reload_app reload_app_preserving_compose'
|
+ ' reload_app reloading_app reload_app_preserving_compose'
|
||||||
+ ' at_top_of_viewport at_bottom_of_viewport'
|
+ ' at_top_of_viewport at_bottom_of_viewport'
|
||||||
+ ' viewport'
|
+ ' viewport'
|
||||||
;
|
;
|
||||||
|
|||||||
@@ -1,6 +1,9 @@
|
|||||||
var status_classes = 'alert-error alert-success alert-info';
|
var status_classes = 'alert-error alert-success alert-info';
|
||||||
|
|
||||||
function show_compose(tabname, focus_area) {
|
function show_compose(tabname, focus_area) {
|
||||||
|
if (reloading_app) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
$("#send-status").removeClass(status_classes).hide();
|
$("#send-status").removeClass(status_classes).hide();
|
||||||
$('#compose').css({visibility: "visible"});
|
$('#compose').css({visibility: "visible"});
|
||||||
$('.message_comp').slideDown(100);
|
$('.message_comp').slideDown(100);
|
||||||
|
|||||||
@@ -57,6 +57,12 @@ function report_success(response, status_box) {
|
|||||||
status_box.show();
|
status_box.show();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function report_message(response, status_box) {
|
||||||
|
status_box.removeClass(status_classes).addClass('alert')
|
||||||
|
.text(response).stop(true).fadeTo(0, 1);
|
||||||
|
status_box.show();
|
||||||
|
}
|
||||||
|
|
||||||
var clicking = false;
|
var clicking = false;
|
||||||
var mouse_moved = false;
|
var mouse_moved = false;
|
||||||
|
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ var people_hash = {};
|
|||||||
var selected_message_class = 'selected_message';
|
var selected_message_class = 'selected_message';
|
||||||
var viewport = $(window);
|
var viewport = $(window);
|
||||||
var app_needs_reload = false;
|
var app_needs_reload = false;
|
||||||
|
var reloading_app = false;
|
||||||
|
|
||||||
$(function () {
|
$(function () {
|
||||||
var i;
|
var i;
|
||||||
@@ -511,15 +512,21 @@ function add_messages(data) {
|
|||||||
update_autocomplete();
|
update_autocomplete();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function do_reload_app() {
|
||||||
|
// TODO: We need a better API for showing messages.
|
||||||
|
report_message("The application has been updated; reloading!", $("#reloading-application"));
|
||||||
|
reloading_app = true;
|
||||||
|
window.location.reload(true);
|
||||||
|
}
|
||||||
|
|
||||||
function reload_app() {
|
function reload_app() {
|
||||||
// If we can, reload the page immediately
|
// If we can, reload the page immediately
|
||||||
if (! composing_message()) {
|
if (! composing_message()) {
|
||||||
window.location.reload(true);
|
do_reload_app();
|
||||||
}
|
}
|
||||||
|
|
||||||
// If the user is composing a message, wait until he's done or
|
// If the user is composing a message, wait until he's done or
|
||||||
// until a timeout expires
|
// until a timeout expires
|
||||||
app_needs_reload = true;
|
|
||||||
setTimeout(function () { reload_app_preserving_compose(false); },
|
setTimeout(function () { reload_app_preserving_compose(false); },
|
||||||
1000 * 60 * 5); // 5 minutes
|
1000 * 60 * 5); // 5 minutes
|
||||||
}
|
}
|
||||||
@@ -537,7 +544,7 @@ function reload_app_preserving_compose(send_after_reload) {
|
|||||||
url += "+msg="+ encodeURIComponent(compose_message());
|
url += "+msg="+ encodeURIComponent(compose_message());
|
||||||
|
|
||||||
window.location.replace(url);
|
window.location.replace(url);
|
||||||
window.location.reload(true);
|
do_reload_app();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check if we're doing a compose-preserving reload. This must be
|
// Check if we're doing a compose-preserving reload. This must be
|
||||||
@@ -593,7 +600,11 @@ function get_updates() {
|
|||||||
received.failures = 0;
|
received.failures = 0;
|
||||||
$('#connection-error').hide();
|
$('#connection-error').hide();
|
||||||
|
|
||||||
if (data.server_generation > server_generation) {
|
if (data.server_generation > server_generation && !app_needs_reload) {
|
||||||
|
// We need to set server_generation here to avoid
|
||||||
|
// pounding the server with get_updates requests.
|
||||||
|
server_generation = data.server_generation;
|
||||||
|
app_needs_reload = true;
|
||||||
reload_app();
|
reload_app();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -281,7 +281,7 @@ img.profile_picture {
|
|||||||
display: none;
|
display: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
#connection-error {
|
.home-error-bar {
|
||||||
margin-top: 5px;
|
margin-top: 5px;
|
||||||
display: none;
|
display: none;
|
||||||
}
|
}
|
||||||
@@ -298,7 +298,7 @@ img.profile_picture {
|
|||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
}
|
}
|
||||||
|
|
||||||
#connection-error .alert {
|
.home-error-bar .alert {
|
||||||
margin-bottom: auto;
|
margin-bottom: auto;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user