Skip to content

Conversation

@jordanvidrine
Copy link
Contributor

Fairly straightforward refactor.

Before After
CleanShot 2025-12-15 at 15 20 04@2x CleanShot 2025-12-15 at 15 19 40@2x

@jordanvidrine jordanvidrine marked this pull request as ready for review December 15, 2025 21:20
Copy link
Contributor

@martin-brennan martin-brennan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a minor change so far, but we do need a system spec here. Also you have some failing tests

</template>
this.args.model
.save(this.saveAttrNames)
.catch(popupAjaxError)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you will need to handle rolling back the model values on error here

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think .save() is what actually changes these items. I looked at the way other controllers for these preferences were doing it.

@action
save() {
this.set("saved", false);
return this.model
.save(this.saveAttrNames)
.then(() => this.set("saved", true))
.catch(popupAjaxError);
}

@action
save() {
this.set("saved", false);
const makeThemeDefault = this.makeThemeDefault;
if (makeThemeDefault) {
this.set("model.user_option.theme_ids", [this.themeId]);
}
const makeTextSizeDefault = this.makeTextSizeDefault;
if (makeTextSizeDefault) {
this.set("model.user_option.text_size", this.textSize);
}
if (!this.showColorSchemeSelector) {
this.set("model.user_option.color_scheme_id", null);
this.set("model.user_option.dark_scheme_id", null);
} else if (this.makeColorSchemeDefault) {
this.set("model.user_option.color_scheme_id", this.selectedColorSchemeId);
this.set(
"model.user_option.dark_scheme_id",
this.selectedDarkColorSchemeId
);
if (this.selectedInterfaceColorModeId) {
this.set(
"model.user_option.interface_color_mode",
this.selectedInterfaceColorModeId
);
}
}
return this.model
.save(this.saveAttrNames)
.then(() => {
this.set("saved", true);
if (makeThemeDefault) {
setLocalTheme([]);
} else {
setLocalTheme(
[this.themeId],
this.get("model.user_option.theme_key_seq")
);
}
if (makeTextSizeDefault) {
this.model.updateTextSizeCookie(null);
} else {
this.model.updateTextSizeCookie(this.textSize);
}
if (this.makeColorSchemeDefault) {
updateColorSchemeCookie(null);
updateColorSchemeCookie(null, { dark: true });
} else {
updateColorSchemeCookie(this.selectedColorSchemeId);
if (
this.defaultDarkSchemeId > 0 &&
this.selectedDarkColorSchemeId === this.defaultDarkSchemeId
) {
updateColorSchemeCookie(null, { dark: true });
} else {
updateColorSchemeCookie(this.selectedDarkColorSchemeId, {
dark: true,
});
}
}
if (this.selectedInterfaceColorModeId) {
if (this.isViewingOwnProfile) {
const modeId = this.selectedInterfaceColorModeId;
if (modeId === INTERFACE_COLOR_MODES.AUTO) {
this.interfaceColor.useAutoMode();
} else if (modeId === INTERFACE_COLOR_MODES.LIGHT) {
this.interfaceColor.forceLightMode();
} else if (modeId === INTERFACE_COLOR_MODES.DARK) {
this.interfaceColor.forceDarkMode();
}
}
this.selectedInterfaceColorModeId = null;
}
this.homeChanged();
if (this.themeId && this.themeId !== this.currentThemeId) {
reload();
}
})
.catch(popupAjaxError);
}

@jordanvidrine
Copy link
Contributor Author

we do need a system spec here

I have added one, and removed a dated one that no longer seemed to be in use.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants