franciskafieh / obsidian-list-modified

đŸĒ¨ The advanced and adaptive changelog for Obsidian. Links all modified files meeting certain criteria to a timed (daily, weekly, monthly) note.
MIT License
85 stars 7 forks source link

Odd behavior when notes are duplicated #12

Closed ScottKillen closed 2 years ago

ScottKillen commented 2 years ago

If I make a copy of a note using the file explorer context menu, a second link to the original file is added to the daily note. The expected behavior would be to add a link to the copy.

franciskafieh commented 2 years ago

Don't think the obsidian api would permit me to fix this... the modify event listener callback gives me a TAbstractFile and I simply use that... could be misunderstanding though

need some more time to look into this and consider if it's worth fixing (if even possible)

ScottKillen commented 2 years ago

I probably should have described the behavior using a little more detail:

  1. Modify a file. (This puts a link in the daily note.)
  2. Use the "make a copy" menu option on the same file. (This puts a duplicate link to the original file.)

So it would seem that in this case, fileIsLinked() is not detecting the link to the original file and a new duplicate link is being added to the daily note, -or- fileIsLinked() is working and the modify event is maybe passing the wrong file on a copy.

I wonder if listening for the 'create' event would fix this? It seems that all created files should be added to the list anyway.

🤔

ScottKillen commented 2 years ago

Did some more testing on the latest version:

  1. Created a file called test.
  2. Verified that the link appeared in the daily note. ✔ī¸
  3. Right clicked on test in the file explorer and selected "Make a copy"
  4. Checked daily note, but no link was added for the new file. ❗
  5. Selected the new file test 1 in the file explorer.
  6. Modified the file.
  7. Checked the daily note, but no link is ever added for test 1, even after editing other files which do get added to the daily note.

The console keeps spamming this every time I modify the copy:

Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'some')
    at ListModified.frontmatterMetadataContainsTag (eval at <anonymous> (app.js:1:1490278), <anonymous>:166:34)
    at ListModified.fileMeetsTagRequirements (eval at <anonymous> (app.js:1:1490278), <anonymous>:151:52)
    at ListModified.eval (eval at <anonymous> (app.js:1:1490278), <anonymous>:119:17)
    at Generator.next (<anonymous>)
    at eval (eval at <anonymous> (app.js:1:1490278), <anonymous>:46:61)
    at new Promise (<anonymous>)
    at __async (eval at <anonymous> (app.js:1:1490278), <anonymous>:30:10)
    at ListModified.onModify (eval at <anonymous> (app.js:1:1490278), <anonymous>:102:31)
    at t.e.tryTrigger (app.js:1:900700)
    at t.e.trigger (app.js:1:900633)

I have attached both of the referenced files.

Edits to test.md always get added to the daily note. Edits to its copy, test 1.md, are never added to the daily note.

franciskafieh commented 2 years ago

might know how to fix this... will try when i get home from school

franciskafieh commented 2 years ago

I suspect that the metadata cache i use to get links and tags from a file does not exist initially when you copy a file... explains the error in console (edit: if it keeps spamming minutes after, there might be something else going on... i'll test when i get back)

another issue is that i use the file's name to link to the daily note. this means that duplicate files will have the same link. there's got to be a better way... could try getFirstLinkPath, i think that's what it's for.

sorry i was unable to think straight yesterday & i said it couldn't be fixed lol. was super tired

ScottKillen commented 2 years ago

@franciskafieh You've got a great plugin here, and you will get tired trying to keep up. Don't stress to the point where it stops being fun. I speak from experience.

The incoming issues and feature requests are because we like what you have done and are taking a vested interest in helping it to be better. No apologies needed!

Also, I tip my hat to you. If I could figure out how to get this working, you'd have my pull request.

franciskafieh commented 2 years ago

user pjeby on the discord told me this... image

would solve the wrong link part :D

franciskafieh commented 2 years ago

Did some more testing on the latest version:

1. Created a file called `test`.

2. Verified that the link appeared in the daily note. ✔ī¸

3. Right clicked on `test` in the file explorer and selected "Make a copy"

4. Checked daily note, but no link was added for the new file. ❗

5. Selected the new file `test 1` in the file explorer.

6. Modified the file.

7. Checked the daily note, but no link is **ever** added for `test 1`, _even after_ editing other files which do get added to the daily note.

The console keeps spamming this every time I modify the copy:

Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'some')
    at ListModified.frontmatterMetadataContainsTag (eval at <anonymous> (app.js:1:1490278), <anonymous>:166:34)
    at ListModified.fileMeetsTagRequirements (eval at <anonymous> (app.js:1:1490278), <anonymous>:151:52)
    at ListModified.eval (eval at <anonymous> (app.js:1:1490278), <anonymous>:119:17)
    at Generator.next (<anonymous>)
    at eval (eval at <anonymous> (app.js:1:1490278), <anonymous>:46:61)
    at new Promise (<anonymous>)
    at __async (eval at <anonymous> (app.js:1:1490278), <anonymous>:30:10)
    at ListModified.onModify (eval at <anonymous> (app.js:1:1490278), <anonymous>:102:31)
    at t.e.tryTrigger (app.js:1:900700)
    at t.e.trigger (app.js:1:900633)

I have attached both of the referenced files.

* [test.md](https://github.com/franciskafieh/obsidian-list-modified/files/8406671/test.md)

* [test 1.md](https://github.com/franciskafieh/obsidian-list-modified/files/8406669/test.1.md)

Edits to test.md always get added to the daily note. Edits to its copy, test 1.md, are never added to the daily note.

can't reprod any of these issues... maybe i've already fixed it and didn't push? lmk if the new version works... edit: i want to do one last thing before i release a new feature, and it won't be done until tomorrow... see new comment for a new main.js build that should do the job for now

here's my testing....

https://user-images.githubusercontent.com/93789670/161637875-1cffdbfc-47f2-49ad-b329-dd779cad7394.mp4

EDIT: just to be sure, i used the exact same markdown file (name, contents) and it's working fine

franciskafieh commented 2 years ago

temporary new version: https://www.file.io/liL0/download/YfMEr9TVVq1r

just replace the current main.js file with this. no need to change the manifest.json, since there's no new version yet

ScottKillen commented 2 years ago

☚ī¸ File was deleted!

franciskafieh commented 2 years ago

☚ī¸ File was deleted!

not sure why, but github won't let me upload a js file! i think i found your discord from the obsidian server, i'll dm it to you there

ScottKillen commented 2 years ago

Got it!

ScottKillen commented 2 years ago

So we have a regression on this new version...It is not taking into account the folder setting in the Daily note plugin...so, it can't find my daily note anymore...

image

franciskafieh commented 2 years ago

So we have a regression on this new version...It is not taking into account the folder setting in the Daily note plugin...so, it can't find my daily note anymore...

image

Should be easy to fix

franciskafieh commented 2 years ago

Fixed in https://github.com/franciskafieh/obsidian-list-modified/commit/304e651dfad92ebe54b4f875d1395fe71ad88eec from my tests... going to build and create a new temporary release since I can't access discord atm

franciskafieh commented 2 years ago

@ScottKillen could you try release 1.0.1 for me?

ScottKillen commented 2 years ago

Unfortunately, it still cannot find my daily note.

franciskafieh commented 2 years ago

Unfortunately, it still cannot find my daily note.

that's really odd because it seems to be working for me with the exact same setup...

image

image

image

are there any errors in console?

edit: it better not be my git bugging out again....

franciskafieh commented 2 years ago

whoops, found a bug i need to fix... should not affect the file not being found for you, though. maybe it will fix itself whenever i release version 1.1 somehow..?

ScottKillen commented 2 years ago

I'm not sure why... 🤔

franciskafieh commented 2 years ago

also, another troubleshooting method: could you try pasting this.app.vault.getAbstractFileByPath(moment().format('[Daily Notes]/YYYY/MM-MMMM/YYYY-MM-DD') + ".md") into console? it should return something like this if that file exists...

image

otherwise, it may say undefined

franciskafieh commented 2 years ago

Any updates on the issue?

ScottKillen commented 2 years ago

Sorry, I am currently working about 18 hours a day...

Probably won't get time for a few weeks.

franciskafieh commented 2 years ago

That's ok. When you do have time, feel free to test again. No rush! Going to close this for now, since I cannot reproduce, but please re-open if the issue persists on v1.1!

On Sat, Apr 9, 2022 at 1:15 AM Scott Killen @.***> wrote:

Sorry, I am currently working about 18 hours a day...

Probably won't get time for a few weeks.

— Reply to this email directly, view it on GitHub https://github.com/franciskafieh/obsidian-list-modified/issues/12#issuecomment-1093700437, or unsubscribe https://github.com/notifications/unsubscribe-auth/AWLR3ZSGKZOFQ4W7W42PQVTVEEG5VANCNFSM5SOB5VGQ . You are receiving this because you were mentioned.Message ID: @.***>

ScottKillen commented 2 years ago

I did upgrade to the latest release this morning, and so far, I have not seen the weirdness 😄