♿ 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 descriptionController = TextEditingController();
|
||||||
final TextEditingController aliasController = TextEditingController();
|
final TextEditingController aliasController = TextEditingController();
|
||||||
|
|
||||||
PostWriteController() {
|
bool _temporarySaveActive = false;
|
||||||
|
|
||||||
|
PostWriteController({bool doLoadFromTemporary = true}) {
|
||||||
|
_temporarySaveActive = doLoadFromTemporary;
|
||||||
titleController.addListener(() {
|
titleController.addListener(() {
|
||||||
_temporaryPlanSave();
|
_temporaryPlanSave();
|
||||||
notifyListeners();
|
notifyListeners();
|
||||||
@ -166,7 +169,7 @@ class PostWriteController extends ChangeNotifier {
|
|||||||
contentController.addListener(() {
|
contentController.addListener(() {
|
||||||
_temporaryPlanSave();
|
_temporaryPlanSave();
|
||||||
});
|
});
|
||||||
_temporaryLoad();
|
if (doLoadFromTemporary) _temporaryLoad();
|
||||||
}
|
}
|
||||||
|
|
||||||
String mode = kTitleMap.keys.first;
|
String mode = kTitleMap.keys.first;
|
||||||
@ -317,6 +320,7 @@ class PostWriteController extends ChangeNotifier {
|
|||||||
Timer? _temporarySaveTimer;
|
Timer? _temporarySaveTimer;
|
||||||
|
|
||||||
void _temporaryPlanSave() {
|
void _temporaryPlanSave() {
|
||||||
|
if (!_temporarySaveActive) return;
|
||||||
_temporarySaveTimer?.cancel();
|
_temporarySaveTimer?.cancel();
|
||||||
_temporarySaveTimer = Timer(const Duration(seconds: 1), () {
|
_temporarySaveTimer = Timer(const Duration(seconds: 1), () {
|
||||||
_temporarySave();
|
_temporarySave();
|
||||||
|
@ -54,7 +54,9 @@ class PostEditorScreen extends StatefulWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class _PostEditorScreenState extends State<PostEditorScreen> {
|
class _PostEditorScreenState extends State<PostEditorScreen> {
|
||||||
final PostWriteController _writeController = PostWriteController();
|
late final PostWriteController _writeController = PostWriteController(
|
||||||
|
doLoadFromTemporary: widget.postEditId == null,
|
||||||
|
);
|
||||||
|
|
||||||
bool _isFetching = false;
|
bool _isFetching = false;
|
||||||
|
|
||||||
|
@ -25,7 +25,7 @@ class PostMiniEditor extends StatefulWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class _PostMiniEditorState extends State<PostMiniEditor> {
|
class _PostMiniEditorState extends State<PostMiniEditor> {
|
||||||
final PostWriteController _writeController = PostWriteController();
|
final PostWriteController _writeController = PostWriteController(doLoadFromTemporary: false);
|
||||||
|
|
||||||
bool _isFetching = false;
|
bool _isFetching = false;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user