mirror of https://github.com/zulip/zulip.git
settings_ui: Revert extension for success callback in do_settings_change.
This reverts success callback extension for `do_settings_change` function because it seems it is better to make the request directly rather than calling `do_settings_change`. And hence `error` callback extension is also removed for the same reason, but a error_continuation is added to do additional tasks when errors happened.
This commit is contained in:
parent
aac76c14bd
commit
ce156dd21d
|
@ -26,41 +26,36 @@ exports.initialize = function () {
|
||||||
// UI. Intended to replace the old system that was built around
|
// UI. Intended to replace the old system that was built around
|
||||||
// direct calls to `ui_report`.
|
// direct calls to `ui_report`.
|
||||||
exports.do_settings_change = function (request_method, url, data, status_element, opts) {
|
exports.do_settings_change = function (request_method, url, data, status_element, opts) {
|
||||||
var success;
|
var spinner = $(status_element).expectOne();
|
||||||
|
loading.make_indicator(spinner, {text: exports.strings.saving});
|
||||||
var success_msg;
|
var success_msg;
|
||||||
var success_continuation;
|
var success_continuation;
|
||||||
var error;
|
var error_continuation;
|
||||||
var spinner = $(status_element).expectOne();
|
|
||||||
if (opts !== undefined) {
|
if (opts !== undefined) {
|
||||||
success = opts.success;
|
|
||||||
success_msg = opts.success_msg;
|
success_msg = opts.success_msg;
|
||||||
success_continuation = opts.success_continuation;
|
success_continuation = opts.success_continuation;
|
||||||
error = opts.error;
|
error_continuation = opts.error_continuation;
|
||||||
}
|
}
|
||||||
if (success_msg === undefined) {
|
if (success_msg === undefined) {
|
||||||
success_msg = exports.strings.success;
|
success_msg = exports.strings.success;
|
||||||
}
|
}
|
||||||
if (success === undefined) {
|
|
||||||
loading.make_indicator(spinner, {text: exports.strings.saving});
|
|
||||||
success = function (reponse_data) {
|
|
||||||
ui_report.success(success_msg, $(status_element).expectOne());
|
|
||||||
settings_ui.display_checkmark(spinner);
|
|
||||||
if (success_continuation !== undefined) {
|
|
||||||
success_continuation(reponse_data);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
if (error === undefined) {
|
|
||||||
error = function (xhr) {
|
|
||||||
ui_report.error(exports.strings.failure, xhr, $(status_element).expectOne());
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
request_method({
|
request_method({
|
||||||
url: url,
|
url: url,
|
||||||
data: data,
|
data: data,
|
||||||
success: success,
|
success: function (reponse_data) {
|
||||||
error: error,
|
ui_report.success(success_msg, spinner);
|
||||||
|
settings_ui.display_checkmark(spinner);
|
||||||
|
if (success_continuation !== undefined) {
|
||||||
|
success_continuation(reponse_data);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
error: function (xhr) {
|
||||||
|
ui_report.error(exports.strings.failure, xhr, spinner);
|
||||||
|
if (error_continuation !== undefined) {
|
||||||
|
error_continuation(xhr);
|
||||||
|
}
|
||||||
|
},
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue