mirror of
https://github.com/zulip/zulip.git
synced 2025-11-16 03:41:58 +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 () {
|
exports.start = function () {
|
||||||
if (tutorial_running) {
|
if (tutorial_running) {
|
||||||
// Not more than one of these at once!
|
// Not more than one of these at once!
|
||||||
@@ -240,13 +249,7 @@ exports.start = function () {
|
|||||||
tutorial_running = true;
|
tutorial_running = true;
|
||||||
add_to_tutorial_stream();
|
add_to_tutorial_stream();
|
||||||
run_tutorial(0);
|
run_tutorial(0);
|
||||||
|
set_tutorial_status("started");
|
||||||
$.ajax({
|
|
||||||
type: 'POST',
|
|
||||||
url: '/json/tutorial_status',
|
|
||||||
data: {status: 'started'}
|
|
||||||
});
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// This technique is not actually that awesome, because it's pretty
|
// This technique is not actually that awesome, because it's pretty
|
||||||
@@ -263,16 +266,10 @@ exports.stop = function () {
|
|||||||
if (tutorial_running) {
|
if (tutorial_running) {
|
||||||
subs.tutorial_unsubscribe_me_from(my_tutorial_stream);
|
subs.tutorial_unsubscribe_me_from(my_tutorial_stream);
|
||||||
tutorial_running = false;
|
tutorial_running = false;
|
||||||
|
set_tutorial_status("finished", function () {
|
||||||
$.ajax({
|
// We need to reload the streams list so the sidebar is populated
|
||||||
type: 'POST',
|
// with the new streams
|
||||||
url: '/json/tutorial_status',
|
subs.reload_subscriptions({clear_first: true});
|
||||||
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});
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user