seanlowe / obsidian-timelines

Create a timeline view of all notes with the specified combination of tags
https://seanlowe.github.io/obsidian-timelines/
MIT License
39 stars 2 forks source link

For plugin to work it must be disabled then re-enabled when Obsidian is opened for the first time in a session #15

Closed Korolebi closed 2 months ago

Korolebi commented 6 months ago

Summary: Consistently every time I open Obsidian for the first time in a session the plug-in does not show timelines in Reader mode. Events are marked as events still, and changes to the CSS file still are passed to the Event Notes

Additional Information: ob-timeline-flat and ob-timeline code block for timeline creator both follow this pattern, however changes made to CSS related to events and the event counter in the property still do work on startup without reloading the plugin. The only issue is the graph themselves. Work around listed below works consistently.

Steps to reproduce: 1.) Close Obsidian 2.) Re-open Obsidian 3.) Observe the lack of timeline Expected Result: I see a timeline in Reader mode Actual Result: Notes with timelines are blank Reproducible: Always. Work Around: 1.) Disable Timeline plug-in in Obsidian Settings 2.) Re-enable Timeline plug-in in Obsidian Settings Severity/Priority: Minor, Low. However, new users who run into similar issues may assume the plugin doesn't work at all so I'm hesitant to say Trivial Additional Plug-ins used: Too many to list, however none performing actions in target folder Plug-in Version: 1.2.0 System/Set-up: Windows 11, Version 10.0.22621 Build 22621. Only tested Desktop. Minimal Theme. Timelines and Events are all located in the same subfolder of the vault with no other notes. Event and Timeline notes have no extra css classes beyond those required for plug-in use

Console: On start up TypeError is thrown ->

Uncaught (in promise) TypeError: Cannot read properties of null (reading 'file')
    at TimelineProcessor.eval (VM243 plugin:timelines-revamped:37222:78)
    at Generator.next (<anonymous>)
    at eval (VM243 plugin:timelines-revamped:31:71)
    at new Promise (<anonymous>)
    at __awaiter (VM243 plugin:timelines-revamped:27:12)
    at TimelineProcessor.getStatusBarText (VM243 plugin:timelines-revamped:37221:16)
    at TimelinesPlugin.eval (VM243 plugin:timelines-revamped:37625:42)
    at Generator.next (<anonymous>)
    at eval (VM243 plugin:timelines-revamped:31:71)
    at new Promise (<anonymous>)
ReconVirus commented 4 months ago

I havent tested this out myself but a solution might be update

getStatusBarText = async ( workspace: Workspace ): Promise<string | null> => {
    const file = workspace.getActiveViewOfType( MarkdownView )?.file

    if ( !file ) {
      return null
    }

    const { totalEvents } = await getNumEventsInFile({ file, appVault: this.appVault, fileCache: this.metadataCache }, null )

    switch ( totalEvents ) {
    case 0:
      return 'Timeline: No events'
    case 1:
      return 'Timeline: 1 event'
    default:
      return `Timeline: ${totalEvents} events`
    }
  }
}

to split the line into two parts:

const activeView = workspace.getActiveViewOfType( MarkdownView );
if ( !activeView ) {
  return null;
}
const file = activeView.file;

This way, you’re not trying to access the file property until after you’ve checked that activeView is not null or undefined.

seanlowe commented 4 months ago

Hm, yeah that's entirely possible. I'll test it out. Thanks for the suggestion!

Shred99 commented 4 months ago

I have exactly the same issue as the OP. When I updated to v2.1.3, my ob-timeline-flat timelines stopped working and I couldn't fix it. As a test, changing one of them to ob-timeline made it render again (albeit incorrectly).

I've reverted to the old version of the plugin and normal operation has been restored - as in, start Obsidian, turn the plugin off and on again, and my timelines appear.

seanlowe commented 4 months ago

@Shred99 Please take a look at the changelog for version 2.0.0 to review the note on the breaking changes I made there.

TL;DR -> there is no ob-timeline-flat anymore. Add a type=flat onto your old ob-timeline-flat codeblock.

Shred99 commented 4 months ago

Add a type=flat onto your old ob-timeline-flat codeblock.

Bah. You're absolutely right. A quick find and replace and it works perfectly. Thank you,

seanlowe commented 2 months ago

@Korolebi @ReconVirus would either of you guys be able to check that this bug still exists? I haven't run into it in a long time so either I fixed it unknowingly or one of the recent updates fixed it and I don't remember that I did it.

ReconVirus commented 2 months ago

@Korolebi @ReconVirus would either of you guys be able to check that this bug still exists? I haven't run into it in a long time so either I fixed it unknowingly or one of the recent updates fixed it and I don't remember that I did it.

On my end i havent had this issue when using your plugin

Korolebi commented 2 months ago

@Korolebi @ReconVirus would either of you guys be able to check that this bug still exists? I haven't run into it in a long time so either I fixed it unknowingly or one of the recent updates fixed it and I don't remember that I did it.

Just saw this, I've been working in a whole different universe so haven't used this plugin in a minute. Replying now after redownloading it and setting up a new vault with some dummy data and no other plugins to test for you. From what I can tell the issue I was running into is completely resolved.

No idea what fixed it or when, and my parents warned me that Typescript is the devil so I won't go digging around to find out. Good job however you fixed it, was a minor thing but it drove me up the wall