Fix Clone screen not disappearing

and other misc changes
This commit is contained in:
Vishesh Handa
2019-01-23 12:48:37 +01:00
parent 2b1ac6cad7
commit 170983024c
3 changed files with 13 additions and 7 deletions

View File

@ -135,7 +135,7 @@ class OnBoardingScreenState extends State<OnBoardingScreen> {
); );
var appState = StateContainer.of(context).appState; var appState = StateContainer.of(context).appState;
_startGitClone(appState.gitBaseDirectory); _startGitClone(context, appState.gitBaseDirectory);
getAnalytics().logEvent( getAnalytics().logEvent(
name: "onboarding_public_key_copied", name: "onboarding_public_key_copied",
@ -276,7 +276,7 @@ class OnBoardingScreenState extends State<OnBoardingScreen> {
} }
} }
void _startGitClone(String basePath) async { void _startGitClone(BuildContext context, String basePath) async {
// Just in case it was half cloned because of an error // Just in case it was half cloned because of an error
await _removeExistingClone(basePath); await _removeExistingClone(basePath);
@ -296,15 +296,17 @@ class OnBoardingScreenState extends State<OnBoardingScreen> {
name: "onboarding_complete", name: "onboarding_complete",
parameters: <String, dynamic>{}, parameters: <String, dynamic>{},
); );
Navigator.pop(context);
this.widget.onBoardingCompletedFunction(); this.widget.onBoardingCompletedFunction();
} }
} }
Future _removeExistingClone(String baseDirPath) async { Future _removeExistingClone(String baseDirPath) async {
var baseDir = new Directory(baseDirPath); var baseDir = new Directory(p.join(baseDirPath, "journal"));
var dotGitDir = new Directory(p.join(baseDir.path, "journal", ".git")); var dotGitDir = new Directory(p.join(baseDir.path, ".git"));
bool exists = await dotGitDir.exists(); bool exists = await dotGitDir.exists();
if (exists) { if (exists) {
print("Removing " + baseDir.path);
await baseDir.delete(recursive: true); await baseDir.delete(recursive: true);
await baseDir.create(); await baseDir.create();
} }

View File

@ -192,7 +192,7 @@ class StateContainerState extends State<StateContainer> {
await migrateGitRepo( await migrateGitRepo(
fromGitBasePath: appState.localGitRepoPath, fromGitBasePath: appState.localGitRepoPath,
toGitBasePath: appState.localGitRepoPath, toGitBasePath: appState.remoteGitRepoPath,
gitBasePath: appState.gitBaseDirectory, gitBasePath: appState.gitBaseDirectory,
); );
@ -201,7 +201,7 @@ class StateContainerState extends State<StateContainer> {
dirName: appState.remoteGitRepoPath, dirName: appState.remoteGitRepoPath,
); );
_persistConfig(); await _persistConfig();
_loadNotesFromDisk(); _loadNotesFromDisk();
_syncNotes(); _syncNotes();
}); });

View File

@ -12,7 +12,7 @@ import 'package:journal/storage/notes_repository.dart';
class GitNoteRepository implements NoteRepository { class GitNoteRepository implements NoteRepository {
final FileStorage _fileStorage; final FileStorage _fileStorage;
final String gitCloneUrl = ""; //final String gitCloneUrl = "";
final String dirName; final String dirName;
bool cloned = false; bool cloned = false;
@ -85,6 +85,9 @@ class GitNoteRepository implements NoteRepository {
@override @override
Future<bool> sync() async { Future<bool> sync() async {
/*
Disable git clone for now - The repo should have already been cloned!
if (gitCloneUrl == null || gitCloneUrl.isEmpty) { if (gitCloneUrl == null || gitCloneUrl.isEmpty) {
print("Cannot sync because of lack of clone url"); print("Cannot sync because of lack of clone url");
return false; return false;
@ -103,6 +106,7 @@ class GitNoteRepository implements NoteRepository {
cloned = true; cloned = true;
return true; return true;
} }
*/
try { try {
await gitPull(this.dirName); await gitPull(this.dirName);