Skip to content

Commit

Permalink
Remove all measure. when page is unmounted
Browse files Browse the repository at this point in the history
See also: #10
  • Loading branch information
BECATRUE committed Dec 4, 2024
1 parent fa6bafd commit caf1c7d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
5 changes: 4 additions & 1 deletion wlm-ui/src/MainPage/Channel/Channel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,10 @@ const Channel = (props: IProps) => {
dispatch(channelListActions.removeOldMeasurements({ channel: channel }));
}, 10 * 60 * 1000);

return () => clearInterval(interval);
return () => {
clearInterval(interval);
dispatch(channelListActions.removeAllMeasurements({ channel: channel }));
};
}, [dispatch, props.channel.channel]);

useEffect(() => {
Expand Down
4 changes: 4 additions & 0 deletions wlm-ui/src/store/slices/channel/channel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,10 @@ export const channelListSlice = createSlice({
info.measurements = info.measurements.filter(
measurement => new Date(measurement.measuredAt) > cutoffTime);
},
removeAllMeasurements: (state, action: PayloadAction<Pick<ChannelType, 'channel'>>) => {
const info = getChannelInfoWithException(state, action.payload.channel);
info.measurements = [];
},
},
extraReducers: (builder) => {
builder
Expand Down

0 comments on commit caf1c7d

Please sign in to comment.