mirror of
https://github.com/zulip/zulip.git
synced 2025-11-06 23:13:25 +00:00
tutorial: factor setting tutorial status into a function.
(imported from commit 3ec355e3bcad25bbe8dceb9a1fdb9e8cce5156ca)
This commit is contained in:
@@ -232,6 +232,15 @@ function add_to_tutorial_stream() {
|
||||
}
|
||||
}
|
||||
|
||||
function set_tutorial_status(status, callback) {
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
url: '/json/tutorial_status',
|
||||
data: {status: status},
|
||||
success: callback
|
||||
});
|
||||
}
|
||||
|
||||
exports.start = function () {
|
||||
if (tutorial_running) {
|
||||
// Not more than one of these at once!
|
||||
@@ -240,13 +249,7 @@ exports.start = function () {
|
||||
tutorial_running = true;
|
||||
add_to_tutorial_stream();
|
||||
run_tutorial(0);
|
||||
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
url: '/json/tutorial_status',
|
||||
data: {status: 'started'}
|
||||
});
|
||||
|
||||
set_tutorial_status("started");
|
||||
};
|
||||
|
||||
// This technique is not actually that awesome, because it's pretty
|
||||
@@ -263,16 +266,10 @@ exports.stop = function () {
|
||||
if (tutorial_running) {
|
||||
subs.tutorial_unsubscribe_me_from(my_tutorial_stream);
|
||||
tutorial_running = false;
|
||||
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
url: '/json/tutorial_status',
|
||||
data: {status: 'finished'},
|
||||
success: function () {
|
||||
// We need to reload the streams list so the sidebar is populated
|
||||
// with the new streams
|
||||
subs.reload_subscriptions({clear_first: true});
|
||||
}
|
||||
set_tutorial_status("finished", function () {
|
||||
// We need to reload the streams list so the sidebar is populated
|
||||
// with the new streams
|
||||
subs.reload_subscriptions({clear_first: true});
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user