Skip to content

Commit

Permalink
Persist event list search
Browse files Browse the repository at this point in the history
  • Loading branch information
getnashty committed Mar 24, 2022
1 parent 3ce2281 commit 00c2a6d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/modules/EventList/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ export const EventListUI = (props: EventListUIProps): ReactElement => {
} = props;

if (event) {
return <Transcript eventId={event.id} onBack={onBackFromTranscript} />;
return <Transcript eventId={event.id} onBack={onBackFromTranscript} initialSearchTerm={searchTerm} />;
}

const wrapMsg = (msg: string) => <div className="flex flex-1 items-center justify-center text-gray-600">{msg}</div>;
Expand Down
9 changes: 5 additions & 4 deletions src/modules/Transcript/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -736,9 +736,9 @@ function useAudioSync(
];
}

function useSearchState(speakerTurns: SpeakerTurn[]) {
function useSearchState(speakerTurns: SpeakerTurn[], initialSearchTerm = '') {
const { state, handlers } = useChangeHandlers({
searchTerm: '',
searchTerm: initialSearchTerm,
});

// Track the current match id and use it to set the proper currentMatchRef for autoscrolling
Expand Down Expand Up @@ -845,13 +845,14 @@ function useSearchState(speakerTurns: SpeakerTurn[]) {
export interface TranscriptProps {
eventId: string;
onBack?: MouseEventHandler;
initialSearchTerm?: string;
}

/**
* Renders Transcript
*/
export const Transcript = (props: TranscriptProps): ReactElement => {
const { eventId, onBack } = props;
const { eventId, onBack, initialSearchTerm } = props;
const { settings } = useSettings();
const eventUpdateQuery = useEventUpdates(eventId);
const eventQuery = useEventData(eventId, eventUpdateQuery);
Expand All @@ -869,7 +870,7 @@ export const Transcript = (props: TranscriptProps): ReactElement => {
startTime,
endTime,
] = useAudioSync(eventId, speakerTurns, eventQuery, audioPlayer);
const searchState = useSearchState(speakerTurns);
const searchState = useSearchState(speakerTurns, initialSearchTerm);
// We need to set two separate refs to the scroll container, so this just wraps those 2 into 1 to pass to the
// scrollContiainer ref. May make this a helper hook at some point
const scrollContainerRef = useCallback(
Expand Down

0 comments on commit 00c2a6d

Please sign in to comment.