Skip to content

Commit a8aa7e4

Browse files
authored
fix: Don't defer ribbon configuration (#222)
Bug: The ribbon items are added too late (after Obsidian applies the sort based on the workspace preferences). This ensures that the ribbon items are added before the workspace finishes loading.
1 parent 44b561a commit a8aa7e4

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

src/main.ts

+9-9
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,12 @@ export default class PeriodicNotesPlugin extends Plugin {
6464
}
6565

6666
async onload(): Promise<void> {
67+
addIcon("calendar-day", calendarDayIcon);
68+
addIcon("calendar-week", calendarWeekIcon);
69+
addIcon("calendar-month", calendarMonthIcon);
70+
addIcon("calendar-quarter", calendarQuarterIcon);
71+
addIcon("calendar-year", calendarYearIcon);
72+
6773
this.settings = writable<ISettings>();
6874
await this.loadSettings();
6975
this.register(this.settings.subscribe(this.onUpdateSettings.bind(this)));
@@ -77,12 +83,9 @@ export default class PeriodicNotesPlugin extends Plugin {
7783

7884
this.openPeriodicNote = this.openPeriodicNote.bind(this);
7985
this.addSettingTab(new PeriodicNotesSettingsTab(this.app, this));
80-
81-
addIcon("calendar-day", calendarDayIcon);
82-
addIcon("calendar-week", calendarWeekIcon);
83-
addIcon("calendar-month", calendarMonthIcon);
84-
addIcon("calendar-quarter", calendarQuarterIcon);
85-
addIcon("calendar-year", calendarYearIcon);
86+
87+
this.configureRibbonIcons();
88+
this.configureCommands();
8689

8790
this.addCommand({
8891
id: "show-date-switcher",
@@ -109,9 +112,6 @@ export default class PeriodicNotesPlugin extends Plugin {
109112
});
110113

111114
this.app.workspace.onLayoutReady(() => {
112-
this.configureRibbonIcons();
113-
this.configureCommands();
114-
115115
const startupNoteConfig = findStartupNoteConfig(this.settings);
116116
if (startupNoteConfig) {
117117
this.openPeriodicNote(startupNoteConfig.granularity, window.moment(), {

0 commit comments

Comments
 (0)