Skip to content

Open Weekly Note crashes if calendar view hasn't been opened yet #377

Open
@oowekyala

Description

@oowekyala

Describe the bug

The command "Open Weekly Note" crashes with "Uncaught TypeError" when the calendar view has not been opened yet.

Steps to reproduce

  1. Open obsidian, do not show the calendar view
  2. Execute "Open Weekly Note" from command palette

Nothing happens but an error is logged in the console:

Uncaught TypeError: Cannot read properties of undefined (reading 'openOrCreateWeeklyNote')
    at Object.checkCallback (plugin:calendar:4419:27)
    at OK (app.js:1:2117643)
    at t.onChooseItem (app.js:1:2726336)
    at t.onChooseSuggestion (app.js:1:1760272)
    at t.selectSuggestion (app.js:1:1759742)
    at e.useSelectedItem (app.js:1:1433276)
    at Object.func (app.js:1:1430675)
    at e.handleKey (app.js:1:754496)
    at e.onKeyEvent (app.js:1:755752)

It's this line:

this.view.openOrCreateWeeklyNote(window.moment(), false);

The view field is undefined and this crashes the function.

Note that you have to start obsidian in such a state that the calendar view is not created on startup (i think). For instance if you open the calendar view then slide the pane out of view, the command works, presumably because the view still exists somewhere. However if you blend out the pane, then shutdown and restart obsidian, then that view is not created on startup.

Expected behavior

Weekly note is opened whether calendar view has been opened or not

Environment (please specify)

OS

Linux

Obsidian Version (e.g. v0.10.6)

(Settings → About → Current Version)
v1.7.4

Calendar version 1.5.10

Thank you for this plugin!

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions