From e60f305b9d9cbb010bf5d3cf21cc8e01ab2f41de Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ferdinand=20M=C3=BCtsch?= Date: Mon, 6 Dec 2021 00:57:17 +0100 Subject: [PATCH] chore: show loading indicator while fetching link preview (resolve #17) --- android/gradle.properties | 1 - android/local.properties | 6 +++--- lib/pages/add_link_page.dart | 19 ++++++++++--------- pubspec.yaml | 2 +- 4 files changed, 14 insertions(+), 14 deletions(-) diff --git a/android/gradle.properties b/android/gradle.properties index cc714bd..4e0dfe2 100644 --- a/android/gradle.properties +++ b/android/gradle.properties @@ -1,5 +1,4 @@ org.gradle.jvmargs=-Xmx1536M -android.enableR8=true android.useAndroidX=true android.enableJetifier=true org.gradle.java.home=/opt/jdk/openjdk-15.0.1/ \ No newline at end of file diff --git a/android/local.properties b/android/local.properties index 729d67c..27b8822 100644 --- a/android/local.properties +++ b/android/local.properties @@ -1,5 +1,5 @@ sdk.dir=/media/ferdinand/HDD/android/sdk flutter.sdk=/opt/flutter -flutter.versionName=1.2.2 -flutter.buildMode=debug -flutter.versionCode=30 \ No newline at end of file +flutter.versionName=1.2.3 +flutter.buildMode=release +flutter.versionCode=31 \ No newline at end of file diff --git a/lib/pages/add_link_page.dart b/lib/pages/add_link_page.dart index 85f22be..106f7c2 100644 --- a/lib/pages/add_link_page.dart +++ b/lib/pages/add_link_page.dart @@ -55,18 +55,19 @@ class _AddLinkPageState extends AnchrState with AnchrActions { } void _onLinkEdit() { - if (_linkDebounce?.isActive ?? false) _linkDebounce.cancel(); + final url = _linkInputController.text.trim(); + if (url == _mostRecentUrl || _descriptionInputController.text.isNotEmpty || !Utils.validateUrl(url)) return; - final url = _linkInputController.text.trim(); - if (url == _mostRecentUrl || _descriptionInputController.text.isNotEmpty || !Utils.validateUrl(url)) return; + if (_linkDebounce?.isActive ?? false) _linkDebounce.cancel(); - _linkDebounce = Timer(const Duration(milliseconds: 500), () async { - if (_descriptionInputController.text.isNotEmpty) return; - String pageTitle = await getPageTitle(url); - setState(() => _descriptionInputController.text = pageTitle); - }); + _linkDebounce = Timer(const Duration(milliseconds: 1000), () async { + if (_descriptionInputController.text.isNotEmpty) return; + setState(() => _descriptionInputController.text = Strings.labelLoading); + String pageTitle = await getPageTitle(url); + setState(() => _descriptionInputController.text = pageTitle ?? ''); + }); - _mostRecentUrl = url; + _mostRecentUrl = url; } @override diff --git a/pubspec.yaml b/pubspec.yaml index 2d67d89..4c567ca 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,7 +1,7 @@ name: anchr_android description: Android client for Anchr.io link collections -version: 1.2.2+30 +version: 1.2.3+31 environment: sdk: ">=2.10.0 <3.0.0"