Skip to content

Commit ba3f42d

Browse files
committed
chore: Move logic to logic file
1 parent 6232f8c commit ba3f42d

File tree

2 files changed

+14
-11
lines changed

2 files changed

+14
-11
lines changed

frontend/src/scenes/notebooks/Nodes/NotebookNodePlaylist.tsx

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import {
1717
} from 'scenes/session-recordings/playlist/sessionRecordingsPlaylistLogic'
1818
import { urls } from 'scenes/urls'
1919

20-
import { AnyPropertyFilter, FilterType, RecordingUniversalFilters, ReplayTabs } from '~/types'
20+
import { FilterType, RecordingUniversalFilters, ReplayTabs } from '~/types'
2121

2222
import { notebookLogic } from '../Notebook/notebookLogic'
2323
import { NotebookNodeAttributeProperties, NotebookNodeProps, NotebookNodeType } from '../types'
@@ -29,14 +29,13 @@ const Component = ({
2929
}: NotebookNodeProps<NotebookNodePlaylistAttributes>): JSX.Element => {
3030
const { pinned, nodeId, universalFilters } = attributes
3131
const playerKey = `notebook-${nodeId}`
32-
const { canvasFiltersOverride } = useValues(notebookLogic)
33-
const personUUID = getPersonUUIDFromOverride(canvasFiltersOverride)
32+
const { personUUIDFromCanvasOverride } = useValues(notebookLogic)
3433

3534
const recordingPlaylistLogicProps: SessionRecordingPlaylistLogicProps = useMemo(
3635
() => ({
3736
logicKey: playerKey,
3837
filters: universalFilters,
39-
...(personUUID ? { personUUID } : {}),
38+
...(personUUIDFromCanvasOverride ? { personUUID: personUUIDFromCanvasOverride } : {}),
4039
updateSearchParams: false,
4140
autoPlay: false,
4241
onFiltersChange: (newFilters) => updateAttributes({ universalFilters: newFilters }),
@@ -168,10 +167,3 @@ export function buildPlaylistContent(filters: Partial<FilterType>): JSONContent
168167
attrs: { filters },
169168
}
170169
}
171-
172-
function getPersonUUIDFromOverride(override: AnyPropertyFilter[] | null): string | null {
173-
if (!override || override.length === 0) {
174-
return null
175-
}
176-
return override.find((filter) => filter.key === 'person_id')?.value as string
177-
}

frontend/src/scenes/notebooks/Notebook/notebookLogic.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -503,6 +503,17 @@ export const notebookLogic = kea<notebookLogicType>([
503503
return insightNodes?.map((node) => node?.attrs?.query?.shortId)
504504
},
505505
],
506+
507+
personUUIDFromCanvasOverride: [
508+
() => [(_, props) => props],
509+
(props: NotebookLogicProps): string | null => {
510+
if (!props.canvasFiltersOverride || props.canvasFiltersOverride.length === 0) {
511+
return null
512+
}
513+
return props.canvasFiltersOverride.find((filter: AnyPropertyFilter) => filter.key === 'person_id')
514+
?.value as string
515+
},
516+
],
506517
}),
507518
listeners(({ values, actions, cache }) => ({
508519
insertAfterLastNode: async ({ content }) => {

0 commit comments

Comments
 (0)