Skip to content

Commit

Permalink
changed name of ui_state.disable_png_cache_until_action_completes to …
Browse files Browse the repository at this point in the history
…export_svg_action_delayed_for_png_cache, and changed its type from generic Action to ExportSvg, and same with associated variables and props
  • Loading branch information
dave-doty committed Sep 20, 2022
1 parent 61de27e commit 248587b
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 15 deletions.
4 changes: 2 additions & 2 deletions lib/src/middleware/export_svg.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@ export_svg_middleware(Store<AppState> store, dynamic action, NextDispatcher next
var ui_state = store.state.ui_state;
var dna_sequence_png_uri = ui_state.dna_sequence_png_uri;
var is_zoom_above_threshold = ui_state.is_zoom_above_threshold;
var disable_png_cache_until_action_completes = ui_state.disable_png_cache_until_action_completes;
var export_svg_action_delayed_for_png_cache = ui_state.export_svg_action_delayed_for_png_cache;
var disable_png_caching_dna_sequences = ui_state.disable_png_caching_dna_sequences;

bool using_png_dna_sequence = util.use_png(
dna_sequence_png_uri,
is_zoom_above_threshold,
disable_png_cache_until_action_completes,
export_svg_action_delayed_for_png_cache,
disable_png_caching_dna_sequences
);

Expand Down
2 changes: 1 addition & 1 deletion lib/src/reducers/app_ui_state_reducer.dart
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ AppUIState ui_state_local_reducer(AppUIState ui_state, action) =>
..dna_sequence_png_vertical_offset =
dna_sequence_vertical_offset_reducer(ui_state.dna_sequence_png_vertical_offset, action)
..disable_png_cache_until_action_completes =
disable_png_cache_until_action_completes(ui_state.disable_png_cache_until_action_completes, action)
disable_png_cache_until_action_completes(ui_state.export_svg_action_delayed_for_png_cache, action)
..is_zoom_above_threshold = is_zoom_above_threshold_reducer(ui_state.is_zoom_above_threshold, action));

bool helix_change_apply_to_all_reducer(bool helix_change_apply_to_all, action) {
Expand Down
4 changes: 2 additions & 2 deletions lib/src/state/app_ui_state.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import 'package:built_value/built_value.dart';
import 'package:scadnano/src/state/design_side_rotation_data.dart';
import 'package:scadnano/src/state/modification.dart';
import 'package:scadnano/src/state/copy_info.dart';
import '../actions/actions.dart';
import '../actions/actions.dart' as actions;
import '../state/local_storage_design_choice.dart';

import 'app_ui_state_storables.dart';
Expand Down Expand Up @@ -115,7 +115,7 @@ abstract class AppUIState with BuiltJsonSerializable implements Built<AppUIState
/// Otherwise, disable png-caching (if a png would otherwise be used)
/// until action is dispatched.
@nullable
Action get disable_png_cache_until_action_completes;
actions.ExportSvg get export_svg_action_delayed_for_png_cache;

/// PNG image should be used (if available) if false.
bool get is_zoom_above_threshold;
Expand Down
4 changes: 2 additions & 2 deletions lib/src/util.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1497,10 +1497,10 @@ void svg_to_png_data() {
/// and the zoom is not above threshold `is_zoom_above_threshold`,
/// and there is no pending action `disable_png_cache_until_action_completes`.
bool use_png(String dna_sequence_png_uri, bool is_zoom_above_threshold,
actions.Action disable_png_cache_until_action_completes, bool disable_png_caching_dna_sequences) {
actions.ExportSvg export_svg_action_delayed_for_png_cache, bool disable_png_caching_dna_sequences) {
return dna_sequence_png_uri != null &&
!is_zoom_above_threshold &&
disable_png_cache_until_action_completes == null &&
export_svg_action_delayed_for_png_cache == null &&
!disable_png_caching_dna_sequences;
}

Expand Down
6 changes: 3 additions & 3 deletions lib/src/view/design_main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ UiFactory<DesignMainProps> ConnectedDesignMain = connect<AppState, DesignMainPro
..dna_sequence_png_uri = state.ui_state.dna_sequence_png_uri
..dna_sequence_png_horizontal_offset = state.ui_state.dna_sequence_png_horizontal_offset
..dna_sequence_png_vertical_offset = state.ui_state.dna_sequence_png_vertical_offset
..disable_png_cache_until_action_completes = state.ui_state.disable_png_cache_until_action_completes
..export_svg_action_delayed_for_png_cache = state.ui_state.export_svg_action_delayed_for_png_cache
..is_zoom_above_threshold = state.ui_state.is_zoom_above_threshold
..only_display_selected_helices = state.ui_state.only_display_selected_helices
..display_base_offsets_of_major_ticks = state.ui_state.display_base_offsets_of_major_ticks
Expand Down Expand Up @@ -113,7 +113,7 @@ mixin DesignMainPropsMixin on UiProps {
String dna_sequence_png_uri;
num dna_sequence_png_horizontal_offset;
num dna_sequence_png_vertical_offset;
actions.Action disable_png_cache_until_action_completes;
actions.ExportSvg export_svg_action_delayed_for_png_cache;
bool is_zoom_above_threshold;
bool only_display_selected_helices;
bool helix_change_apply_to_all;
Expand Down Expand Up @@ -234,7 +234,7 @@ class DesignMainComponent extends UiComponent2<DesignMainProps> {
..dna_sequence_png_horizontal_offset = props.dna_sequence_png_horizontal_offset
..dna_sequence_png_vertical_offset = props.dna_sequence_png_vertical_offset
..is_zoom_above_threshold = props.is_zoom_above_threshold
..disable_png_cache_until_action_completes = props.disable_png_cache_until_action_completes
..export_svg_action_delayed_for_png_cache = props.export_svg_action_delayed_for_png_cache
..only_display_selected_helices = props.only_display_selected_helices
..helix_idx_to_svg_position_map = props.helix_idx_to_svg_position_map
..disable_png_caching_dna_sequences = props.disable_png_caching_dna_sequences
Expand Down
6 changes: 3 additions & 3 deletions lib/src/view/design_main_dna_sequences.dart
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ mixin DesignMainDNASequencesProps on UiProps {
num dna_sequence_png_horizontal_offset;
num dna_sequence_png_vertical_offset;
bool is_zoom_above_threshold;
actions.Action disable_png_cache_until_action_completes;
actions.ExportSvg export_svg_action_delayed_for_png_cache;
bool only_display_selected_helices;
BuiltMap<int, Point<num>> helix_idx_to_svg_position_map;
bool disable_png_caching_dna_sequences;
Expand All @@ -40,7 +40,7 @@ class DesignMainDNASequencesComponent extends UiComponent2<DesignMainDNASequence
/// If this prop is not null, then it dispatches the prop action before disabling it.
@override
void componentDidUpdate(Map prevProps, Map prevState, [snapshot]) {
var action_to_complete = props.disable_png_cache_until_action_completes;
var action_to_complete = props.export_svg_action_delayed_for_png_cache;

if (action_to_complete != null) {
app.dispatch(action_to_complete);
Expand All @@ -53,7 +53,7 @@ class DesignMainDNASequencesComponent extends UiComponent2<DesignMainDNASequence
@override
render() {
bool should_use_png_dna_sequence = use_png(props.dna_sequence_png_uri, props.is_zoom_above_threshold,
props.disable_png_cache_until_action_completes, props.disable_png_caching_dna_sequences);
props.export_svg_action_delayed_for_png_cache, props.disable_png_caching_dna_sequences);

if (should_use_png_dna_sequence) {
// DNA sequence png.
Expand Down
4 changes: 2 additions & 2 deletions test/reducer_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5555,10 +5555,10 @@ main() {

AppState new_state = app_state_reducer(old_state, SetDisablePngCacheUntilActionCompletes(action));

expect(new_state.ui_state.disable_png_cache_until_action_completes, action);
expect(new_state.ui_state.export_svg_action_delayed_for_png_cache, action);

new_state = app_state_reducer(new_state, SetDisablePngCacheUntilActionCompletes(null));
expect(new_state.ui_state.disable_png_cache_until_action_completes, null);
expect(new_state.ui_state.export_svg_action_delayed_for_png_cache, null);
});
});

Expand Down

0 comments on commit 248587b

Please sign in to comment.