Skip to content

Commit

Permalink
Fix date picker changes not triggering chats reload
Browse files Browse the repository at this point in the history
  • Loading branch information
crespocarlos committed Dec 10, 2024
1 parent 5e46e0a commit 18c0e3e
Showing 1 changed file with 26 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,11 @@ export const useUnifiedSearch = () => {

const {
data: {
query: { filterManager: filterManagerService, queryString: queryStringService },
query: {
filterManager: filterManagerService,
queryString: queryStringService,
timefilter: timeFilterService,
},
},
telemetry,
} = services;
Expand Down Expand Up @@ -95,8 +99,9 @@ export const useUnifiedSearch = () => {
const onDateRangeChange = useCallback(
(dateRange: StringDateRange) => {
setSearch({ type: 'SET_DATE_RANGE', dateRange });
updateSearchSessionId();
},
[setSearch]
[setSearch, updateSearchSessionId]
);

const onQueryChange = useCallback(
Expand All @@ -115,9 +120,8 @@ export const useUnifiedSearch = () => {
const onSubmit = useCallback(
({ dateRange }: { dateRange: TimeRange }) => {
onDateRangeChange(dateRange);
updateSearchSessionId();
},
[onDateRangeChange, updateSearchSessionId]
[onDateRangeChange]
);

const parsedDateRange = useMemo(() => {
Expand Down Expand Up @@ -182,6 +186,16 @@ export const useUnifiedSearch = () => {
.subscribe()
);

subscription.add(
timeFilterService.timefilter
.getTimeUpdate$()
.pipe(
map(() => timeFilterService.timefilter.getTime()),
tap((dateRange) => onDateRangeChange(dateRange))
)
.subscribe()
);

subscription.add(
queryStringService
.getUpdates$()
Expand All @@ -195,7 +209,14 @@ export const useUnifiedSearch = () => {
return () => {
subscription.unsubscribe();
};
}, [filterManagerService, queryStringService, onQueryChange, onFiltersChange]);
}, [
filterManagerService,
queryStringService,
onQueryChange,
onFiltersChange,
timeFilterService.timefilter,
onDateRangeChange,
]);

// Track telemetry event on query/filter/date changes
useEffect(() => {
Expand Down

0 comments on commit 18c0e3e

Please sign in to comment.