@@ -8,6 +8,12 @@ import 'package:freecodecamp/service/podcast/podcasts_service.dart';
8
8
import 'package:path_provider/path_provider.dart' ;
9
9
import 'package:stacked/stacked.dart' ;
10
10
11
+ const fccPodcastUrls = [
12
+ 'https://freecodecamp.libsyn.com/rss' ,
13
+ 'https://feeds.transistor.fm/freecodecamp-podcast-en-espanol' ,
14
+ 'https://feeds.transistor.fm/freecodecamp-podcast-in-chinese'
15
+ ];
16
+
11
17
class PodcastListViewModel extends BaseViewModel {
12
18
final _databaseService = locator <PodcastsDatabaseService >();
13
19
final _developerService = locator <DeveloperService >();
@@ -32,15 +38,23 @@ class PodcastListViewModel extends BaseViewModel {
32
38
33
39
Future <List <Podcasts >> fetchPodcasts (bool isDownloadView) async {
34
40
String baseUrl = (await _developerService.developmentMode ())
35
- ? 'https://api.mobile.freecodecamp.dev/ '
36
- : 'https://api.mobile.freecodecamp.org/ ' ;
41
+ ? 'https://api.mobile.freecodecamp.dev'
42
+ : 'https://api.mobile.freecodecamp.org' ;
37
43
await _databaseService.initialise ();
38
44
if (isDownloadView) {
39
45
return await _databaseService.getPodcasts ();
40
46
} else {
41
- final res = await _dio.get ('${ baseUrl } podcasts' );
47
+ final res = await _dio.get ('$baseUrl / podcasts' );
42
48
final List <dynamic > podcasts = res.data;
43
- return podcasts.map ((podcast) => Podcasts .fromAPIJson (podcast)).toList ();
49
+ final podcastList =
50
+ podcasts.map ((podcast) => Podcasts .fromAPIJson (podcast)).toList ();
51
+ final fccPodcasts = podcastList
52
+ .where ((podcast) => fccPodcastUrls.contains (podcast.url))
53
+ .toList ();
54
+ final otherPodcasts = podcastList
55
+ .where ((podcast) => ! fccPodcastUrls.contains (podcast.url))
56
+ .toList ();
57
+ return [...fccPodcasts, ...otherPodcasts];
44
58
}
45
59
}
46
60
}
0 commit comments