Skip to content

Commit 576fe63

Browse files
authored
Merge pull request #118 from ISISComputingGroup/useState_for_lastUpdate
use a setState for lastUpdate
2 parents 281da23 + 74846f2 commit 576fe63

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

app/components/InstrumentData.tsx

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,15 +33,14 @@ import TopBar from "@/app/components/TopBar";
3333
import CheckToggle from "@/app/components/CheckToggle";
3434
import Groups from "@/app/components/Groups";
3535

36-
let lastUpdate: string = "";
37-
3836
export function InstrumentData({ instrumentName }: { instrumentName: string }) {
3937
const [showHiddenBlocks, setShowHiddenBlocks] = useState(false);
4038
const CONFIG_DETAILS = "CS:BLOCKSERVER:WD_CONF_DETAILS";
4139
const [instlist, setInstlist] = useState<instList | null>(null);
4240
const [currentInstrument, setCurrentInstrument] = useState<Instrument | null>(
4341
null,
4442
);
43+
const [lastUpdate, setLastUpdate] = useState<string>("");
4544

4645
const instName = instrumentName;
4746

@@ -119,7 +118,7 @@ export function InstrumentData({ instrumentName }: { instrumentName: string }) {
119118
// config hasnt actually changed so do nothing
120119
return;
121120
}
122-
lastUpdate = updatedPVbytes;
121+
setLastUpdate(updatedPVbytes);
123122
const res = dehex_and_decompress(atob(updatedPVbytes));
124123
currentInstrument.groups = getGroupsWithBlocksFromConfigOutput(
125124
JSON.parse(res),
@@ -183,7 +182,7 @@ export function InstrumentData({ instrumentName }: { instrumentName: string }) {
183182
}
184183
}
185184
}
186-
}, [lastJsonMessage, currentInstrument, sendJsonMessage]);
185+
}, [lastJsonMessage, currentInstrument, sendJsonMessage, lastUpdate]);
187186

188187
if (!instName || !currentInstrument) {
189188
return <h1>Loading...</h1>;

0 commit comments

Comments
 (0)