diff --git a/lib/core/notes_view.dart b/lib/core/notes_materialized_view.dart similarity index 79% rename from lib/core/notes_view.dart rename to lib/core/notes_materialized_view.dart index 5854831a..5f60b81a 100644 --- a/lib/core/notes_view.dart +++ b/lib/core/notes_materialized_view.dart @@ -4,18 +4,18 @@ import 'note.dart'; typedef NotesViewComputer = T Function(Note note); -class NotesView { +class NotesMaterializedView { final Box storageBox; final NotesViewComputer computeFn; - NotesView._internal(this.storageBox, this.computeFn); + NotesMaterializedView._internal(this.storageBox, this.computeFn); - static Future> loadView( + static Future> loadView( String name, NotesViewComputer computeFn, ) async { var box = await Hive.openBox(name); - return NotesView._internal(box, computeFn); + return NotesMaterializedView._internal(box, computeFn); } // FIXME: The return value doesn't need to be optional @@ -29,7 +29,7 @@ class NotesView { // FIXME: the note.filePath doesn't need to contain the full path! var ts = note.fileLastModified!.toUtc().millisecondsSinceEpoch / 1000; var path = note.filePath; - var key = '${ts}_$path'; + var key = '${path}_$ts'; T? val = storageBox.get(key, defaultValue: null); if (val == null) { diff --git a/test/core/notes_view_test.dart b/test/core/notes_materialized_view_test.dart similarity index 90% rename from test/core/notes_view_test.dart rename to test/core/notes_materialized_view_test.dart index d87208b0..015a2296 100644 --- a/test/core/notes_view_test.dart +++ b/test/core/notes_materialized_view_test.dart @@ -2,7 +2,7 @@ import 'dart:io'; import 'package:gitjournal/core/notes_folder_config.dart'; import 'package:gitjournal/core/notes_folder_fs.dart'; -import 'package:gitjournal/core/notes_view.dart'; +import 'package:gitjournal/core/notes_materialized_view.dart'; import 'package:gitjournal/core/note.dart'; import 'package:gitjournal/core/transformers/base.dart'; import 'package:shared_preferences/shared_preferences.dart'; @@ -48,7 +48,8 @@ Hello return note.fileName; }; - var view = await NotesView.loadView('_test_box', compute); + var view = + await NotesMaterializedView.loadView('_test_box', compute); var note = await _createExampleNote(); expect(view.fetch(note), note.fileName);