mirror of
https://github.com/zulip/zulip.git
synced 2025-11-15 11:22:04 +00:00
Properly start tutorial on first run, even if you have new messages.
We were previously having an issue where the tutorial could be pre-empted if you got a few messages while you were first logging in. I have some reservations about this being slightly fragile, and a better approach might be to just have a bit that we use to determine whether or not you've already seen a tutorial. (Or potentially that checks whether or not you've ever sent a message.) (imported from commit f8858f64a36bcd25887b76314caff283929f340c)
This commit is contained in:
@@ -66,6 +66,7 @@ var have_initial_messages = {{ have_initial_messages|escapejs }};
|
||||
var desktop_notifications_enabled = {{ desktop_notifications_enabled|escapejs }};
|
||||
var enter_sends = {{ enter_sends|escapejs }};
|
||||
var debug_mode = {% if debug %} true {% else %} false {% endif %};
|
||||
var needs_tutorial = {{ needs_tutorial|escapejs }};
|
||||
|
||||
{# We use JSONEncoderForHTML to generate "streams". #}
|
||||
var stream_list = {{ streams }};
|
||||
|
||||
@@ -8,7 +8,7 @@ var globals =
|
||||
// index.html
|
||||
+ ' initial_pointer email stream_list people_list have_initial_messages'
|
||||
+ ' fullname desktop_notifications_enabled enter_sends domain poll_timeout'
|
||||
+ ' debug_mode'
|
||||
+ ' debug_mode needs_tutorial'
|
||||
|
||||
// common.js
|
||||
+ ' status_classes'
|
||||
|
||||
@@ -9,12 +9,8 @@ $(function () {
|
||||
if (have_initial_messages) {
|
||||
util.make_loading_indicator($('#page_loading_indicator'), 'Loading...');
|
||||
} else {
|
||||
try {
|
||||
tutorial.run_when_ready();
|
||||
} catch (e) {
|
||||
util.show_first_run_message();
|
||||
}
|
||||
}
|
||||
|
||||
// Compile Handlebars templates.
|
||||
$.each(['message', 'subscription',
|
||||
|
||||
@@ -287,14 +287,10 @@ exports.is_running = function () {
|
||||
return tutorial_running;
|
||||
};
|
||||
|
||||
var should_autostart_tutorial = false;
|
||||
exports.run_when_ready = function () {
|
||||
should_autostart_tutorial = true;
|
||||
};
|
||||
|
||||
exports.initialize = function () {
|
||||
make_script();
|
||||
if (should_autostart_tutorial) {
|
||||
// Global variable populated by the server code
|
||||
if (needs_tutorial) {
|
||||
exports.start();
|
||||
}
|
||||
};
|
||||
|
||||
@@ -381,6 +381,11 @@ def home(request):
|
||||
|
||||
num_messages = UserMessage.objects.filter(user_profile=user_profile).count()
|
||||
|
||||
needs_tutorial = False
|
||||
if user_profile.pointer == -1:
|
||||
# Brand new user, give them a tutorial
|
||||
needs_tutorial = True
|
||||
|
||||
if user_profile.pointer == -1 and num_messages > 0:
|
||||
# Put the new user's pointer at the bottom
|
||||
#
|
||||
@@ -431,6 +436,7 @@ def home(request):
|
||||
'show_debug':
|
||||
settings.DEBUG and ('show_debug' in request.GET),
|
||||
'show_invites': show_invites,
|
||||
'needs_tutorial': js_bool(needs_tutorial)
|
||||
},
|
||||
context_instance=RequestContext(request))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user