Browse Source

Anon feedback dialog post account deletion (#917)

Neeraj Gupta 2 years ago
parent
commit
e8d3aa4e91
2 changed files with 29 additions and 3 deletions
  1. 8 3
      lib/services/user_service.dart
  2. 21 0
      lib/ui/account/delete_account_page.dart

+ 8 - 3
lib/services/user_service.dart

@@ -112,6 +112,13 @@ class UserService {
     }
   }
 
+  Future<void> sendFeedback(BuildContext context, String feedback) async {
+    await _dio.post(
+      _config.getHttpEndpoint() + "/anonymous/feedback",
+      data: {"feedback": feedback},
+    );
+  }
+
   // getPublicKey returns null value if email id is not
   // associated with another ente account
   Future<String?> getPublicKey(String email) async {
@@ -523,9 +530,7 @@ class UserService {
     try {
       await _enteDio.post(
         "/users/two-factor/enable",
-        data: {
-          "code": code
-        },
+        data: {"code": code},
       );
       await dialog.hide();
       Navigator.pop(context);

+ 21 - 0
lib/ui/account/delete_account_page.dart

@@ -1,6 +1,7 @@
 import 'dart:convert';
 
 import 'package:flutter/material.dart';
+import "package:logging/logging.dart";
 import 'package:photos/core/configuration.dart';
 import 'package:photos/models/delete_account.dart';
 import 'package:photos/services/local_authentication_service.dart';
@@ -157,7 +158,27 @@ class DeleteAccountPage extends StatelessWidget {
       if (choice.action != ButtonAction.first) {
         return;
       }
+
       Navigator.of(context).popUntil((route) => route.isFirst);
+      await showTextInputDialog(
+        context,
+        title: "Your account was deleted. Would you like to leave us a note?",
+        submitButtonLabel: "Send",
+        hintText: "Optional, as short as you like...",
+        alwaysShowSuccessState: true,
+        textCapitalization: TextCapitalization.words,
+        onSubmit: (String text) async {
+          // indicates user cancelled the rename request
+          if (text == "" || text.trim().isEmpty) {
+            return;
+          }
+          try {
+            await UserService.instance.sendFeedback(context, text);
+          } catch (e, s) {
+            Logger("Delete account").severe("Failed to send feedback", e, s);
+          }
+        },
+      );
     }
   }