diff --git a/core/lib/src/networking/tmdb_api.dart b/core/lib/src/networking/tmdb_api.dart index 9fd66e9a..d5ca2b09 100644 --- a/core/lib/src/networking/tmdb_api.dart +++ b/core/lib/src/networking/tmdb_api.dart @@ -63,19 +63,15 @@ class TMDBApi { } KtList _parseActorAvatars(List> movieCast) { - final actorsWithAvatars = mutableListOf(); - - movieCast.forEach((Map castMember) { + return listFrom(movieCast).map((castMember) { String pp = castMember['profile_path']; final profilePath = pp != null ? 'https://image.tmdb.org/t/p/w200$pp' : null; - actorsWithAvatars.add(Actor( + return Actor( name: castMember['name'], avatarUrl: profilePath, - )); + ); }); - - return actorsWithAvatars; } } diff --git a/core/lib/src/redux/actor/actor_reducer.dart b/core/lib/src/redux/actor/actor_reducer.dart index e82ca57e..b22d3d77 100644 --- a/core/lib/src/redux/actor/actor_reducer.dart +++ b/core/lib/src/redux/actor/actor_reducer.dart @@ -14,22 +14,19 @@ KtMap actorReducer(KtMap state, dynamic action) { KtMap _updateActors( KtMap state, ActorsUpdatedAction action) { - final actors = state.toMutableMap(); - action.actors.forEach((actor) { - actors.putIfAbsent(actor.name, Actor(name: actor.name)); - }); - return actors.toMap(); + final updated = action.actors.associateBy((it) => it.name); + return updated.plus(state); } KtMap _updateActorAvatars( KtMap state, ReceivedActorAvatarsAction action) { - final actorsWithAvatars = state.toMutableMap(); - action.actors.forEach((actor) { - actorsWithAvatars[actor.name] = Actor( - name: actor.name, - avatarUrl: actor.avatarUrl, - ); - }); - - return actorsWithAvatars.toMap(); + final actors = state.toMutableMap(); + for (final actor in action.actors.iter) { + final current = actors[actor.name]; + if (current == null) { + continue; + } + actors.put(actor.name, actor); + } + return actors.toMap(); } diff --git a/core/pubspec.yaml b/core/pubspec.yaml index 96c7916d..5fffbc12 100644 --- a/core/pubspec.yaml +++ b/core/pubspec.yaml @@ -14,7 +14,7 @@ dependencies: http: ^0.12.0 reselect: ^0.4.0 key_value_store: ^1.0.0 - kt_dart: ^0.5.0 + kt_dart: ^0.6.0 dev_dependencies: test: ^1.3.0 diff --git a/core/test/redux/actor_reducer_test.dart b/core/test/redux/actor_reducer_test.dart index 0ab42f09..2a2629af 100644 --- a/core/test/redux/actor_reducer_test.dart +++ b/core/test/redux/actor_reducer_test.dart @@ -11,7 +11,7 @@ void main() { 'when called with ActorsUpdatedAction, should not modify existing actors', () { final state = AppState.initial().copyWith( - actorsByName: mapFrom({ + actorsByName: mapFrom({ 'Seth Ladd': Actor( name: 'Seth Ladd', avatarUrl: 'https://seths-avatar-url', @@ -34,7 +34,7 @@ void main() { expect( reducedState.actorsByName, - mapFrom({ + mapFrom({ 'Seth Ladd': Actor( name: 'Seth Ladd', avatarUrl: 'https://seths-avatar-url', @@ -55,7 +55,7 @@ void main() { 'when called with ReceivedActorAvatarsAction, should add urls for actors', () { final state = AppState.initial().copyWith( - actorsByName: mapFrom({ + actorsByName: mapFrom({ 'Seth Ladd': Actor(name: 'Seth Ladd', avatarUrl: null), 'Eric Seidel': Actor(name: 'Eric Seidel', avatarUrl: null), }), @@ -71,7 +71,7 @@ void main() { expect( reducedState.actorsByName, - mapFrom({ + mapFrom({ 'Seth Ladd': Actor( name: 'Seth Ladd', avatarUrl: 'https://seths-avatar-url', diff --git a/mobile/lib/ui/event_details/event_gallery_grid.dart b/mobile/lib/ui/event_details/event_gallery_grid.dart index f91674ee..6ca9fb2a 100644 --- a/mobile/lib/ui/event_details/event_gallery_grid.dart +++ b/mobile/lib/ui/event_details/event_gallery_grid.dart @@ -59,7 +59,7 @@ class _Grid extends StatelessWidget { ), children: event.galleryImages.map((image) { return _GalleryImage(image.location); - }).list, + }).asList(), ); } } diff --git a/mobile/lib/ui/showtimes/showtime_date_selector.dart b/mobile/lib/ui/showtimes/showtime_date_selector.dart index ff48168d..e1cf9aff 100644 --- a/mobile/lib/ui/showtimes/showtime_date_selector.dart +++ b/mobile/lib/ui/showtimes/showtime_date_selector.dart @@ -26,7 +26,7 @@ class ShowtimeDateSelector extends StatelessWidget { mainAxisAlignment: MainAxisAlignment.spaceAround, children: viewModel.dates.map((date) { return _DateSelectorItem(date, viewModel); - }).list, + }).asList(), ), ), ); diff --git a/web/lib/src/common/theater_selector/theater_selector_dropdown_menu_component.dart b/web/lib/src/common/theater_selector/theater_selector_dropdown_menu_component.dart index d30d800c..1917eeba 100644 --- a/web/lib/src/common/theater_selector/theater_selector_dropdown_menu_component.dart +++ b/web/lib/src/common/theater_selector/theater_selector_dropdown_menu_component.dart @@ -1,5 +1,6 @@ import 'package:angular/angular.dart'; import 'package:core/core.dart'; +import 'package:kt_dart/collection.dart'; import 'package:redux/redux.dart'; import 'package:web/src/common/theater_selector/theater_dropdown_controller.dart'; @@ -18,7 +19,7 @@ class TheaterSelectorDropdownMenuComponent { TheaterListViewModel get _viewModel => TheaterListViewModel.fromStore(_store); Theater get selectedTheater => _viewModel.currentTheater; - List get theaters => _viewModel.theaters.list; + KtList get theaters => _viewModel.theaters; bool get focusTrapVisible => isOpen; bool isOpen = false; diff --git a/web/lib/src/common/theater_selector/theater_selector_dropdown_menu_component.html b/web/lib/src/common/theater_selector/theater_selector_dropdown_menu_component.html index c7bda14f..d4908e28 100644 --- a/web/lib/src/common/theater_selector/theater_selector_dropdown_menu_component.html +++ b/web/lib/src/common/theater_selector/theater_selector_dropdown_menu_component.html @@ -6,7 +6,7 @@ diff --git a/web/lib/src/events/events_page_component.html b/web/lib/src/events/events_page_component.html index 4ad81f8f..774d067b 100644 --- a/web/lib/src/events/events_page_component.html +++ b/web/lib/src/events/events_page_component.html @@ -9,7 +9,7 @@

{{ eventTypeTitle }}

[errorMessage]="messages.errorLoadingEvents" (actionButtonClicked)="viewModel.refreshEvents()">
- diff --git a/web/lib/src/showtimes/showtimes_page_component.html b/web/lib/src/showtimes/showtimes_page_component.html index 927ead8b..539bb3ed 100644 --- a/web/lib/src/showtimes/showtimes_page_component.html +++ b/web/lib/src/showtimes/showtimes_page_component.html @@ -4,7 +4,7 @@

{{ messages.showtimes }}

- @@ -12,7 +12,7 @@

{{ messages.showtimes }}

[status]="viewModel.status" [contentEmpty]="shows.isEmpty()" (actionButtonClicked)="viewModel.refreshShowtimes()"> -