From caf1c7d2f6cb687f3c88386599af02e8817fb7ee Mon Sep 17 00:00:00 2001 From: Jaehun You Date: Sun, 1 Dec 2024 08:08:20 +0900 Subject: [PATCH] Remove all measure. when page is unmounted See also: #10 --- wlm-ui/src/MainPage/Channel/Channel.tsx | 5 ++++- wlm-ui/src/store/slices/channel/channel.ts | 4 ++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/wlm-ui/src/MainPage/Channel/Channel.tsx b/wlm-ui/src/MainPage/Channel/Channel.tsx index c17cb8d..7089226 100644 --- a/wlm-ui/src/MainPage/Channel/Channel.tsx +++ b/wlm-ui/src/MainPage/Channel/Channel.tsx @@ -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(() => { diff --git a/wlm-ui/src/store/slices/channel/channel.ts b/wlm-ui/src/store/slices/channel/channel.ts index 662bef6..73b4862 100644 --- a/wlm-ui/src/store/slices/channel/channel.ts +++ b/wlm-ui/src/store/slices/channel/channel.ts @@ -108,6 +108,10 @@ export const channelListSlice = createSlice({ info.measurements = info.measurements.filter( measurement => new Date(measurement.measuredAt) > cutoffTime); }, + removeAllMeasurements: (state, action: PayloadAction>) => { + const info = getChannelInfoWithException(state, action.payload.channel); + info.measurements = []; + }, }, extraReducers: (builder) => { builder