mirror of
https://github.com/GitJournal/GitJournal.git
synced 2025-08-26 10:38:13 +08:00
Rename NoteView -> NoteMaterializedView
It is stored in the disk
This commit is contained in:
@ -4,18 +4,18 @@ import 'note.dart';
|
||||
|
||||
typedef NotesViewComputer<T> = T Function(Note note);
|
||||
|
||||
class NotesView<T> {
|
||||
class NotesMaterializedView<T> {
|
||||
final Box storageBox;
|
||||
final NotesViewComputer computeFn;
|
||||
|
||||
NotesView._internal(this.storageBox, this.computeFn);
|
||||
NotesMaterializedView._internal(this.storageBox, this.computeFn);
|
||||
|
||||
static Future<NotesView<T>> loadView<T>(
|
||||
static Future<NotesMaterializedView<T>> loadView<T>(
|
||||
String name,
|
||||
NotesViewComputer computeFn,
|
||||
) async {
|
||||
var box = await Hive.openBox<T>(name);
|
||||
return NotesView<T>._internal(box, computeFn);
|
||||
return NotesMaterializedView<T>._internal(box, computeFn);
|
||||
}
|
||||
|
||||
// FIXME: The return value doesn't need to be optional
|
||||
@ -29,7 +29,7 @@ class NotesView<T> {
|
||||
// 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) {
|
Reference in New Issue
Block a user