mirror of
https://github.com/GitJournal/GitJournal.git
synced 2025-06-29 18:38:36 +08:00
Simplify the code
This commit is contained in:
10
lib/app.dart
10
lib/app.dart
@ -11,7 +11,6 @@ import 'package:easy_localization/easy_localization.dart';
|
||||
import 'package:easy_localization_loader/easy_localization_loader.dart';
|
||||
import 'package:flutter_sentry/flutter_sentry.dart';
|
||||
import 'package:package_info/package_info.dart';
|
||||
import 'package:path/path.dart' as p;
|
||||
import 'package:path_provider/path_provider.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:quick_actions/quick_actions.dart';
|
||||
@ -85,18 +84,13 @@ class JournalApp extends StatefulWidget {
|
||||
appState.remoteGitRepoConfigured = remotes.isNotEmpty;
|
||||
}
|
||||
|
||||
final cacheDir = await getApplicationSupportDirectory();
|
||||
appState.cacheDir = (await getApplicationSupportDirectory()).path;
|
||||
|
||||
Widget app = ChangeNotifierProvider.value(
|
||||
value: settings,
|
||||
child: ChangeNotifierProvider(
|
||||
create: (_) {
|
||||
return StateContainer(
|
||||
appState: appState,
|
||||
settings: settings,
|
||||
gitBaseDirectory: appState.gitBaseDirectory,
|
||||
cacheDirectory: cacheDir.path,
|
||||
);
|
||||
return StateContainer(appState: appState, settings: settings);
|
||||
},
|
||||
child: ChangeNotifierProvider(
|
||||
child: JournalApp(appState),
|
||||
|
@ -17,7 +17,9 @@ class AppState {
|
||||
}
|
||||
|
||||
NotesFolderFS notesFolder;
|
||||
|
||||
var gitBaseDirectory = "";
|
||||
var cacheDir = "";
|
||||
|
||||
bool remoteGitRepoConfigured = false;
|
||||
}
|
||||
|
@ -23,8 +23,6 @@ import 'package:gitjournal/utils/logger.dart';
|
||||
class StateContainer with ChangeNotifier {
|
||||
final AppState appState;
|
||||
final Settings settings;
|
||||
final String gitBaseDirectory;
|
||||
final String cacheDirectory;
|
||||
|
||||
final _opLock = Lock();
|
||||
final _loadLock = Lock();
|
||||
@ -37,12 +35,7 @@ class StateContainer with ChangeNotifier {
|
||||
|
||||
String repoPath;
|
||||
|
||||
StateContainer({
|
||||
@required this.appState,
|
||||
@required this.settings,
|
||||
@required this.gitBaseDirectory,
|
||||
@required this.cacheDirectory,
|
||||
}) {
|
||||
StateContainer({@required this.appState, @required this.settings}) {
|
||||
repoPath = settings.buildRepoPath(appState.gitBaseDirectory);
|
||||
|
||||
_gitRepo = GitNoteRepository(gitDirPath: repoPath, settings: settings);
|
||||
@ -54,7 +47,7 @@ class StateContainer with ChangeNotifier {
|
||||
value: appState.remoteGitRepoConfigured.toString(),
|
||||
);
|
||||
|
||||
var cachePath = p.join(cacheDirectory, "cache.json");
|
||||
var cachePath = p.join(appState.cacheDir, "cache.json");
|
||||
_notesCache = NotesCache(
|
||||
filePath: cachePath,
|
||||
notesBasePath: _gitRepo.gitDirPath,
|
||||
|
Reference in New Issue
Block a user