client: Fix flicker of font selection

This commit is contained in:
Elian Doran 2024-10-27 21:03:13 +02:00
parent 514653fb50
commit 41e3163595
No known key found for this signature in database
3 changed files with 24 additions and 4 deletions

View File

@ -50,6 +50,9 @@ class NoteContextAwareWidget extends BasicWidget {
/**
* @inheritdoc
*
* <p>
* If the widget is not enabled, it will not receive `refreshWithNote` updates.
*
* @returns {boolean} true when an active note exists
*/
isEnabled() {

View File

@ -133,14 +133,17 @@ export default class FontsOptions extends OptionsWidget {
this.$widget.find(".reload-frontend-button").on("click", () => utils.reloadFrontendApp("changes from appearance options"));
}
isEnabled() {
return this._isEnabled;
}
async optionsLoaded(options) {
if (options.overrideThemeFonts !== 'true') {
this.toggleInt(false);
this._isEnabled = (options.overrideThemeFonts === 'true');
this.toggleInt(this._isEnabled);
if (!this._isEnabled) {
return;
}
this.toggleInt(true);
this.$mainFontSize.val(options.mainFontSize);
this.fillFontFamilyOptions(this.$mainFontFamily, options.mainFontFamily);

View File

@ -44,6 +44,20 @@ export default class OptionsWidget extends NoteContextAwareWidget {
optionsLoaded(options) {}
async refresh() {
this.toggleInt(this.isEnabled());
try {
await this.refreshWithNote(this.note);
} catch (e) {
// Ignore errors when user is refreshing or navigating away.
if (e === "rejected by browser") {
return;
}
throw e;
}
}
async refreshWithNote(note) {
const options = await server.get('options');