38 Commits

Author SHA1 Message Date
51420f6c8d fix issue #579 -- this commit replaces PR #625
This commit was already in PR #625 but this new one is based on a more
recent version of the master branch.

As discussed in https://github.com/GitJournal/GitJournal/pull/625 the
problem was that if there is no yaml header, the title does not get
stored anywhere and hence gets lost. The fix is to write the title back
to the file as a first heading. This is used for loading the title
anyway, afaict.

The side effect is of course that any *other* application using the note
in the meantime will see the heading containing the note title. This is
way less disruptive than losing the title fully, though.
2023-12-12 20:14:01 +01:00
657721adc6 Update dart-git and stop using the Result class
Instead we're going to move back to standard exceptions.

Using a custom Result class has created far far more problems
- The Stacktraces aren't always right
- Sometimes one forgets to check the Result error
- All other exception throwing code needing to be converted to Results
- Non idiomatic Dart code

I think it's better to just go back to exceptions. They have their
problems, but overall, I think it's a better approach.
2023-11-24 14:03:30 +01:00
92e73c414d Move core Note classes into a separate file
I'm trying to get ride of this huge 'Note' class, and have it be quite
dumb. The idea is that we'll have separate Note subclasses - TxtNote,
MdNote, etc
2022-04-24 13:09:14 +02:00
0a085e78e7 MdYamlDoc: Make it immutable 2022-01-27 15:17:56 +01:00
afd7690611 Use fast_immutable_collections instead of Kt
It's much more intuitive to use, and is way more performant.
2022-01-27 12:13:34 +01:00
3841cdcab9 Note.tags: Use an compile time immutable set 2022-01-27 11:52:43 +01:00
901e4b5cb9 Avoid importing dart_git's Result class
It's easier to see where all dart_git is used this way, and this result
class should be refactored into its own package anyway.
2022-01-22 10:11:45 +01:00
1b63c2696d NoteStorage: Bump the modified when saving
It's not the exact same modified, but this way there is less lag for the
user.
2022-01-20 18:09:19 +01:00
b46ae0b811 Rebuild the entire 'File' when reloading 2022-01-20 18:08:50 +01:00
83d122d06f Note.oid: The oid is now only empty when the file hasn't yet been saved 2022-01-20 17:51:32 +01:00
b38c97454b Compute the file hash on saving a note
It's not ideal as the hash is now calculated twice, but it simplifies
such a large porition of the code as I can put proper asserts to make
sure all Files in the NotesFolderFS always have a valid GitHash.
2022-01-20 15:43:22 +01:00
7bdf52165c Ensure the Note's file is reloaded on reloading the Note
Also add more asserts.
2022-01-20 14:34:48 +01:00
f17542bf89 Mark Note as immutable 2022-01-18 23:34:58 +01:00
e6a24f8897 Fix note renaming to change editor type 2022-01-14 17:34:19 +01:00
7bb7fb94f2 note.title: Let it be null
This is a remanent from the time when non-nulllable didn't exist in
Dart.
2022-01-14 10:26:03 +01:00
125d24d9ba Ensure all exceptions implement the Exception interface 2021-12-20 09:28:00 +01:00
60b2922176 NotesFolder: Only notify if modified if really modified
Reloading the note doesn't count as a modification
2021-12-20 09:28:00 +01:00
567835b9c5 make fmt 2021-12-14 16:28:08 +01:00
4b658e3580 Move markdown handling to its own folder 2021-12-14 14:12:12 +01:00
015659d58f Allow a note to be renamed to whatever
Earlier one could never change a note type, and therefore its extension.
Now you can rename a note's filename to whatever and accordingly the
editor will change.

A warning message is shown when changing the file type.

Fixes #474
2021-11-15 12:39:12 +01:00
e1ea7a4953 Fetch the modified + created time from git
Fixes #78

This is probably the largest commit that I have ever made. From now on -
every File always has an mtime and ctime which is fetched from git.
Notes can optionally override that time by providing yaml metadata.

Additionally the 'filePath' and 'folderPath' is now relative to the
repoPath instead of being the full path.

This will slow down GitJournal like crazy as all the mtimes and ctime
still need to be cached. For my test repo it takes about 23 seconds for
GitJournal to become responsive.
2021-10-26 17:49:08 +02:00
28f34ca5e6 Avoid catching only Exceptions
We also occasionally get Errors in runtime. It seems like a terrible
decission for Error and Exception to not have a common subtype.
2021-10-20 09:59:14 +02:00
729764c518 Remove NoteLoadState
It's no longer required as a Note can never be in an Error state, it
becomes an 'IgnoredFile'
2021-10-18 13:09:47 +02:00
7a56d0f423 Remove Note's default constructor
Instead there is a new type called 'UnopenedFile'. This was part of my
effort to not have everything inside the 'Note' class and to make it a
bit more immutable.

But, wow, this took a very long time. The 'Note' class seems to be very
deeply integrated everywhere.
2021-10-18 13:03:22 +02:00
5f07543db2 Remove Note's doc setter
This makes us one step closer to making the Note class immutable which
will help GitJournal's overall architecture a lot. Plus it makes me one
step closer to having proper web support.
2021-10-17 22:22:33 +02:00
7f9beb0d5c NoteFileTypes: Hook up selector to the settings 2021-10-15 17:33:19 +02:00
be038c7e3e Ensure metadata is not stored when disabled
Fixes #544
2021-10-12 14:43:57 +02:00
1bf2f2f5be Avoid logging failed notes
These mostly seem to be due to utf8 compatibilities.

Fixes APP-1EQ
2021-10-11 21:43:11 +02:00
7e0a77ace3 Fix many cases of 'avoid-ignoring-return-values'
Now that dart-code-metrics has been updated, this lint can finally be
used. So far all of these are false positives, in the sense that I don't
care about their return values.

I wish there was an easy way of marking functions whose return value
shouldn't ever be ignored.
2021-09-27 18:39:18 +02:00
ee4c48b186 Note.save: Make sure the lastModified is exactly right
Otherwise the cache isn't always valid.
2021-09-17 09:57:38 +02:00
4bf0a78fee MaterializedView: Avoid re-computing many times
Ideally the Note's lastModified shouldn't ever be 0.
2021-09-17 09:55:33 +02:00
af7665bc5a Avoid logging the note's value
Urgh, so stupid.
2021-09-17 08:35:58 +02:00
510b277398 Add Note.apply
Avoid calling each setter as each results in the entire tree being
rebuilt.
2021-09-16 20:07:33 +02:00
33a731a3d7 Add reuse licensing to files in lib 2021-09-15 13:06:43 +02:00
cfaf1436f1 Move the MarkdownYamlCodec out of the Note class 2021-09-09 10:08:38 +02:00
fdc79828c7 Move note.load to NoteStorage
Now the note class is almost ready to become immutable
2021-09-09 10:01:36 +02:00
a0a97aa8cb Cleanup code 2021-08-04 08:17:49 +02:00
39096c270c Note.save: Move to NoteStorage
I'm trying to move all FS related operations out of the Note class, and
ideally make it super small. This class will need to be serialized over
the wire for the web version, and that needs it to be small.
2021-08-04 08:03:48 +02:00