Skip to content

Commit

Permalink
chore: show loading indicator while fetching link preview (resolve #17)
Browse files Browse the repository at this point in the history
  • Loading branch information
muety committed Dec 5, 2021
1 parent 748d5fd commit e60f305
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 14 deletions.
1 change: 0 additions & 1 deletion android/gradle.properties
Original file line number Diff line number Diff line change
@@ -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/
6 changes: 3 additions & 3 deletions android/local.properties
Original file line number Diff line number Diff line change
@@ -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
flutter.versionName=1.2.3
flutter.buildMode=release
flutter.versionCode=31
19 changes: 10 additions & 9 deletions lib/pages/add_link_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -55,18 +55,19 @@ class _AddLinkPageState extends AnchrState<AddLinkPage> 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
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -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"
Expand Down

0 comments on commit e60f305

Please sign in to comment.