({
theme,
row,
editStream,
deleteStream,
handleWatchStream,
createChannelFromStream,
table,
})
| 70 | import useStreamsTableStore from '../../store/streamsTable'; |
| 71 | |
| 72 | const StreamRowActions = ({ |
| 73 | theme, |
| 74 | row, |
| 75 | editStream, |
| 76 | deleteStream, |
| 77 | handleWatchStream, |
| 78 | createChannelFromStream, |
| 79 | table, |
| 80 | }) => { |
| 81 | const tableSize = table?.tableSize ?? 'default'; |
| 82 | const expandedChannelId = useChannelsTableStore((s) => s.expandedChannelId); |
| 83 | const selectedChannelIds = useChannelsTableStore((s) => s.selectedChannelIds); |
| 84 | const targetChannelId = |
| 85 | expandedChannelId || |
| 86 | (selectedChannelIds.length === 1 ? selectedChannelIds[0] : null); |
| 87 | const channelSelectionStreams = useChannelsTableStore( |
| 88 | (state) => |
| 89 | state.channels.find((chan) => chan.id === targetChannelId)?.streams |
| 90 | ); |
| 91 | |
| 92 | const addStreamToChannel = async () => { |
| 93 | await API.addStreamsToChannel(targetChannelId, channelSelectionStreams, [ |
| 94 | row.original, |
| 95 | ]); |
| 96 | }; |
| 97 | |
| 98 | const onEdit = useCallback(() => { |
| 99 | editStream(row.original); |
| 100 | }, [row.original, editStream]); |
| 101 | |
| 102 | const onDelete = useCallback(() => { |
| 103 | deleteStream(row.original.id); |
| 104 | }, [row.original.id, deleteStream]); |
| 105 | |
| 106 | const onPreview = useCallback(() => { |
| 107 | console.log( |
| 108 | 'Previewing stream:', |
| 109 | row.original.name, |
| 110 | 'ID:', |
| 111 | row.original.id, |
| 112 | 'Hash:', |
| 113 | row.original.stream_hash |
| 114 | ); |
| 115 | handleWatchStream(row.original.stream_hash, row.original.name); |
| 116 | }, [row.original, handleWatchStream]); // Add proper dependencies to ensure correct stream |
| 117 | |
| 118 | const iconSize = |
| 119 | tableSize == 'default' ? 'sm' : tableSize == 'compact' ? 'xs' : 'md'; |
| 120 | |
| 121 | return ( |
| 122 | <> |
| 123 | <Tooltip label="Add to Channel" openDelay={500}> |
| 124 | <ActionIcon |
| 125 | size={iconSize} |
| 126 | color={theme.tailwind.blue[6]} |
| 127 | variant="transparent" |
| 128 | onClick={addStreamToChannel} |
| 129 | style={{ background: 'none' }} |
nothing calls this directly
no test coverage detected