Skip to content

armgit / ente

Public Imported from GitHub
0

πŸ’š End-to-end encrypted cloud for everything.

Focus added auth codes by issuer

Neeraj Gupta82ad840b10cb
diff --git a/mobile/apps/auth/lib/ui/home_page.dart b/mobile/apps/auth/lib/ui/home_page.dart
index d3c5ee384c..f58874fe08 100644
--- a/mobile/apps/auth/lib/ui/home_page.dart
+++ b/mobile/apps/auth/lib/ui/home_page.dart
@@ -78,6 +78,11 @@ class HomePage extends BaseHomePage {
State<HomePage> createState() => _HomePageState();
}
+@visibleForTesting
+String addedCodeFocusSearchQuery(Code code) {
+ return code.issuer.trim().isNotEmpty ? code.issuer : code.account;
+}
+
class _HomePageState extends State<HomePage> {
final _codeDisplayStore = CodeDisplayStore.instance;
late final _settingsPage = SettingsPage(
@@ -2021,8 +2026,9 @@ class _HomePageState extends State<HomePage> {
_showSearchBox = true;
selectedTag = "";
_isTrashOpen = false;
- _textController.text = newCode.account;
- _searchText = newCode.account;
+ final searchQuery = addedCodeFocusSearchQuery(newCode);
+ _textController.text = searchQuery;
+ _searchText = searchQuery;
_applyFilteringAndRefresh();
}
diff --git a/mobile/apps/auth/test/ui/home_page_test.dart b/mobile/apps/auth/test/ui/home_page_test.dart
new file mode 100644
index 0000000000..9e46cbf4e0
--- /dev/null
+++ b/mobile/apps/auth/test/ui/home_page_test.dart
@@ -0,0 +1,21 @@
+import 'package:ente_auth/models/code.dart';
+import 'package:ente_auth/ui/home_page.dart';
+import 'package:flutter_test/flutter_test.dart';
+
+void main() {
+ test('newly added code focus search prefers issuer', () {
+ final code = Code.fromOTPAuthUrl(
+ 'otpauth://totp/[email protected]?secret=ASKZNWOU6SVYAMVS&issuer=GitHub',
+ );
+
+ expect(addedCodeFocusSearchQuery(code), 'GitHub');
+ });
+
+ test('newly added code focus search falls back to account', () {
+ final code = Code.fromOTPAuthUrl(
+ 'otpauth://totp/[email protected]?secret=ASKZNWOU6SVYAMVS',
+ );
+
+ expect(addedCodeFocusSearchQuery(code), '[email protected]');
+ });
+}