Skip to content

Commit

Permalink
see #1245: test when the ttl cache is cleared, should reset notificat…
Browse files Browse the repository at this point in the history
…ion flag test passing
  • Loading branch information
naveen17797 committed Jan 6, 2021
1 parent 7eef535 commit 9718210
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions src/wordlift/admin/class-key-validation-notice.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,18 +83,19 @@ private function is_key_valid() {
}

$is_valid = $this->key_validation_service->is_key_valid( $key );

// when the cache is set, clear the notification flag.
delete_option( self::NOTIFICATION_OPTION_KEY );

$this->ttl_cache_service->put( self::CACHE_KEY, $is_valid );

return $is_valid;
}

private function display_key_validation_notice() {
add_action( 'admin_notices', function () {
$is_notification_shown = get_option( self::NOTIFICATION_OPTION_KEY, false );

if ( $is_notification_shown ) {
return;
}
$is_notification_shown = get_option( self::NOTIFICATION_OPTION_KEY, false );

$key = $this->configuration_service->get_key();

Expand All @@ -107,6 +108,10 @@ private function display_key_validation_notice() {
return;
}

if ( $is_notification_shown ) {
return;
}

$this->show_notification();

} );
Expand Down

0 comments on commit 9718210

Please sign in to comment.