mirror of https://github.com/zulip/zulip.git
Show a user-visible error message when mirroring is not working.
The main problem with this code is that the error message doesn't go away until you reload. To fix this, we need to add a noblock option on get_updates. (imported from commit dc45af397bcf06a218bda5dd224ebd5fdf3462db)
This commit is contained in:
parent
eefa5b2d7b
commit
fac24df233
|
@ -179,7 +179,12 @@ var people_list = [
|
|||
<strong>Can't receive messages</strong>
|
||||
— retrying soon. <a class="cursor_pointer" onclick="restart_get_updates({dont_block: true});">Try now</a>.
|
||||
</div>
|
||||
<div class="alert alert_sidebar alert-error home-error-bar" id="reloading-application">
|
||||
<div class="alert alert_sidebar alert-error home-error-bar" id="zephyr-mirror-error">
|
||||
<strong>Messages you send are not being mirrored to MIT zephyr</strong>
|
||||
— Please check that you are still running the MIT
|
||||
Zephyr mirroring bot. <a class="cursor_pointer" onclick="restart_get_updates({dont_block: true});">Check now</a>
|
||||
</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="stream-dne">
|
||||
|
|
|
@ -596,6 +596,12 @@ function get_updates(options) {
|
|||
add_messages(data.messages, true);
|
||||
}
|
||||
|
||||
if (data.zephyr_mirror_active === false) {
|
||||
$('#zephyr-mirror-error').show();
|
||||
} else {
|
||||
$('#zephyr-mirror-error').hide();
|
||||
}
|
||||
|
||||
// Pointer sync is disabled for now
|
||||
// if (data.new_pointer !== undefined
|
||||
// && data.new_pointer !== selected_message_id)
|
||||
|
|
|
@ -311,6 +311,17 @@ def format_updates_response(messages=[], apply_markdown=True,
|
|||
'update_types': update_types}
|
||||
if new_pointer is not None:
|
||||
ret['new_pointer'] = new_pointer
|
||||
if user_profile.realm.domain == "mit.edu":
|
||||
try:
|
||||
activity = UserActivity.objects.get(user_profile = user_profile,
|
||||
query="/api/v1/get_messages",
|
||||
client__name="zephyr_mirror")
|
||||
ret['zephyr_mirror_active'] = \
|
||||
(activity.last_visit.replace(tzinfo=None) >
|
||||
datetime.datetime.utcnow() - datetime.timedelta(minutes=5))
|
||||
except UserActivity.DoesNotExist:
|
||||
pass
|
||||
|
||||
return ret
|
||||
|
||||
def format_delayed_updates_response(request=None, user_profile=None,
|
||||
|
@ -331,6 +342,7 @@ def format_delayed_updates_response(request=None, user_profile=None,
|
|||
update_types.append("pointer_update")
|
||||
|
||||
return format_updates_response(new_pointer=pointer,
|
||||
user_profile=user_profile,
|
||||
update_types=update_types, **kwargs)
|
||||
|
||||
def return_messages_immediately(user_profile, client_id, last,
|
||||
|
|
Loading…
Reference in New Issue