Skip to content

Commit

Permalink
Should create new item instead of re-using it
Browse files Browse the repository at this point in the history
  • Loading branch information
qdraw committed Nov 11, 2024
1 parent 6d0c0df commit 5043e3f
Showing 1 changed file with 3 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,20 +36,19 @@ public ThumbnailQueryFactory(SetupDatabaseTypes? setupDatabaseTypes,
}

var context = _setupDatabaseTypes?.BuilderDbFactory();
if ( _thumbnailQuery.GetType() == typeof(ThumbnailQuery) && context != null &&
_memoryCache != null )
if ( _thumbnailQuery.GetType() == typeof(ThumbnailQuery) && context != null )
{
return new ThumbnailQuery(context, _serviceScopeFactory, _logger, _memoryCache);
}

// FakeIQuery should skip creation
var isAnyContentIncluded =
_thumbnailQuery.GetReflectionFieldValue<List<ThumbnailItem>?>("_content")?.Count != 0;
_thumbnailQuery.GetReflectionFieldValue<List<ThumbnailItem>?>("_content") != null;

if ( !isAnyContentIncluded )
{
return Activator.CreateInstance(_thumbnailQuery.GetType(),
context, _serviceScopeFactory, _logger) as IThumbnailQuery;
context, _serviceScopeFactory, _logger, _memoryCache) as IThumbnailQuery;
}

_logger.LogInformation("FakeIThumbnailQuery _content detected");
Expand Down

0 comments on commit 5043e3f

Please sign in to comment.