FIX: Do not set color_scheme_id in user options when no schemes are marked as selectable

This commit is contained in:
Penar Musaraj 2020-08-30 09:32:40 -04:00
parent 7bba65b6f5
commit b4c5f6631f
No known key found for this signature in database
GPG Key ID: E390435D881FF0F7
2 changed files with 9 additions and 9 deletions

View File

@ -36,6 +36,7 @@ export default Controller.extend({
selectedColorSchemeId: null,
selectedDarkColorSchemeId: null,
preferencesController: inject("preferences"),
makeColorSchemeDefault: true,
init() {
this._super(...arguments);
@ -46,8 +47,8 @@ export default Controller.extend({
});
},
@discourseComputed("makeThemeDefault", "makeColorSchemeDefault")
saveAttrNames(makeThemeDefault, makeColorSchemeDefault) {
@discourseComputed("makeThemeDefault")
saveAttrNames(makeThemeDefault) {
let attrs = [
"locale",
"external_links_in_new_tab",
@ -61,17 +62,15 @@ export default Controller.extend({
"hide_profile_and_presence",
"text_size",
"title_count_mode",
"skip_new_user_tips"
"skip_new_user_tips",
"color_scheme_id",
"dark_scheme_id"
];
if (makeThemeDefault) {
attrs.push("theme_ids");
}
if (makeColorSchemeDefault) {
attrs.push("color_scheme_id");
attrs.push("dark_scheme_id");
}
return attrs;
},
@ -230,7 +229,9 @@ export default Controller.extend({
this.set("model.user_option.text_size", this.textSize);
}
if (this.makeColorSchemeDefault) {
if (!this.showColorSchemeSelector) {
this.set("model.user_option.color_scheme_id", null);
} else if (this.makeColorSchemeDefault) {
this.set(
"model.user_option.color_scheme_id",
this.selectedColorSchemeId

View File

@ -12,7 +12,6 @@ export default RestrictedUserRoute.extend({
makeThemeDefault:
!user.get("user_option.theme_ids") ||
currentThemeId() === user.get("user_option.theme_ids")[0],
makeColorSchemeDefault: !user.get("user_option.color_scheme_id"),
makeTextSizeDefault:
user.get("currentTextSize") === user.get("user_option.text_size")
});