RhetTbull / macnotesapp

Work with Apple MacOS Notes.app from the command line. Also includes python interface for scripting Notes.app from your own python code.
MIT License
129 stars 6 forks source link

accountGetAllNotes is far too slow #8

Closed RhetTbull closed 1 year ago

RhetTbull commented 1 year ago

I think it would be much faster to replace current accountGetAllNotes code:

on accountGetAllNotes(accountName)
    (* Get all notes for an account

     Args:
        accountName: name of account to get notes for

    Returns:
        list of note ids in account
     *)
    set allNotes to {}
    tell application "Notes"
        tell account accountName
            repeat with i from 1 to the count of notes
                set noteID to «class seld» of (note i as record)
                copy noteID to end of allNotes
            end repeat
        end tell
    end tell
    return allNotes
end accountGetAllNotes

with:

on accountGetAllNotes(accountName)
    (* Get all notes for an account

     Args:
        accountName: name of account to get notes for

    Returns:
        list of note ids in account
     *)
    set allNotes to {}
    tell application "Notes"
        tell account accountName
            set allNotes to id of notes
        end tell
    end tell
    return allNotes
end accountGetAllNotes