♿ Optimize temporary save post scenario
This commit is contained in:
parent
6ac536412a
commit
2b3a58b55e
@ -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();
|
||||
|
@ -54,7 +54,9 @@ class PostEditorScreen extends StatefulWidget {
|
||||
}
|
||||
|
||||
class _PostEditorScreenState extends State<PostEditorScreen> {
|
||||
final PostWriteController _writeController = PostWriteController();
|
||||
late final PostWriteController _writeController = PostWriteController(
|
||||
doLoadFromTemporary: widget.postEditId == null,
|
||||
);
|
||||
|
||||
bool _isFetching = false;
|
||||
|
||||
|
@ -25,7 +25,7 @@ class PostMiniEditor extends StatefulWidget {
|
||||
}
|
||||
|
||||
class _PostMiniEditorState extends State<PostMiniEditor> {
|
||||
final PostWriteController _writeController = PostWriteController();
|
||||
final PostWriteController _writeController = PostWriteController(doLoadFromTemporary: false);
|
||||
|
||||
bool _isFetching = false;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user