diff --git a/lib/controllers/post_write_controller.dart b/lib/controllers/post_write_controller.dart index 77749ff..0593eb5 100644 --- a/lib/controllers/post_write_controller.dart +++ b/lib/controllers/post_write_controller.dart @@ -154,7 +154,10 @@ class PostWriteController extends ChangeNotifier { final TextEditingController descriptionController = TextEditingController(); final TextEditingController aliasController = TextEditingController(); - PostWriteController() { + bool _temporarySaveActive = false; + + PostWriteController({bool doLoadFromTemporary = true}) { + _temporarySaveActive = doLoadFromTemporary; titleController.addListener(() { _temporaryPlanSave(); notifyListeners(); @@ -166,7 +169,7 @@ class PostWriteController extends ChangeNotifier { contentController.addListener(() { _temporaryPlanSave(); }); - _temporaryLoad(); + if (doLoadFromTemporary) _temporaryLoad(); } String mode = kTitleMap.keys.first; @@ -317,6 +320,7 @@ class PostWriteController extends ChangeNotifier { Timer? _temporarySaveTimer; void _temporaryPlanSave() { + if (!_temporarySaveActive) return; _temporarySaveTimer?.cancel(); _temporarySaveTimer = Timer(const Duration(seconds: 1), () { _temporarySave(); diff --git a/lib/screens/post/post_editor.dart b/lib/screens/post/post_editor.dart index 47e2770..309223c 100644 --- a/lib/screens/post/post_editor.dart +++ b/lib/screens/post/post_editor.dart @@ -54,7 +54,9 @@ class PostEditorScreen extends StatefulWidget { } class _PostEditorScreenState extends State { - final PostWriteController _writeController = PostWriteController(); + late final PostWriteController _writeController = PostWriteController( + doLoadFromTemporary: widget.postEditId == null, + ); bool _isFetching = false; diff --git a/lib/widgets/post/post_mini_editor.dart b/lib/widgets/post/post_mini_editor.dart index 676a211..a9fd8b8 100644 --- a/lib/widgets/post/post_mini_editor.dart +++ b/lib/widgets/post/post_mini_editor.dart @@ -25,7 +25,7 @@ class PostMiniEditor extends StatefulWidget { } class _PostMiniEditorState extends State { - final PostWriteController _writeController = PostWriteController(); + final PostWriteController _writeController = PostWriteController(doLoadFromTemporary: false); bool _isFetching = false;