chore: add hardcoded fallback language list (#2207)
This commit is contained in:
parent
1b80f12f6f
commit
f8feab5eea
2 changed files with 1145 additions and 4 deletions
File diff suppressed because it is too large
Load diff
|
|
@ -8,6 +8,7 @@ import 'package:http/http.dart';
|
|||
import 'package:fluffychat/pangea/common/config/environment.dart';
|
||||
import 'package:fluffychat/pangea/common/network/urls.dart';
|
||||
import 'package:fluffychat/pangea/common/utils/error_handler.dart';
|
||||
import 'package:fluffychat/pangea/learning_settings/constants/language_constants.dart';
|
||||
import 'package:fluffychat/pangea/learning_settings/models/language_model.dart';
|
||||
import '../../common/network/requests.dart';
|
||||
|
||||
|
|
@ -16,11 +17,16 @@ class LanguageRepo {
|
|||
final Requests req = Requests(
|
||||
choreoApiKey: Environment.choreoApiKey,
|
||||
);
|
||||
final Response res = await req.get(url: PApiUrls.getLanguages);
|
||||
|
||||
final decodedBody =
|
||||
jsonDecode(utf8.decode(res.bodyBytes).toString()) as List;
|
||||
final List<LanguageModel> langFlag = decodedBody.map((e) {
|
||||
List<dynamic> languageResp = [];
|
||||
try {
|
||||
final Response res = await req.get(url: PApiUrls.getLanguages);
|
||||
languageResp = jsonDecode(utf8.decode(res.bodyBytes).toString()) as List;
|
||||
} catch (e) {
|
||||
languageResp = FallbackLanguage.languageList;
|
||||
}
|
||||
|
||||
final List<LanguageModel> langFlag = languageResp.map((e) {
|
||||
try {
|
||||
return LanguageModel.fromJson(e);
|
||||
} catch (err, stack) {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue