Explorar o código

bug fix : empty string being saved everytime file info is closed without editing caption

ashilkn %!s(int64=2) %!d(string=hai) anos
pai
achega
e5125254b2
Modificáronse 1 ficheiros con 8 adicións e 3 borrados
  1. 8 3
      lib/ui/viewer/file/file_caption_widget.dart

+ 8 - 3
lib/ui/viewer/file/file_caption_widget.dart

@@ -16,7 +16,7 @@ class _FileCaptionWidgetState extends State<FileCaptionWidget> {
   int currentLength = 0;
   int currentLength = 0;
   final _textController = TextEditingController();
   final _textController = TextEditingController();
   final _focusNode = FocusNode();
   final _focusNode = FocusNode();
-  String editedCaption = "";
+  String? editedCaption;
 
 
   @override
   @override
   void initState() {
   void initState() {
@@ -27,12 +27,15 @@ class _FileCaptionWidgetState extends State<FileCaptionWidget> {
         editedCaption = caption;
         editedCaption = caption;
       }
       }
     });
     });
+    editedCaption = widget.file.caption;
     super.initState();
     super.initState();
   }
   }
 
 
   @override
   @override
   void dispose() {
   void dispose() {
-    editFileCaption(null, widget.file, editedCaption);
+    if (editedCaption != null) {
+      editFileCaption(null, widget.file, editedCaption);
+    }
     _textController.dispose();
     _textController.dispose();
     _focusNode.removeListener(() {});
     _focusNode.removeListener(() {});
     super.dispose();
     super.dispose();
@@ -45,7 +48,9 @@ class _FileCaptionWidgetState extends State<FileCaptionWidget> {
     final caption = widget.file.caption;
     final caption = widget.file.caption;
     return TextField(
     return TextField(
       onEditingComplete: () {
       onEditingComplete: () {
-        editFileCaption(context, widget.file, editedCaption);
+        if (editedCaption != null) {
+          editFileCaption(context, widget.file, editedCaption);
+        }
         _focusNode.unfocus();
         _focusNode.unfocus();
       },
       },
       controller: _textController,
       controller: _textController,