mirror of
https://github.com/zulip/zulip.git
synced 2025-11-03 21:43:21 +00:00
settings: Add backend storage and interface for night mode.
This allows the night mode setting to be stored in the backend.
This commit is contained in:
committed by
Tim Abbott
parent
2b43a0302a
commit
f9f0f356be
@@ -2,6 +2,33 @@ var settings_display = (function () {
|
||||
|
||||
var exports = {};
|
||||
|
||||
exports.set_night_mode = function (bool) {
|
||||
var night_mode = bool;
|
||||
var data = { night_mode: JSON.stringify(night_mode) };
|
||||
var context = {
|
||||
enable_text: data.night_mode === "true" ?
|
||||
i18n.t("enabled") :
|
||||
i18n.t("disabled"),
|
||||
};
|
||||
|
||||
channel.patch({
|
||||
url: '/json/settings/display',
|
||||
data: data,
|
||||
success: function () {
|
||||
page_params.night_mode = night_mode;
|
||||
if (overlays.settings_open()) {
|
||||
ui_report.success(i18n.t("Night mode __enable_text__!", context),
|
||||
$('#display-settings-status').expectOne());
|
||||
}
|
||||
},
|
||||
error: function (xhr) {
|
||||
if (overlays.settings_open()) {
|
||||
ui_report.error(i18n.t("Error updating night mode setting."), xhr, $('#display-settings-status').expectOne());
|
||||
}
|
||||
},
|
||||
});
|
||||
};
|
||||
|
||||
exports.set_up = function () {
|
||||
$("#display-settings-status").hide();
|
||||
|
||||
@@ -71,6 +98,10 @@ exports.set_up = function () {
|
||||
});
|
||||
});
|
||||
|
||||
$("#night_mode").change(function () {
|
||||
exports.set_night_mode(this.checked);
|
||||
});
|
||||
|
||||
$("#left_side_userlist").change(function () {
|
||||
var left_side_userlist = this.checked;
|
||||
var data = {};
|
||||
|
||||
Reference in New Issue
Block a user