Skip to content

Commit

Permalink
fine-tune for preventing cache in picam visual #1
Browse files Browse the repository at this point in the history
  • Loading branch information
hcwinsemius committed Jan 15, 2025
1 parent f59b6ba commit b4f34bc
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions dashboard/src/views/cameraAim.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,17 +37,20 @@ const CameraAim = () => {
const handleToggle = async () => {
setIsLoading(true);
const newState = !isToggledOn; // Determine new state
setIsToggledOn(newState); // Update toggle state
try {
if (newState) {
// Call endpoint for "enabled" state
await api.post('/pivideo/start');
console.log("PiCamera enabled.");
const feedUrl = `${api.defaults.baseURL}/pivideo/stream`;
// re-create a unique url to prevent the browser thinks it can use a cached version
const feedUrl = `${api.defaults.baseURL}/pivideo/stream?${new Date().getTime()}`;
setVideoFeedUrl(feedUrl);
setIsToggledOn(true);
} else {
// Call endpoint for "disabled" state
await api.post('/pivideo/stop');
setVideoFeedUrl("");
setIsToggledOn(false);
console.log("PiCamera disabled.");
}
} catch (error) {
Expand Down

0 comments on commit b4f34bc

Please sign in to comment.