mirror of
https://github.com/TriliumNext/Notes.git
synced 2025-10-24 16:21:32 +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
|
||||
*
|
||||
* <p>
|
||||
* If the widget is not enabled, it will not receive `refreshWithNote` updates.
|
||||
*
|
||||
* @returns {boolean} true when an active note exists
|
||||
*/
|
||||
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"));
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
|
||||
@ -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');
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user