mirror of
https://github.com/TriliumNext/Notes.git
synced 2025-10-25 08:51:35 +08:00
client: Fix flicker of font selection
This commit is contained in:
parent
514653fb50
commit
41e3163595
@ -50,6 +50,9 @@ class NoteContextAwareWidget extends BasicWidget {
|
|||||||
/**
|
/**
|
||||||
* @inheritdoc
|
* @inheritdoc
|
||||||
*
|
*
|
||||||
|
* <p>
|
||||||
|
* If the widget is not enabled, it will not receive `refreshWithNote` updates.
|
||||||
|
*
|
||||||
* @returns {boolean} true when an active note exists
|
* @returns {boolean} true when an active note exists
|
||||||
*/
|
*/
|
||||||
isEnabled() {
|
isEnabled() {
|
||||||
|
|||||||
@ -133,14 +133,17 @@ export default class FontsOptions extends OptionsWidget {
|
|||||||
this.$widget.find(".reload-frontend-button").on("click", () => utils.reloadFrontendApp("changes from appearance options"));
|
this.$widget.find(".reload-frontend-button").on("click", () => utils.reloadFrontendApp("changes from appearance options"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
isEnabled() {
|
||||||
|
return this._isEnabled;
|
||||||
|
}
|
||||||
|
|
||||||
async optionsLoaded(options) {
|
async optionsLoaded(options) {
|
||||||
if (options.overrideThemeFonts !== 'true') {
|
this._isEnabled = (options.overrideThemeFonts === 'true');
|
||||||
this.toggleInt(false);
|
this.toggleInt(this._isEnabled);
|
||||||
|
if (!this._isEnabled) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.toggleInt(true);
|
|
||||||
|
|
||||||
this.$mainFontSize.val(options.mainFontSize);
|
this.$mainFontSize.val(options.mainFontSize);
|
||||||
this.fillFontFamilyOptions(this.$mainFontFamily, options.mainFontFamily);
|
this.fillFontFamilyOptions(this.$mainFontFamily, options.mainFontFamily);
|
||||||
|
|
||||||
|
|||||||
@ -44,6 +44,20 @@ export default class OptionsWidget extends NoteContextAwareWidget {
|
|||||||
|
|
||||||
optionsLoaded(options) {}
|
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) {
|
async refreshWithNote(note) {
|
||||||
const options = await server.get('options');
|
const options = await server.get('options');
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user