Skip to content

Commit

Permalink
[fix] card bottom controls type, character store update
Browse files Browse the repository at this point in the history
  • Loading branch information
chenasraf committed Jun 10, 2020
1 parent 2628260 commit c701a57
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 16 deletions.
4 changes: 2 additions & 2 deletions android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ android {
multiDexEnabled true

// VERSION
versionCode 38
versionName "1.1.6+1"
versionCode 39
versionName "1.1.6+2"
}

// flavorDimensions "version"
Expand Down
2 changes: 1 addition & 1 deletion lib/db/listeners.dart
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ void registerCharactersListener() async {
dwStore.dispatch(
SetCharacters({
for (var character in characters.documents)
character.reference.path: Character(
character.reference.documentID: Character(
data: character.data,
ref: character.reference,
),
Expand Down
2 changes: 1 addition & 1 deletion lib/src/atoms/card_bottom_controls.dart
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class CardBottomControls extends StatelessWidget {
}

List<Widget> getButtons() {
var buttons = [];
var buttons = <Widget>[];
Widget editButton = IconButton(
tooltip: suffixType('Edit'),
icon: Icon(Icons.edit),
Expand Down
6 changes: 3 additions & 3 deletions lib/src/molecules/move_card.dart
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class MoveCard extends StatefulWidget {
class MoveCardState extends State<MoveCard> {
@override
Widget build(BuildContext context) {
Move move = widget.move;
var move = widget.move;
Widget name =
Text("${move.name}${widget.raceMove ? '\'s Racial Move' : ''}");

Expand Down Expand Up @@ -125,13 +125,13 @@ class MoveCardState extends State<MoveCard> {
);
}

_save(Move move) {
void _save(Move move) {
if (widget.onSave != null) {
widget.onSave(move);
}
}

_delete() {
void _delete() {
if (widget.onDelete != null) {
widget.onDelete();
}
Expand Down
15 changes: 6 additions & 9 deletions lib/src/redux/characters/characters_store.dart
Original file line number Diff line number Diff line change
Expand Up @@ -22,21 +22,15 @@ CharacterStore characterReducer(CharacterStore state, action) {
state.characters ??= {};
state.characters.addAll(action.characters);
}
if (action.characters.isNotEmpty &&
if (state.current != null) {
state.current = action.characters[state.current.documentID];
} else if (action.characters.isNotEmpty &&
!state.characters.containsKey(state.current?.documentID)) {
state.current = action.characters.values.first;
}
return state;
}

if (action is UpsertCharacter) {
state.characters = {
...state.characters,
action.character.documentID: action.character
};
return state;
}

if (action is RemoveCharacter) {
state.characters.removeWhere((k, v) => k == action.character.documentID);
if (state.current.documentID == action.character.documentID) {
Expand All @@ -47,6 +41,9 @@ CharacterStore characterReducer(CharacterStore state, action) {

if (action is UpsertCharacter) {
state.characters[action.character.documentID] = action.character;
if (state.current.documentID == action.character.documentID) {
state.current = action.character;
}
return state;
}

Expand Down

0 comments on commit c701a57

Please sign in to comment.