Commit e6aa65e7 authored by tom's avatar tom

add block to the list only if type is matching

parent 9a432009
......@@ -32,13 +32,15 @@ const BlocksContent = ({ type }: Props) => {
const handleNewBlockMessage: SocketMessage.NewBlock['handler'] = React.useCallback((payload) => {
queryClient.setQueryData([ QueryKeys.blocks, type ], (prevData: BlocksResponse | undefined) => {
const shouldAddToList = !type || type === payload.block.type;
if (!prevData) {
return {
items: [ payload.block ],
items: shouldAddToList ? [ payload.block ] : [],
next_page_params: null,
};
}
return { ...prevData, items: [ payload.block, ...prevData.items ] };
return shouldAddToList ? { ...prevData, items: [ payload.block, ...prevData.items ] } : prevData;
});
}, [ queryClient, type ]);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment