mirror of
https://github.com/GitJournal/GitJournal.git
synced 2025-09-17 08:56:43 +08:00
@ -68,6 +68,19 @@ class GitNoteRepository {
|
||||
return NoteRepoResult(noteFilePath: newFullPath, error: false);
|
||||
}
|
||||
|
||||
Future<NoteRepoResult> renameNote(
|
||||
String oldFullPath,
|
||||
String newFullPath,
|
||||
) async {
|
||||
// FIXME: This is a hacky way of adding the changes, ideally we should be calling rm + add or something
|
||||
await _gitRepo.add(".");
|
||||
await _gitRepo.commit(
|
||||
message: "Renamed Note",
|
||||
);
|
||||
|
||||
return NoteRepoResult(noteFilePath: newFullPath, error: false);
|
||||
}
|
||||
|
||||
Future<NoteRepoResult> removeNote(String noteFilePath) async {
|
||||
var pathSpec = noteFilePath.replaceFirst(gitDirPath, "").substring(1);
|
||||
|
||||
|
@ -155,6 +155,15 @@ class Note with ChangeNotifier implements Comparable<Note> {
|
||||
await file.delete();
|
||||
}
|
||||
|
||||
void rename(String newName) {
|
||||
var parentDirName = p.dirname(filePath);
|
||||
var newFilePath = p.join(parentDirName, newName);
|
||||
File(filePath).renameSync(newFilePath);
|
||||
_filePath = newFilePath;
|
||||
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
@override
|
||||
int get hashCode => _filePath.hashCode;
|
||||
|
||||
|
Reference in New Issue
Block a user