liamcain / obsidian-calendar-plugin

Simple calendar widget for Obsidian.
MIT License
1.62k stars 141 forks source link

Locale Override Broken in Obsidian v1.7.3 #375

Open iiz00 opened 2 weeks ago

iiz00 commented 2 weeks ago

Describe the bug

The locale override feature appears to be broken in recent Obsidian insider versions (starting from v1.7.2 or v1.7.3?). This feature had been working flawlessly for years until recently in my environment. Rolling back to the public release of Obsidian seems to resolve the issue.

Steps to reproduce

  1. Incorrect Daily Note Naming

    • Despite selecting Override locale in the Calendar plugin settings (in my case, overriding "system locale(ja)" to "en-sg" with filename format YYYY-MM-DD_dddd), daily notes are created using the pre-override language.
    • Example: Creates '2024-10-03_木曜日' instead of '2024-10-03_Thursday', breaking filename consistency with existing daily notes.
  2. Settings Display Issues

    • The Calendar plugin settings screen randomly fails to load completely (sometimes it does load fully; specific conditions unknown).
    • Console displays the following error:
      plugin:calendar:814 Uncaught TypeError: Cannot read properties of undefined (reading 'dow')
       at CalendarSettingsTab.addWeekStartSetting (plugin:calendar:814:66)
       at CalendarSettingsTab.display (plugin:calendar:775:14)
       at t.openTab (app.js:1:3043848)
       at HTMLDivElement.<anonymous> (app.js:1:3042168)
  3. File Access Issues After Plugin Reset

    • After disabling and re-enabling the Calendar plugin:
      • Settings screen loads completely
      • New issue emerges similar to Issue #373
      • New files can be created with the overridden language
      • But, attempting to open these files through Periodic Notes command results in an error
    • Console displays:
      app.js:1 Uncaught (in promise) Error: File already exists.
       at t.<anonymous> (app.js:1:732669)
       at app.js:1:237228
       at Object.next (app.js:1:237333)
       at a (app.js:1:236051)

Screenshots

CalendarSettingsScreen Settings screen fails to show all items

Environment (please specify)

OS

Windows 11

Obsidian Version (e.g. v0.10.6)

v1.7.3 (insider)

iiz00 commented 2 weeks ago

After roughly examining and testing the code, Adding configureGlobalMomentLocale(settings.localeOverride, settings.weekStart); after await this.loadOptions(); on line 4428 of main.js might have improved the situation (I haven't thoroughly verified this, so there might be other issues introduced).

iiz00 commented 2 weeks ago

Hmm, even after the above, things still go wrong after restarting Obsidian... It seems that turning the Calendar plugin and Periodic Notes plugin off and on in sequence fixes it.

ksdavidc commented 17 hours ago

also getting this.

Hmm, even after the above, things still go wrong after restarting Obsidian... It seems that turning the Calendar plugin and Periodic Notes plugin off and on in sequence fixes it.

not sure whatis meant here. could you specify? you mean calendar on and off, then periodic, or calendar off, periodic off, then calendar on and periodic on? Are you reloading after each?

ksdavidc commented 11 hours ago

While testing another plugin, I can now verify that the settings display error is related to whether or not calendar is the visible tab on startup, per sandbox vault. if it is, no error, if it isn't, error.

iiz00 commented 7 hours ago

My current workaround for this issue is as follows:

  1. Modify the main.js file of the Calendar plugin as mentioned previously.
  2. After launching Obsidian, restart the plugins in this order: Calendar plugin, then Periodic Notes plugin. If the Calendar plugin's view is already displayed, restarting the Calendar plugin might not be necessary.

Here's my speculation about this bug (which may be incorrect):

The main.js modification mentioned above is intended to perform locale override processing during the Calendar plugin's startup. However, due to potential issues with the startup order between Calendar and Periodic Notes plugins (or perhaps other factors), it seems necessary to restart each plugin as described above for proper functionality. Creating a Templater script to automatically restart the plugins might be more convenient... The ideal solution would be to integrate the locale override functionality (and perhaps even the Calendar and Periodic Notes features) into Obsidian's core functionality 😄

ksdavidc commented 6 hours ago

I see very clear thank you much appreciated

On Mon, Oct 21, 2024, 12:44 iiz00 @.***> wrote:

My current workaround for this issue is as follows:

  1. Modify the main.js file of the Calendar plugin as mentioned previously.
  2. After launching Obsidian, restart the plugins in this order: Calendar plugin, then Periodic Notes plugin. If the Calendar plugin's view is already displayed, restarting the Calendar plugin might not be necessary.

Here's my speculation about this bug (which may be incorrect):

  • The locale override processing in the Calendar plugin seems to occur during the plugin's custom view rendering, not during plugin startup.
  • In Obsidian v1.7.2, to improve startup times, view rendering is skipped when a plugin's view is not in the foreground (I haven't thoroughly investigated this). As a result, if the Calendar view is not displayed, the locale override processing doesn't occur. This leads to failures when trying to open the settings page, causing it to display only partially. It also causes plugins that use locale override, such as Periodic Notes, to malfunction.

The main.js modification mentioned above is intended to perform locale override processing during the Calendar plugin's startup. However, due to potential issues with the startup order between Calendar and Periodic Notes plugins (or perhaps other factors), it seems necessary to restart each plugin as described above for proper functionality. Creating a Templater script to automatically restart the plugins might be more convenient... The ideal solution would be to integrate the locale override functionality (and perhaps even the Calendar and Periodic Notes features) into Obsidian's core functionality 😄

— Reply to this email directly, view it on GitHub https://github.com/liamcain/obsidian-calendar-plugin/issues/375#issuecomment-2425508157, or unsubscribe https://github.com/notifications/unsubscribe-auth/AO2Y35CAR3A2ZYD5CCHYVKDZ4R2BBAVCNFSM6AAAAABPJJSMF6VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDIMRVGUYDQMJVG4 . You are receiving this because you commented.Message ID: @.***>