-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feat/support component versions #73
Conversation
@@ -27,7 +27,7 @@ export class HomeEffects { | |||
queryMetadataFromShapes$ = createEffect(() => this.actions$.pipe( | |||
ofType(shapesDetected), | |||
mergeMap(({shapeIds}) => forkJoin(shapeIds.concat([ 'http://digita.ai/voc/input#input' ]).map((shapeId) => this.semComService.queryComponents(shapeId)))), | |||
map((resultsPerShape) => resultsPerShape.filter((results) => results.length > 0)), | |||
map((resultsPerShape) => resultsPerShape.filter((results) => results.length > 0 && results[0])), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of checking here, we should rewrite the query function to never return undefined.
@@ -7,16 +8,27 @@ export class ComponentInMemoryStore extends ComponentStore { | |||
} | |||
|
|||
async query(filter: Partial<ComponentMetadata>): Promise<ComponentMetadata[]> { | |||
return this.components.filter((component) => | |||
let filtered = this.components.filter((component) => |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would prefer this to remain a constant, e.g. by returning other constant based on this one.
if(filtered && filter.version) { | ||
const versions = filtered.map((component) => component.version); | ||
const maxVersion = semver.maxSatisfying(versions, filter.version); | ||
filtered = [ filtered.find((component) => component.version === maxVersion) ]; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rewrite this so it does not return undefined (e.g. using filter instead of find).
No description provided.