Skip to content

Commit

Permalink
Display syncSetting error without stopping the build
Browse files Browse the repository at this point in the history
Only track syncSettings once per dev/build
  • Loading branch information
wilr authored Mar 23, 2021
1 parent 6aac96d commit 5375c8b
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion src/Extensions/AlgoliaObjectExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@ class AlgoliaObjectExtension extends DataExtension
{
use Configurable;

/**
* @var boolean
*/
private $ranSync = false;

/**
* @config
*
Expand Down Expand Up @@ -73,8 +78,18 @@ public function updateSettingsFields(FieldList $fields)
*/
public function requireDefaultRecords()
{
if ($this->ranSync) {
return false;
}

$this->ranSync = true;
$algolia = Injector::inst()->create(AlgoliaService::class);
$algolia->syncSettings();

try {
$algolia->syncSettings();
} catch (Exception $e) {
DB::alteration_message($e->getMessage(), 'error');
}
}

/**
Expand Down

0 comments on commit 5375c8b

Please sign in to comment.