Skip to content

Commit

Permalink
fix(thumbnail-view-defaults): Capture field_options not existing
Browse files Browse the repository at this point in the history
There are three states we're targeting here:
  1.  A new view where the default should be that show_thumbnail is on
  2.  A previously saved view where they might have enabled or disabled
      show_thumbnail
  3.  An existing view that was there before these options were
      presented (no config options set)

We want to make sure that the default behavior is that where appropriate
cards display thumbnails by default until they opt out.  This attempt to
determine if there's no config at all (existing view before update) and
sets the thumbnail option accordingly.
  • Loading branch information
dblanken-yale committed Sep 18, 2024
1 parent 06d02eb commit b3f3a08
Showing 1 changed file with 4 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -399,10 +399,13 @@ public function getView($type, $params) {

$eventTimePeriod = $paramsDecoded['filters']['event_time_period'] ?? NULL;

// Determine if we are in a state where field_options doesn't yet exist (pre-existing view)
$no_field_display_options_saved = !key_exists('field_options', $paramsDecoded) || !is_array($paramsDecoded['field_options']);

$field_display_options = [
'show_categories' => (int) !empty($paramsDecoded['field_options']['show_categories']),
'show_tags' => (int) !empty($paramsDecoded['field_options']['show_tags']),
'show_thumbnail' => (int) !empty($paramsDecoded['field_options']['show_thumbnail']),
'show_thumbnail' => (int) $no_field_display_options_saved || !empty($paramsDecoded['field_options']['show_thumbnail']),
];

$view->setArguments(
Expand Down

0 comments on commit b3f3a08

Please sign in to comment.