From f679af1a35e8101d0b30e16b8090035de531567b Mon Sep 17 00:00:00 2001 From: Alex Mikhalev Date: Thu, 16 Aug 2018 14:36:20 -0600 Subject: [PATCH] Fixed program table expansion with storing id's instead of program --- client/components/ProgramTable.tsx | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/client/components/ProgramTable.tsx b/client/components/ProgramTable.tsx index f3de61d..632e24c 100644 --- a/client/components/ProgramTable.tsx +++ b/client/components/ProgramTable.tsx @@ -82,11 +82,13 @@ class ProgramRows extends React.Component<{ } } +type ProgramId = Program["id"]; + @observer export default class ProgramTable extends React.Component<{ iDevice: ISprinklersDevice, device: SprinklersDevice, routerStore: RouterStore, }, { - expandedPrograms: Program[], + expandedPrograms: ProgramId[], }> { constructor(p: any) { super(p); @@ -122,7 +124,7 @@ export default class ProgramTable extends React.Component<{ if (!program) { return null; } - const expanded = this.state.expandedPrograms.indexOf(program) !== -1; + const expanded = this.state.expandedPrograms.indexOf(program.id) !== -1; return ( { const { expandedPrograms } = this.state; - const idx = expandedPrograms.indexOf(program); + const idx = expandedPrograms.indexOf(program.id); if (idx !== -1) { expandedPrograms.splice(idx, 1); } else { - expandedPrograms.push(program); + expandedPrograms.push(program.id); } this.setState({ expandedPrograms,