@jtran feedback, use the type guard util
This commit is contained in:
@ -1,6 +1,7 @@
|
|||||||
import { assign, fromPromise, setup } from 'xstate'
|
import { assign, fromPromise, setup } from 'xstate'
|
||||||
import { ProjectsCommandSchema } from 'lib/commandBarConfigs/projectsCommandConfig'
|
import { ProjectsCommandSchema } from 'lib/commandBarConfigs/projectsCommandConfig'
|
||||||
import { Project } from 'lib/project'
|
import { Project } from 'lib/project'
|
||||||
|
import { isArray } from 'lib/utils'
|
||||||
|
|
||||||
export const projectsMachine = setup({
|
export const projectsMachine = setup({
|
||||||
types: {
|
types: {
|
||||||
@ -51,7 +52,7 @@ export const projectsMachine = setup({
|
|||||||
actions: {
|
actions: {
|
||||||
setProjects: assign({
|
setProjects: assign({
|
||||||
projects: ({ context, event }) =>
|
projects: ({ context, event }) =>
|
||||||
'output' in event && Array.isArray(event.output)
|
'output' in event && isArray(event.output)
|
||||||
? event.output
|
? event.output
|
||||||
: context.projects,
|
: context.projects,
|
||||||
}),
|
}),
|
||||||
|
|||||||
Reference in New Issue
Block a user