mirror of
https://github.com/GitJournal/GitJournal.git
synced 2025-07-15 07:56:11 +08:00
Make Settings take the folderName as a parameter
This commit is contained in:
19
lib/app.dart
19
lib/app.dart
@ -29,34 +29,28 @@ class JournalApp extends StatefulWidget {
|
|||||||
static Future main(SharedPreferences pref) async {
|
static Future main(SharedPreferences pref) async {
|
||||||
await Log.init();
|
await Log.init();
|
||||||
|
|
||||||
var settings = Settings();
|
|
||||||
settings.load(pref);
|
|
||||||
|
|
||||||
var appSettings = AppSettings.instance;
|
var appSettings = AppSettings.instance;
|
||||||
Log.i("AppSetting ${appSettings.toMap()}");
|
Log.i("AppSetting ${appSettings.toMap()}");
|
||||||
Log.i("Setting ${settings.toLoggableMap()}");
|
|
||||||
|
|
||||||
if (appSettings.collectUsageStatistics) {
|
if (appSettings.collectUsageStatistics) {
|
||||||
_enableAnalyticsIfPossible(appSettings, settings);
|
_enableAnalyticsIfPossible(appSettings);
|
||||||
}
|
}
|
||||||
_sendAppUpdateEvent(appSettings);
|
_sendAppUpdateEvent(appSettings);
|
||||||
|
|
||||||
final gitBaseDirectory = (await getApplicationDocumentsDirectory()).path;
|
final gitBaseDirectory = (await getApplicationDocumentsDirectory()).path;
|
||||||
final cacheDir = (await getApplicationSupportDirectory()).path;
|
final cacheDir = (await getApplicationSupportDirectory()).path;
|
||||||
|
|
||||||
await settings.migrate(pref, gitBaseDirectory);
|
|
||||||
|
|
||||||
var repo = await Repository.load(
|
var repo = await Repository.load(
|
||||||
gitBaseDir: gitBaseDirectory,
|
gitBaseDir: gitBaseDirectory,
|
||||||
cacheDir: cacheDir,
|
cacheDir: cacheDir,
|
||||||
settings: settings,
|
pref: pref,
|
||||||
name: "journal",
|
name: "journal",
|
||||||
);
|
);
|
||||||
|
|
||||||
Widget app = ChangeNotifierProvider.value(
|
Widget app = ChangeNotifierProvider.value(
|
||||||
value: settings,
|
|
||||||
child: ChangeNotifierProvider.value(
|
|
||||||
value: repo,
|
value: repo,
|
||||||
|
child: ChangeNotifierProvider.value(
|
||||||
|
value: repo.settings,
|
||||||
child: ChangeNotifierProvider.value(
|
child: ChangeNotifierProvider.value(
|
||||||
child: JournalApp(),
|
child: JournalApp(),
|
||||||
value: repo.notesFolder,
|
value: repo.notesFolder,
|
||||||
@ -82,8 +76,7 @@ class JournalApp extends StatefulWidget {
|
|||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void _enableAnalyticsIfPossible(
|
static void _enableAnalyticsIfPossible(AppSettings appSettings) async {
|
||||||
AppSettings appSettings, Settings settings) async {
|
|
||||||
JournalApp.isInDebugMode = foundation.kDebugMode;
|
JournalApp.isInDebugMode = foundation.kDebugMode;
|
||||||
|
|
||||||
var isPhysicalDevice = true;
|
var isPhysicalDevice = true;
|
||||||
@ -120,8 +113,6 @@ class JournalApp extends StatefulWidget {
|
|||||||
name: 'proExpirationDate',
|
name: 'proExpirationDate',
|
||||||
value: appSettings.proExpirationDate.toString(),
|
value: appSettings.proExpirationDate.toString(),
|
||||||
);
|
);
|
||||||
|
|
||||||
logEvent(Event.Settings, parameters: settings.toLoggableMap());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6,6 +6,7 @@ import 'package:flutter/material.dart';
|
|||||||
|
|
||||||
import 'package:dart_git/dart_git.dart';
|
import 'package:dart_git/dart_git.dart';
|
||||||
import 'package:path/path.dart' as p;
|
import 'package:path/path.dart' as p;
|
||||||
|
import 'package:shared_preferences/shared_preferences.dart';
|
||||||
import 'package:synchronized/synchronized.dart';
|
import 'package:synchronized/synchronized.dart';
|
||||||
|
|
||||||
import 'package:gitjournal/analytics.dart';
|
import 'package:gitjournal/analytics.dart';
|
||||||
@ -59,9 +60,18 @@ class Repository with ChangeNotifier {
|
|||||||
static Future<Repository> load({
|
static Future<Repository> load({
|
||||||
@required String gitBaseDir,
|
@required String gitBaseDir,
|
||||||
@required String cacheDir,
|
@required String cacheDir,
|
||||||
@required Settings settings,
|
@required SharedPreferences pref,
|
||||||
@required String name,
|
@required String name,
|
||||||
}) async {
|
}) async {
|
||||||
|
var settings = Settings(name);
|
||||||
|
settings.load(pref);
|
||||||
|
|
||||||
|
await settings.migrate(pref, gitBaseDir);
|
||||||
|
|
||||||
|
logEvent(Event.Settings, parameters: settings.toLoggableMap());
|
||||||
|
|
||||||
|
Log.i("Setting ${settings.toLoggableMap()}");
|
||||||
|
|
||||||
var repoPath = settings.buildRepoPath(gitBaseDir);
|
var repoPath = settings.buildRepoPath(gitBaseDir);
|
||||||
|
|
||||||
var repoDirStat = File(repoPath).statSync();
|
var repoDirStat = File(repoPath).statSync();
|
||||||
|
@ -13,7 +13,9 @@ import 'package:gitjournal/screens/note_editor.dart';
|
|||||||
import 'package:gitjournal/utils/logger.dart';
|
import 'package:gitjournal/utils/logger.dart';
|
||||||
|
|
||||||
class Settings extends ChangeNotifier {
|
class Settings extends ChangeNotifier {
|
||||||
Settings();
|
Settings(this.folderName);
|
||||||
|
|
||||||
|
String folderName;
|
||||||
|
|
||||||
// Properties
|
// Properties
|
||||||
String gitAuthor = "GitJournal";
|
String gitAuthor = "GitJournal";
|
||||||
@ -59,8 +61,6 @@ class Settings extends ChangeNotifier {
|
|||||||
|
|
||||||
bool bottomMenuBar = true;
|
bool bottomMenuBar = true;
|
||||||
|
|
||||||
String folderName = "journal";
|
|
||||||
|
|
||||||
bool storeInternally = true;
|
bool storeInternally = true;
|
||||||
String storageLocation = "";
|
String storageLocation = "";
|
||||||
|
|
||||||
@ -145,7 +145,7 @@ class Settings extends ChangeNotifier {
|
|||||||
|
|
||||||
Future<void> save() async {
|
Future<void> save() async {
|
||||||
var pref = await SharedPreferences.getInstance();
|
var pref = await SharedPreferences.getInstance();
|
||||||
var defaultSet = Settings();
|
var defaultSet = Settings(folderName);
|
||||||
|
|
||||||
_setString(pref, "gitAuthor", gitAuthor, defaultSet.gitAuthor);
|
_setString(pref, "gitAuthor", gitAuthor, defaultSet.gitAuthor);
|
||||||
_setString(
|
_setString(
|
||||||
|
@ -41,7 +41,7 @@ Booga Wooga
|
|||||||
var notePath = p.join(tempDir.path, "note.md");
|
var notePath = p.join(tempDir.path, "note.md");
|
||||||
File(notePath).writeAsString(content);
|
File(notePath).writeAsString(content);
|
||||||
|
|
||||||
var parentFolder = NotesFolderFS(null, tempDir.path, Settings());
|
var parentFolder = NotesFolderFS(null, tempDir.path, Settings(''));
|
||||||
var note = Note(parentFolder, notePath);
|
var note = Note(parentFolder, notePath);
|
||||||
await note.load();
|
await note.load();
|
||||||
|
|
||||||
@ -105,7 +105,7 @@ Booga Wooga
|
|||||||
var notePath = p.join(tempDir.path, "note2.md");
|
var notePath = p.join(tempDir.path, "note2.md");
|
||||||
await File(notePath).writeAsString(content);
|
await File(notePath).writeAsString(content);
|
||||||
|
|
||||||
var parentFolder = NotesFolderFS(null, tempDir.path, Settings());
|
var parentFolder = NotesFolderFS(null, tempDir.path, Settings(''));
|
||||||
var note = Note(parentFolder, notePath);
|
var note = Note(parentFolder, notePath);
|
||||||
await note.load();
|
await note.load();
|
||||||
|
|
||||||
@ -120,7 +120,7 @@ Booga Wooga
|
|||||||
var notePath = p.join(tempDir.path, "note3.md");
|
var notePath = p.join(tempDir.path, "note3.md");
|
||||||
await File(notePath).writeAsString(content);
|
await File(notePath).writeAsString(content);
|
||||||
|
|
||||||
var parentFolder = NotesFolderFS(null, tempDir.path, Settings());
|
var parentFolder = NotesFolderFS(null, tempDir.path, Settings(''));
|
||||||
var note = Note(parentFolder, notePath);
|
var note = Note(parentFolder, notePath);
|
||||||
await note.load();
|
await note.load();
|
||||||
|
|
||||||
@ -141,7 +141,7 @@ Booga Wooga
|
|||||||
var notePath = p.join(tempDir.path, "note13.md");
|
var notePath = p.join(tempDir.path, "note13.md");
|
||||||
await File(notePath).writeAsString(content);
|
await File(notePath).writeAsString(content);
|
||||||
|
|
||||||
var parentFolder = NotesFolderFS(null, tempDir.path, Settings());
|
var parentFolder = NotesFolderFS(null, tempDir.path, Settings(''));
|
||||||
var note = Note(parentFolder, notePath);
|
var note = Note(parentFolder, notePath);
|
||||||
await note.load();
|
await note.load();
|
||||||
|
|
||||||
@ -161,7 +161,7 @@ Booga Wooga
|
|||||||
var notePath = p.join(tempDir.path, "note4.md");
|
var notePath = p.join(tempDir.path, "note4.md");
|
||||||
await File(notePath).writeAsString(content);
|
await File(notePath).writeAsString(content);
|
||||||
|
|
||||||
var parentFolder = NotesFolderFS(null, tempDir.path, Settings());
|
var parentFolder = NotesFolderFS(null, tempDir.path, Settings(''));
|
||||||
var note = Note(parentFolder, notePath);
|
var note = Note(parentFolder, notePath);
|
||||||
await note.load();
|
await note.load();
|
||||||
|
|
||||||
@ -181,7 +181,7 @@ Booga Wooga
|
|||||||
var notePath = p.join(tempDir.path, "note4.md");
|
var notePath = p.join(tempDir.path, "note4.md");
|
||||||
await File(notePath).writeAsString(content);
|
await File(notePath).writeAsString(content);
|
||||||
|
|
||||||
var parentFolder = NotesFolderFS(null, tempDir.path, Settings());
|
var parentFolder = NotesFolderFS(null, tempDir.path, Settings(''));
|
||||||
var note = Note(parentFolder, notePath);
|
var note = Note(parentFolder, notePath);
|
||||||
await note.load();
|
await note.load();
|
||||||
|
|
||||||
@ -197,7 +197,7 @@ Booga Wooga
|
|||||||
var notePath = p.join(tempDir.path, "note449.md");
|
var notePath = p.join(tempDir.path, "note449.md");
|
||||||
await File(notePath).writeAsString(content);
|
await File(notePath).writeAsString(content);
|
||||||
|
|
||||||
var parentFolder = NotesFolderFS(null, tempDir.path, Settings());
|
var parentFolder = NotesFolderFS(null, tempDir.path, Settings(''));
|
||||||
var note = Note(parentFolder, notePath);
|
var note = Note(parentFolder, notePath);
|
||||||
await note.load();
|
await note.load();
|
||||||
|
|
||||||
@ -215,7 +215,7 @@ Booga Wooga
|
|||||||
var notePath = p.join(tempDir.path, "note448.md");
|
var notePath = p.join(tempDir.path, "note448.md");
|
||||||
await File(notePath).writeAsString(content);
|
await File(notePath).writeAsString(content);
|
||||||
|
|
||||||
var parentFolder = NotesFolderFS(null, tempDir.path, Settings());
|
var parentFolder = NotesFolderFS(null, tempDir.path, Settings(''));
|
||||||
var note = Note(parentFolder, notePath);
|
var note = Note(parentFolder, notePath);
|
||||||
await note.load();
|
await note.load();
|
||||||
|
|
||||||
@ -231,7 +231,7 @@ Booga Wooga
|
|||||||
var notePath = p.join(tempDir.path, "note448.md");
|
var notePath = p.join(tempDir.path, "note448.md");
|
||||||
await File(notePath).writeAsString(content);
|
await File(notePath).writeAsString(content);
|
||||||
|
|
||||||
var parentFolder = NotesFolderFS(null, tempDir.path, Settings());
|
var parentFolder = NotesFolderFS(null, tempDir.path, Settings(''));
|
||||||
var note = Note(parentFolder, notePath);
|
var note = Note(parentFolder, notePath);
|
||||||
await note.load();
|
await note.load();
|
||||||
|
|
||||||
@ -247,7 +247,7 @@ Booga Wooga
|
|||||||
var notePath = p.join(tempDir.path, "note449.md");
|
var notePath = p.join(tempDir.path, "note449.md");
|
||||||
await File(notePath).writeAsString(content);
|
await File(notePath).writeAsString(content);
|
||||||
|
|
||||||
var parentFolder = NotesFolderFS(null, tempDir.path, Settings());
|
var parentFolder = NotesFolderFS(null, tempDir.path, Settings(''));
|
||||||
var note = Note(parentFolder, notePath);
|
var note = Note(parentFolder, notePath);
|
||||||
await note.load();
|
await note.load();
|
||||||
|
|
||||||
@ -264,7 +264,7 @@ Booga Wooga
|
|||||||
var notePath = p.join(tempDir.path, "note429.md");
|
var notePath = p.join(tempDir.path, "note429.md");
|
||||||
await File(notePath).writeAsString(content);
|
await File(notePath).writeAsString(content);
|
||||||
|
|
||||||
var parentFolder = NotesFolderFS(null, tempDir.path, Settings());
|
var parentFolder = NotesFolderFS(null, tempDir.path, Settings(''));
|
||||||
var note = Note(parentFolder, notePath);
|
var note = Note(parentFolder, notePath);
|
||||||
await note.load();
|
await note.load();
|
||||||
|
|
||||||
|
@ -24,7 +24,7 @@ void main() {
|
|||||||
await _writeRandomNote(random, tempDir.path);
|
await _writeRandomNote(random, tempDir.path);
|
||||||
}
|
}
|
||||||
|
|
||||||
rootFolder = NotesFolderFS(null, tempDir.path, Settings());
|
rootFolder = NotesFolderFS(null, tempDir.path, Settings(''));
|
||||||
await rootFolder.loadRecursively();
|
await rootFolder.loadRecursively();
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -56,7 +56,7 @@ Future<void> _writeRandomNote(Random random, String dirPath) async {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var note = Note(NotesFolderFS(null, dirPath, Settings()), path);
|
var note = Note(NotesFolderFS(null, dirPath, Settings('')), path);
|
||||||
note.modified = DateTime(2014, 1, 1 + (random.nextInt(2000)));
|
note.modified = DateTime(2014, 1, 1 + (random.nextInt(2000)));
|
||||||
note.body = "p1";
|
note.body = "p1";
|
||||||
await note.save();
|
await note.save();
|
||||||
|
@ -31,7 +31,7 @@ void main() {
|
|||||||
setUp(() async {
|
setUp(() async {
|
||||||
tempDir = await Directory.systemTemp.createTemp('__sorted_folder_test__');
|
tempDir = await Directory.systemTemp.createTemp('__sorted_folder_test__');
|
||||||
|
|
||||||
rootFolder = NotesFolderFS(null, tempDir.path, Settings());
|
rootFolder = NotesFolderFS(null, tempDir.path, Settings(''));
|
||||||
|
|
||||||
for (var i = 0; i < 3; i++) {
|
for (var i = 0; i < 3; i++) {
|
||||||
var note = Note(rootFolder, _getRandomFilePath(rootFolder.folderPath));
|
var note = Note(rootFolder, _getRandomFilePath(rootFolder.folderPath));
|
||||||
@ -45,7 +45,7 @@ void main() {
|
|||||||
Directory(p.join(tempDir.path, "sub2")).createSync();
|
Directory(p.join(tempDir.path, "sub2")).createSync();
|
||||||
|
|
||||||
var sub1Folder =
|
var sub1Folder =
|
||||||
NotesFolderFS(rootFolder, p.join(tempDir.path, "sub1"), Settings());
|
NotesFolderFS(rootFolder, p.join(tempDir.path, "sub1"), Settings(''));
|
||||||
for (var i = 0; i < 2; i++) {
|
for (var i = 0; i < 2; i++) {
|
||||||
var note = Note(
|
var note = Note(
|
||||||
sub1Folder,
|
sub1Folder,
|
||||||
@ -57,7 +57,7 @@ void main() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var sub2Folder =
|
var sub2Folder =
|
||||||
NotesFolderFS(rootFolder, p.join(tempDir.path, "sub2"), Settings());
|
NotesFolderFS(rootFolder, p.join(tempDir.path, "sub2"), Settings(''));
|
||||||
for (var i = 0; i < 2; i++) {
|
for (var i = 0; i < 2; i++) {
|
||||||
var note = Note(
|
var note = Note(
|
||||||
sub2Folder,
|
sub2Folder,
|
||||||
@ -69,7 +69,7 @@ void main() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var p1Folder = NotesFolderFS(
|
var p1Folder = NotesFolderFS(
|
||||||
sub1Folder, p.join(tempDir.path, "sub1", "p1"), Settings());
|
sub1Folder, p.join(tempDir.path, "sub1", "p1"), Settings(''));
|
||||||
for (var i = 0; i < 2; i++) {
|
for (var i = 0; i < 2; i++) {
|
||||||
var note = Note(
|
var note = Note(
|
||||||
p1Folder,
|
p1Folder,
|
||||||
|
@ -15,7 +15,7 @@ void main() {
|
|||||||
setUpAll(() async {
|
setUpAll(() async {
|
||||||
tempDir = await Directory.systemTemp.createTemp('__link_resolver__');
|
tempDir = await Directory.systemTemp.createTemp('__link_resolver__');
|
||||||
|
|
||||||
rootFolder = NotesFolderFS(null, tempDir.path, Settings());
|
rootFolder = NotesFolderFS(null, tempDir.path, Settings(''));
|
||||||
|
|
||||||
await generateNote(tempDir.path, "Hello.md");
|
await generateNote(tempDir.path, "Hello.md");
|
||||||
await generateNote(tempDir.path, "Fire.md");
|
await generateNote(tempDir.path, "Fire.md");
|
||||||
|
@ -10,7 +10,7 @@ import 'package:gitjournal/settings.dart';
|
|||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
group('Note Serializer Test', () {
|
group('Note Serializer Test', () {
|
||||||
var parent = NotesFolderFS(null, '/tmp', Settings());
|
var parent = NotesFolderFS(null, '/tmp', Settings(''));
|
||||||
|
|
||||||
test('Test emojis', () {
|
test('Test emojis', () {
|
||||||
var props = LinkedHashMap<String, dynamic>.from(
|
var props = LinkedHashMap<String, dynamic>.from(
|
||||||
|
@ -28,7 +28,7 @@ void main() {
|
|||||||
n1Path = p.join(tempDir.path, "1.md");
|
n1Path = p.join(tempDir.path, "1.md");
|
||||||
n2Path = p.join(tempDir.path, "2.md");
|
n2Path = p.join(tempDir.path, "2.md");
|
||||||
|
|
||||||
var parent = NotesFolderFS(null, tempDir.path, Settings());
|
var parent = NotesFolderFS(null, tempDir.path, Settings(''));
|
||||||
var n1 = Note(parent, n1Path);
|
var n1 = Note(parent, n1Path);
|
||||||
n1.body = "test";
|
n1.body = "test";
|
||||||
n1.created = dt;
|
n1.created = dt;
|
||||||
@ -52,7 +52,7 @@ void main() {
|
|||||||
expect(File(n2Path).existsSync(), isTrue);
|
expect(File(n2Path).existsSync(), isTrue);
|
||||||
|
|
||||||
var loadedNotes = <Note>[];
|
var loadedNotes = <Note>[];
|
||||||
var parent = NotesFolderFS(null, tempDir.path, Settings());
|
var parent = NotesFolderFS(null, tempDir.path, Settings(''));
|
||||||
|
|
||||||
await Future.forEach(notes, (origNote) async {
|
await Future.forEach(notes, (origNote) async {
|
||||||
var note = Note(parent, origNote.filePath);
|
var note = Note(parent, origNote.filePath);
|
||||||
|
@ -30,7 +30,7 @@ Hello""";
|
|||||||
var notePath = p.join(tempDir.path, "note.md");
|
var notePath = p.join(tempDir.path, "note.md");
|
||||||
await File(notePath).writeAsString(content);
|
await File(notePath).writeAsString(content);
|
||||||
|
|
||||||
var parentFolder = NotesFolderFS(null, tempDir.path, Settings());
|
var parentFolder = NotesFolderFS(null, tempDir.path, Settings(''));
|
||||||
var note = Note(parentFolder, notePath);
|
var note = Note(parentFolder, notePath);
|
||||||
await note.load();
|
await note.load();
|
||||||
|
|
||||||
@ -60,7 +60,7 @@ Hello""";
|
|||||||
var notePath = p.join(tempDir.path, "note.md");
|
var notePath = p.join(tempDir.path, "note.md");
|
||||||
await File(notePath).writeAsString(content);
|
await File(notePath).writeAsString(content);
|
||||||
|
|
||||||
var parentFolder = NotesFolderFS(null, tempDir.path, Settings());
|
var parentFolder = NotesFolderFS(null, tempDir.path, Settings(''));
|
||||||
var note = Note(parentFolder, notePath);
|
var note = Note(parentFolder, notePath);
|
||||||
await note.load();
|
await note.load();
|
||||||
|
|
||||||
@ -90,7 +90,7 @@ Hello""";
|
|||||||
var notePath = p.join(tempDir.path, "note5.md");
|
var notePath = p.join(tempDir.path, "note5.md");
|
||||||
await File(notePath).writeAsString(content);
|
await File(notePath).writeAsString(content);
|
||||||
|
|
||||||
var parentFolder = NotesFolderFS(null, tempDir.path, Settings());
|
var parentFolder = NotesFolderFS(null, tempDir.path, Settings(''));
|
||||||
var note = Note(parentFolder, notePath);
|
var note = Note(parentFolder, notePath);
|
||||||
await note.load();
|
await note.load();
|
||||||
|
|
||||||
@ -128,7 +128,7 @@ bar: Foo
|
|||||||
var notePath = p.join(tempDir.path, "note6.md");
|
var notePath = p.join(tempDir.path, "note6.md");
|
||||||
await File(notePath).writeAsString(content);
|
await File(notePath).writeAsString(content);
|
||||||
|
|
||||||
var parentFolder = NotesFolderFS(null, tempDir.path, Settings());
|
var parentFolder = NotesFolderFS(null, tempDir.path, Settings(''));
|
||||||
var note = Note(parentFolder, notePath);
|
var note = Note(parentFolder, notePath);
|
||||||
await note.load();
|
await note.load();
|
||||||
|
|
||||||
@ -148,7 +148,7 @@ bar: Foo
|
|||||||
var notePath = p.join(tempDir.path, "note63.md");
|
var notePath = p.join(tempDir.path, "note63.md");
|
||||||
await File(notePath).writeAsString(content);
|
await File(notePath).writeAsString(content);
|
||||||
|
|
||||||
var parentFolder = NotesFolderFS(null, tempDir.path, Settings());
|
var parentFolder = NotesFolderFS(null, tempDir.path, Settings(''));
|
||||||
var note = Note(parentFolder, notePath);
|
var note = Note(parentFolder, notePath);
|
||||||
await note.load();
|
await note.load();
|
||||||
|
|
||||||
@ -173,7 +173,7 @@ Gee
|
|||||||
var notePath = p.join(tempDir.path, "note16.md");
|
var notePath = p.join(tempDir.path, "note16.md");
|
||||||
await File(notePath).writeAsString(content);
|
await File(notePath).writeAsString(content);
|
||||||
|
|
||||||
var parentFolder = NotesFolderFS(null, tempDir.path, Settings());
|
var parentFolder = NotesFolderFS(null, tempDir.path, Settings(''));
|
||||||
var note = Note(parentFolder, notePath);
|
var note = Note(parentFolder, notePath);
|
||||||
await note.load();
|
await note.load();
|
||||||
|
|
||||||
@ -195,7 +195,7 @@ Gee
|
|||||||
});
|
});
|
||||||
|
|
||||||
test('New Notes have a file extension', () async {
|
test('New Notes have a file extension', () async {
|
||||||
var parentFolder = NotesFolderFS(null, tempDir.path, Settings());
|
var parentFolder = NotesFolderFS(null, tempDir.path, Settings(''));
|
||||||
var note = Note.newNote(parentFolder);
|
var note = Note.newNote(parentFolder);
|
||||||
var path = note.filePath;
|
var path = note.filePath;
|
||||||
expect(path.endsWith('.md'), true);
|
expect(path.endsWith('.md'), true);
|
||||||
@ -209,7 +209,7 @@ Gee
|
|||||||
var txtNotePath = p.join(tempDir.path, "note163.txt");
|
var txtNotePath = p.join(tempDir.path, "note163.txt");
|
||||||
await File(txtNotePath).writeAsString(content);
|
await File(txtNotePath).writeAsString(content);
|
||||||
|
|
||||||
var parentFolder = NotesFolderFS(null, tempDir.path, Settings());
|
var parentFolder = NotesFolderFS(null, tempDir.path, Settings(''));
|
||||||
var txtNote = Note(parentFolder, txtNotePath);
|
var txtNote = Note(parentFolder, txtNotePath);
|
||||||
await txtNote.load();
|
await txtNote.load();
|
||||||
|
|
||||||
|
@ -25,7 +25,7 @@ void main() {
|
|||||||
cache = NotesCache(
|
cache = NotesCache(
|
||||||
filePath: cacheFilePath,
|
filePath: cacheFilePath,
|
||||||
notesBasePath: '/base',
|
notesBasePath: '/base',
|
||||||
settings: Settings(),
|
settings: Settings(''),
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -45,7 +45,7 @@ void main() {
|
|||||||
|
|
||||||
test('Should create directory structure accurately', () async {
|
test('Should create directory structure accurately', () async {
|
||||||
await cache.saveToDisk(fileList);
|
await cache.saveToDisk(fileList);
|
||||||
var rootFolder = NotesFolderFS(null, '/base', Settings());
|
var rootFolder = NotesFolderFS(null, '/base', Settings(''));
|
||||||
await cache.load(rootFolder);
|
await cache.load(rootFolder);
|
||||||
|
|
||||||
expect(rootFolder.subFolders.length, 2);
|
expect(rootFolder.subFolders.length, 2);
|
||||||
|
@ -24,7 +24,7 @@ void main() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
test('Should load from FS correctly', () async {
|
test('Should load from FS correctly', () async {
|
||||||
var folder = NotesFolderFS(null, tempDir.path, Settings());
|
var folder = NotesFolderFS(null, tempDir.path, Settings(''));
|
||||||
var config = NotesFolderConfig(
|
var config = NotesFolderConfig(
|
||||||
defaultEditor: EditorType.Checklist,
|
defaultEditor: EditorType.Checklist,
|
||||||
defaultView: FolderViewType.Standard,
|
defaultView: FolderViewType.Standard,
|
||||||
|
@ -18,7 +18,7 @@ void main() {
|
|||||||
setUp(() async {
|
setUp(() async {
|
||||||
tempDir = await Directory.systemTemp.createTemp('__sorted_folder_test__');
|
tempDir = await Directory.systemTemp.createTemp('__sorted_folder_test__');
|
||||||
|
|
||||||
folder = NotesFolderFS(null, tempDir.path, Settings());
|
folder = NotesFolderFS(null, tempDir.path, Settings(''));
|
||||||
|
|
||||||
var random = Random();
|
var random = Random();
|
||||||
for (var i = 0; i < 5; i++) {
|
for (var i = 0; i < 5; i++) {
|
||||||
@ -122,7 +122,7 @@ void main() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
test('If still sorted while loading the notes', () async {
|
test('If still sorted while loading the notes', () async {
|
||||||
var folder = NotesFolderFS(null, tempDir.path, Settings());
|
var folder = NotesFolderFS(null, tempDir.path, Settings(''));
|
||||||
var sf = SortedNotesFolder(
|
var sf = SortedNotesFolder(
|
||||||
folder: folder,
|
folder: folder,
|
||||||
sortingMode:
|
sortingMode:
|
||||||
|
@ -8,7 +8,7 @@ import 'package:gitjournal/settings.dart';
|
|||||||
void main() {
|
void main() {
|
||||||
group('Sorting Mode', () {
|
group('Sorting Mode', () {
|
||||||
test('Created', () async {
|
test('Created', () async {
|
||||||
var folder = NotesFolderFS(null, '/tmp/', Settings());
|
var folder = NotesFolderFS(null, '/tmp/', Settings(''));
|
||||||
var n1 = Note(folder, '/tmp/1.md');
|
var n1 = Note(folder, '/tmp/1.md');
|
||||||
n1.created = DateTime(2020, 10, 01);
|
n1.created = DateTime(2020, 10, 01);
|
||||||
|
|
||||||
@ -33,7 +33,7 @@ void main() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
test('Modified', () async {
|
test('Modified', () async {
|
||||||
var folder = NotesFolderFS(null, '/tmp/', Settings());
|
var folder = NotesFolderFS(null, '/tmp/', Settings(''));
|
||||||
var n1 = Note(folder, '/tmp/1.md');
|
var n1 = Note(folder, '/tmp/1.md');
|
||||||
n1.modified = DateTime(2020, 10, 01);
|
n1.modified = DateTime(2020, 10, 01);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user