uphy / obsidian-reminder

Reminder plugin for Obsidian
https://uphy.github.io/obsidian-reminder/
MIT License
453 stars 35 forks source link

[Bug]: Reminders no longer loading with system notifications or non-system on MacOS #201

Open rey-hernandez opened 1 month ago

rey-hernandez commented 1 month ago

Describe the bug

Obsidian: Version 1.7.4 (Installer 1.4.16) Reminder: Version 1.1.15

In the last couple of days, the reminder plugin no longer notifies me of tasks that are due. I am using both the Task format and the Reminder format. Opening Developer Tools, I see these errors in an interval that seems to be whenever it looks for new reminders: plugin:obsidian-reminder-plugin:16775 Uncaught (in promise) TypeError: view.reload is not a function at eval (plugin:obsidian-reminder-plugin:16775:38) at Array.forEach () at ReminderListItemViewProxy.reload (plugin:obsidian-reminder-plugin:16775:15) at ReminderPlugin.eval (plugin:obsidian-reminder-plugin:17008:22) at Generator.next () at eval (plugin:obsidian-reminder-plugin:50:61) at new Promise () at __async (plugin:obsidian-reminder-plugin:34:10) at ReminderPlugin.periodicTask (plugin:obsidian-reminder-plugin:17007:12) at eval (plugin:obsidian-reminder-plugin:17000:14)

Expected Behavior

Reminders should work

Steps to reproduce

Install the latest reminder plugin with the latest Obsidian Configure the plugin Make a note with one of the defined reminder formats Wait for it to fire it does not fire Console shows weird errors. Hotkeys for scanning reminders and showing reminders don't do anything either.

Operating system

macOS

alexanderzeh commented 3 weeks ago

I have the same issue. IIRC the problem appeared roughly at the time when the new desktop version 1.7.4 was released. (https://obsidian.md/changelog/2024-10-16-desktop-v1.7.4/)

There's this part in the release notes:

Views now load only when visible, improving startup performance and memory usage. This might cause issues with some plugins. We have published a guide to help developers update their plugins.

Maybe this is related to the issue?

rey-hernandez commented 3 weeks ago

Ah, maybe. I noticed that when I startup Obsidian, if I disable and re-enable the Reminder plugin it ends up working. But it isn't consistent, eventually it'll stop and I need to reload it again.

alexanderzeh commented 3 weeks ago

Ha, thanks for that little workaround. Not ideal, but better have to reload the plugin once every morning than not have it working at all.

sbsamarski commented 2 weeks ago

@uphy Any plans to update the plugin? It doesn't work any more since Obsidian 1.7.4 update, on any OS.

apagnz commented 2 weeks ago

@rey-hernandez Thanks so much for this. It's been driving me crazy so I'm very thankful to have it working again!

telemak0 commented 4 days ago

Hello everyone, I found a workaround. I don't develop Obsidian extensions so I don't know if this is the right way to fix this but it's doing the job. I haven't made a PR for that same reason (and because @uphy appears to be inactive).

Find your vault, inside there's an .obsidian folder. Navigate to plugins/obsidian-reminder-plugin/main.js. Locate the view.reload() line that is causing the issue.

Select the complete reload method (in case you don't understand javascript, just replace from the reload(force... line up to the third closing bracket } at the end, 12 lines in total) and replace it with this one:

  reload(force = false) {
    if (force || !this.valid) {
      const views = this.getLeafs();
      if (views.length > 0) {
        views.forEach((view) => {
            view.setViewState({ type: VIEW_TYPE_REMINDER_LIST, active: true });
        });
        this.valid = true;
      } else {
        this.valid = false;
        console.debug("view is null.  Skipping reminder list view reload");
      }
    }
  }
  getLeafs() {
    return this.workspace.getLeavesOfType(VIEW_TYPE_REMINDER_LIST);
  }

Now just save the file and reload Obsidian.

This will get removed if Uphy updates the extension, which I guess would contain this fix if he does.

alexanderzeh commented 4 days ago

@telemak0 Thank you so much! šŸ™ It works for me as well. I was already considering using a different app for my tasks/reminders, but it's so much better to have everything in one place. šŸ™‚

sbsamarski commented 4 days ago

Thanks @telemak0 ! šŸ™ Looks like your solution is working OK...

Btw, can we replace the 3 getViews lines at the end as well, so in total 15 lines? Since, it looks like you replaced getViews with getLeafs?

rey-hernandez commented 4 days ago

How do we get this into the actual reminders plugin? This is great, working for me as well! I ended up just commenting out the offending lines and adding the new ones just to make sure, but yeah, replacing reload and getViews with the new reload and getLeafs seems to do the trick.

telemak0 commented 4 days ago

@sbsamarski yeah, it looks like getViews() is not used anywhere else, so you can replace it with the new getLeafs(). I should have also renamed the variable to leafs instead of views etc, it was just a hack-y temporal fix in the meantime.

Happy to hear is working for you guys too. Lets hope Uphy comes back and updates this.

rey-hernandez commented 2 days ago

One area that may be related to this change, I notice when I am editing any notes with reminders, the note I'm in loses focus. I wonder if this is happening because of the refresh of the views/leafs now that it is identifying the reminders correctly? Has anyone else noticed this?