Giter VIP home page Giter VIP logo

Comments (9)

pbek avatar pbek commented on July 17, 2024

At the time handleNewNoteHeadlineHook is called the note doesn't exist yet.
Just return the filename you want every time in handleNoteTextFileNameHook or is something preventing you from doing that?

from scripts.

pbek avatar pbek commented on July 17, 2024

You could for example check the created date: https://www.qownnotes.org/scripting/classes.html#note

from scripts.

pkeir avatar pkeir commented on July 17, 2024

So my handleNoteTextFileNameHook function would have two code paths? In the first instance, I assume there is not yet a file creation date, and so I calculate my string as before using the current time. Subsequently, my handleNoteTextFileNameHookwould find that there is a file, and file creation date, and would use that. Does that sound right? (By the way, when I tried a script.log containing note.fileCreated.toISOString() I get "RangeError: Invalid Date out of range" in both scenarios.)

My hope had been that the NoteApi parameter of handleNewNoteHeadlineHook would allow access to a boolean indicating that there is already a file name associated with this note. Alternatively, another hook such as handleNewNoteHeadlineHook, say handleNewNoteHeadlineFilenameHook, could return both a headline and a filename as a simple pair object.

from scripts.

pbek avatar pbek commented on July 17, 2024

Funny, it seems like fileCreated will only be set if the note tree is reloaded. But you can also check the fileLastModified. But use handleNoteTextFileNameHook.

from scripts.

pkeir avatar pkeir commented on July 17, 2024

I edited my last comment: my function names were mixed up. I'll try fileLastModified.

from scripts.

pkeir avatar pkeir commented on July 17, 2024

I added the following at the start of my handleNoteTextFileNameHook function, and it seems to be working now. Thanks for the advice.

if (!isNaN(note.fileLastModified)) {
  return "";
}

from scripts.

pbek avatar pbek commented on July 17, 2024

Great, and I will fix the fileCreated.

from scripts.

pbek avatar pbek commented on July 17, 2024

20.12.1

  • the fileCreated date will now also be set for new notes before the note folder is reloaded

from scripts.

pbek avatar pbek commented on July 17, 2024

There now is a new release, could you please test it and report if it works for you?

from scripts.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.