Skip to content

Commit

Permalink
Fix #1378 Update Talawa to give a meaningful message if the URL isn't…
Browse files Browse the repository at this point in the history
… available.
  • Loading branch information
Ayush0Chaudhary committed Dec 30, 2022
1 parent 9c563eb commit c22d593
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 16 deletions.
6 changes: 5 additions & 1 deletion lib/services/database_mutation_functions.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import 'dart:async';

import 'package:flutter/material.dart';
import 'package:graphql_flutter/graphql_flutter.dart';
import 'package:talawa/locator.dart';
Expand Down Expand Up @@ -37,7 +39,9 @@ class DataBaseMutationFunctions {
if (exception.linkException != null) {
debugPrint(exception.linkException.toString());
if (showSnackBar) {
navigationService.showSnackBar("Server not running/wrong url");
Timer(const Duration(seconds: 2), () {
navigationService.showSnackBar("Server not running/wrong url");
});
}
return false;
}
Expand Down
10 changes: 4 additions & 6 deletions lib/utils/validators.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,14 @@ import 'package:flutter/cupertino.dart';
import 'package:http/http.dart' as http;

class Validator {
static Future<String?> validateURL(
static String? validateURL(
String value,
) async {
) {
if (value.isEmpty) {
return 'Please verify URL first';
}
Uri uri = Uri.parse(value);
// final bool validURL = uri.isAbsolute;
final response = await http.get(uri);
if (response.statusCode != 200) {
final bool validURL = Uri.parse(value).isAbsolute;
if (!validURL) {
return 'Enter a valid URL';
}
return null;
Expand Down
13 changes: 4 additions & 9 deletions lib/widgets/organization_list.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import 'dart:async';

import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:graphql_flutter/graphql_flutter.dart';
Expand Down Expand Up @@ -32,17 +34,10 @@ class OrganizationList extends StatelessWidget {
Future<QueryResult?> Function()? refetch,
}) {
if (result.hasException) {
final isException = databaseFunctions.encounteredExceptionOrError(
databaseFunctions.encounteredExceptionOrError(
result.exception!,
showSnackBar: false,
showSnackBar: true,
);
if (isException != null) {
if (isException) {
refetch!();
} else {
refetch!();
}
}
} else {
if (!result.isLoading) {
model.organizations = OrgInfo().fromJsonToList(
Expand Down

0 comments on commit c22d593

Please sign in to comment.