mirror of
https://github.com/GitJournal/GitJournal.git
synced 2025-06-29 18:38:36 +08:00
Remove unused base class
This commit is contained in:
@ -10,7 +10,6 @@ import 'package:journal/appstate.dart';
|
|||||||
import 'package:journal/note.dart';
|
import 'package:journal/note.dart';
|
||||||
import 'package:journal/note_fileName.dart';
|
import 'package:journal/note_fileName.dart';
|
||||||
import 'package:journal/storage/git_storage.dart';
|
import 'package:journal/storage/git_storage.dart';
|
||||||
import 'package:journal/storage/notes_repository.dart';
|
|
||||||
import 'package:path/path.dart' as p;
|
import 'package:path/path.dart' as p;
|
||||||
import 'package:shared_preferences/shared_preferences.dart';
|
import 'package:shared_preferences/shared_preferences.dart';
|
||||||
|
|
||||||
|
@ -6,10 +6,19 @@ import 'package:flutter/foundation.dart';
|
|||||||
import 'package:journal/apis/git.dart';
|
import 'package:journal/apis/git.dart';
|
||||||
import 'package:journal/note.dart';
|
import 'package:journal/note.dart';
|
||||||
import 'package:journal/settings.dart';
|
import 'package:journal/settings.dart';
|
||||||
import 'package:journal/storage/notes_repository.dart';
|
|
||||||
import 'package:path/path.dart' as p;
|
import 'package:path/path.dart' as p;
|
||||||
|
|
||||||
class GitNoteRepository implements NoteRepository {
|
class NoteRepoResult {
|
||||||
|
bool error;
|
||||||
|
String noteFilePath;
|
||||||
|
|
||||||
|
NoteRepoResult({
|
||||||
|
@required this.error,
|
||||||
|
this.noteFilePath,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
class GitNoteRepository {
|
||||||
final String dirName;
|
final String dirName;
|
||||||
final String subDirName;
|
final String subDirName;
|
||||||
final String baseDirectory;
|
final String baseDirectory;
|
||||||
@ -33,7 +42,6 @@ class GitNoteRepository implements NoteRepository {
|
|||||||
notesBasePath = p.join(baseDirectory, dirName, subDirName);
|
notesBasePath = p.join(baseDirectory, dirName, subDirName);
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
|
||||||
Future<NoteRepoResult> addNote(Note note) async {
|
Future<NoteRepoResult> addNote(Note note) async {
|
||||||
return _addNote(note, "Added Journal Entry");
|
return _addNote(note, "Added Journal Entry");
|
||||||
}
|
}
|
||||||
@ -48,7 +56,6 @@ class GitNoteRepository implements NoteRepository {
|
|||||||
return NoteRepoResult(noteFilePath: note.filePath, error: false);
|
return NoteRepoResult(noteFilePath: note.filePath, error: false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
|
||||||
Future<NoteRepoResult> removeNote(Note note) async {
|
Future<NoteRepoResult> removeNote(Note note) async {
|
||||||
var gitDir = p.join(baseDirectory, dirName);
|
var gitDir = p.join(baseDirectory, dirName);
|
||||||
var pathSpec = note.filePath.replaceFirst(gitDir, "").substring(1);
|
var pathSpec = note.filePath.replaceFirst(gitDir, "").substring(1);
|
||||||
@ -67,12 +74,10 @@ class GitNoteRepository implements NoteRepository {
|
|||||||
return NoteRepoResult(error: false);
|
return NoteRepoResult(error: false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
|
||||||
Future<NoteRepoResult> updateNote(Note note) async {
|
Future<NoteRepoResult> updateNote(Note note) async {
|
||||||
return _addNote(note, "Edited Journal Entry");
|
return _addNote(note, "Edited Journal Entry");
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
|
||||||
Future<List<Note>> listNotes() async {
|
Future<List<Note>> listNotes() async {
|
||||||
final dir = Directory(notesBasePath);
|
final dir = Directory(notesBasePath);
|
||||||
|
|
||||||
@ -91,7 +96,6 @@ class GitNoteRepository implements NoteRepository {
|
|||||||
return notes;
|
return notes;
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
|
||||||
Future<bool> sync() async {
|
Future<bool> sync() async {
|
||||||
try {
|
try {
|
||||||
await _gitRepo.pull();
|
await _gitRepo.pull();
|
||||||
|
@ -1,25 +0,0 @@
|
|||||||
import 'dart:async';
|
|
||||||
|
|
||||||
import 'package:flutter/foundation.dart';
|
|
||||||
import 'package:journal/note.dart';
|
|
||||||
|
|
||||||
class NoteRepoResult {
|
|
||||||
bool error;
|
|
||||||
String noteFilePath;
|
|
||||||
|
|
||||||
NoteRepoResult({
|
|
||||||
@required this.error,
|
|
||||||
this.noteFilePath,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
abstract class NoteRepository {
|
|
||||||
// TODO: Better error message!
|
|
||||||
Future<bool> sync();
|
|
||||||
|
|
||||||
Future<NoteRepoResult> addNote(Note note);
|
|
||||||
Future<NoteRepoResult> updateNote(Note note);
|
|
||||||
Future<NoteRepoResult> removeNote(Note note);
|
|
||||||
|
|
||||||
Future<List<Note>> listNotes();
|
|
||||||
}
|
|
Reference in New Issue
Block a user