chrisgrieser / shimmering-obsidian

Alfred Workflow with dozens of features for controlling your Obsidian vault.
https://alfred.app/workflows/chrisgrieser/shimmering-obsidian/
MIT License
850 stars 41 forks source link

[Bug]: `ol` is one page behind #88

Closed bramses closed 2 years ago

bramses commented 2 years ago

Bug Description

Hi! Amazing work on Shimmering, I'm wildly impressed :)

ol seems to be one note behind. Say I'm on File A and I run ol. But if I then open File B and run ol I get the links from File A.

I think it might have to do with active path not updating in .obsidian but I'm not sure.

function readFile (path, encoding) {
        if (!encoding) encoding = $.NSUTF8StringEncoding;
        const fm = $.NSFileManager.defaultManager;
        const data = fm.contentsAtPath(path);
        const str = $.NSString.alloc.initWithDataEncoding(data, encoding);
        return ObjC.unwrap(str);
    }

    const vaultPath = $.getenv("vault_path").replace(/^~/, app.pathTo("home folder"));
    const activeFile = JSON.parse(readFile(vaultPath + "/.obsidian/workspace"))
        .lastOpenFiles[0];

    return activeFile;

Relevant Screenshot

I'm currently on this page (as in, its open in Obsidian, being edited) but ol is looking at the last page (debugging log below)

Screenshot 2022-07-16 20-46-07

To Reproduce

No response

Debugging Log

{"items":[{"title":"⬅️ 🕑 2022-W29","match":"recent  2022 W29 2022-W29 ","subtitle":"▸ Weekly","type":"file:skipcheck","quicklookurl"...

Workflow Configuration

Screenshot 2022-07-16 20-47-36

Version & System Information

-------------------------------
Metadata JSONs: 3/3
Metadata String Length: 4948599
-------------------------------
INSTALLED VERSION
macOS: 12.4
Alfred: 4.6.4

Obsidian: 0.15.6
This Workflow: 2.26.8
Advanced URI Plugin: 1.23.0
Metadata Extractor: 1.0.2
-------------------------------
LATEST VERSION
Obsidian: 0.15.6 (Insider: 0.15.6)
This Workflow: 2.26.8
Advanced URI Plugin: 1.23.0
Metadata Extractor: 1.0.2
-------------------------------

Make sure you have done the following

chrisgrieser commented 2 years ago

yeah, it seems with the newer Obsidian versions, the workspace file only contains the last files opened, not the current file. I switched the method of retrieving the active file in the latest release, this should work now.