Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update ktdart to 0.6.0 #118

Open
wants to merge 3 commits into
base: development
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 3 additions & 7 deletions core/lib/src/networking/tmdb_api.dart
Original file line number Diff line number Diff line change
Expand Up @@ -63,19 +63,15 @@ class TMDBApi {
}

KtList<Actor> _parseActorAvatars(List<Map<String, dynamic>> movieCast) {
final actorsWithAvatars = mutableListOf<Actor>();

movieCast.forEach((Map<String, dynamic> 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;
}
}
25 changes: 11 additions & 14 deletions core/lib/src/redux/actor/actor_reducer.dart
Original file line number Diff line number Diff line change
Expand Up @@ -14,22 +14,19 @@ KtMap<String, Actor> actorReducer(KtMap<String, Actor> state, dynamic action) {

KtMap<String, Actor> _updateActors(
KtMap<String, Actor> 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<String, Actor> _updateActorAvatars(
KtMap<String, Actor> 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();
}
2 changes: 1 addition & 1 deletion core/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 4 additions & 4 deletions core/test/redux/actor_reducer_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ void main() {
'when called with ActorsUpdatedAction, should not modify existing actors',
() {
final state = AppState.initial().copyWith(
actorsByName: mapFrom<String, Actor>({
actorsByName: mapFrom({
'Seth Ladd': Actor(
name: 'Seth Ladd',
avatarUrl: 'https://seths-avatar-url',
Expand All @@ -34,7 +34,7 @@ void main() {

expect(
reducedState.actorsByName,
mapFrom<String, Actor>({
mapFrom({
'Seth Ladd': Actor(
name: 'Seth Ladd',
avatarUrl: 'https://seths-avatar-url',
Expand All @@ -55,7 +55,7 @@ void main() {
'when called with ReceivedActorAvatarsAction, should add urls for actors',
() {
final state = AppState.initial().copyWith(
actorsByName: mapFrom<String, Actor>({
actorsByName: mapFrom({
'Seth Ladd': Actor(name: 'Seth Ladd', avatarUrl: null),
'Eric Seidel': Actor(name: 'Eric Seidel', avatarUrl: null),
}),
Expand All @@ -71,7 +71,7 @@ void main() {

expect(
reducedState.actorsByName,
mapFrom<String, Actor>({
mapFrom({
'Seth Ladd': Actor(
name: 'Seth Ladd',
avatarUrl: 'https://seths-avatar-url',
Expand Down
2 changes: 1 addition & 1 deletion mobile/lib/ui/event_details/event_gallery_grid.dart
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ class _Grid extends StatelessWidget {
),
children: event.galleryImages.map((image) {
return _GalleryImage(image.location);
}).list,
}).asList(),
);
}
}
Expand Down
2 changes: 1 addition & 1 deletion mobile/lib/ui/showtimes/showtime_date_selector.dart
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class ShowtimeDateSelector extends StatelessWidget {
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: viewModel.dates.map((date) {
return _DateSelectorItem(date, viewModel);
}).list,
}).asList(),
),
),
);
Expand Down
Original file line number Diff line number Diff line change
@@ -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';

Expand All @@ -18,7 +19,7 @@ class TheaterSelectorDropdownMenuComponent {

TheaterListViewModel get _viewModel => TheaterListViewModel.fromStore(_store);
Theater get selectedTheater => _viewModel.currentTheater;
List<Theater> get theaters => _viewModel.theaters.list;
KtList<Theater> get theaters => _viewModel.theaters;

bool get focusTrapVisible => isOpen;
bool isOpen = false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<div class="menu" [class.opened]="isOpen" [style.background]="background">
<div class="item"
[class.selected]="theater == selectedTheater"
*ngFor="let theater of theaters"
*ngFor="let theater of theaters.asList()"
(click)="onTheaterClicked(theater)">
{{ theater.name }}
</div>
Expand Down
4 changes: 2 additions & 2 deletions web/lib/src/event_details/event_details_component.html
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ <h3>{{ messages.storyline }}</h3>
<div class="section white top-shadow actor-section" *ngIf="event.actors.isNotEmpty()">
<div class="centered-content">
<h3>{{ messages.cast }}</h3>
<actor-scroller [actors]="event.actors.list"></actor-scroller>
<actor-scroller [actors]="event.actors.asList()"></actor-scroller>
</div>
</div>

Expand All @@ -41,7 +41,7 @@ <h3>{{ messages.cast }}</h3>
<h3>{{ messages.gallery }}</h3>

<div class="gallery">
<img *ngFor="let galleryImage of event.galleryImages.list" [src]="galleryImage.location"
<img *ngFor="let galleryImage of event.galleryImages.asList()" [src]="galleryImage.location"
[alt]="'A still frame from the movie ' + event.title"/>
</div>
</div>
Expand Down
2 changes: 1 addition & 1 deletion web/lib/src/events/events_page_component.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ <h3>{{ eventTypeTitle }}</h3>
[errorMessage]="messages.errorLoadingEvents"
(actionButtonClicked)="viewModel.refreshEvents()">
<div class="grid-container">
<event-poster *ngFor="let event of viewModel.events.list"
<event-poster *ngFor="let event of viewModel.events.asList()"
[event]="event"
[isComingSoon]="isDisplayingComingSoonMovies"
(click)="openEventDetails(event)">
Expand Down
4 changes: 2 additions & 2 deletions web/lib/src/showtimes/showtimes_page_component.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@ <h3>{{ messages.showtimes }}</h3>
<theater-selector></theater-selector>
</div>

<date-selector [dates]="viewModel.dates.list"
<date-selector [dates]="viewModel.dates.asList()"
[selectedDate]="viewModel.selectedDate"
[newDateSelected]="viewModel.changeCurrentDate"></date-selector>

<loading-view
[status]="viewModel.status"
[contentEmpty]="shows.isEmpty()"
(actionButtonClicked)="viewModel.refreshShowtimes()">
<showtime-item *ngFor="let show of shows.list"
<showtime-item *ngFor="let show of shows.asList()"
[show]="show"
(click)="openShowDetails(show)"></showtime-item>
</loading-view>
Expand Down