Skip to content

Commit

Permalink
Fixing import and removing flickering
Browse files Browse the repository at this point in the history
  • Loading branch information
jonathan-buttner committed Aug 30, 2022
1 parent 77491ff commit ae3f44b
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,11 @@ export const CaseViewActivity = ({
const userActionProfileUids = Array.from(userActionsData?.profileUids.values() ?? []);
const uidsToRetrieve = uniq([...userActionProfileUids, ...assignees]);

const { data: userProfiles, isLoading: isLoadingUserProfiles } = useBulkGetUserProfiles({
const { data: userProfiles, isFetching: isLoadingUserProfiles } = useBulkGetUserProfiles({
uids: uidsToRetrieve,
});

const { data: currentUserProfile, isLoading: isLoadingCurrentUserProfile } =
const { data: currentUserProfile, isFetching: isLoadingCurrentUserProfile } =
useGetCurrentUserProfile();

const onShowAlertDetails = useCallback(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ const SuggestUsersPopoverComponent: React.FC<SuggestUsersPopoverProps> = ({
[]
);

const { data: userProfiles, isLoading: isLoadingSuggest } = useSuggestUserProfiles({
const { data: userProfiles, isFetching: isLoadingSuggest } = useSuggestUserProfiles({
name: searchTerm,
owners: owner,
});
Expand Down Expand Up @@ -173,7 +173,7 @@ const SuggestUsersPopoverComponent: React.FC<SuggestUsersPopoverProps> = ({
searchPlaceholder: i18n.SEARCH_USERS,
clearButtonLabel: i18n.REMOVE_ASSIGNEES,
emptyMessage: <EmptyMessage />,
noMatchesMessage: <NoMatches />,
noMatchesMessage: searchResultProfiles ? <NoMatches /> : <EmptyMessage />,
}}
/>
);
Expand All @@ -183,7 +183,7 @@ SuggestUsersPopoverComponent.displayName = 'SuggestUsersPopover';

export const SuggestUsersPopover = React.memo(SuggestUsersPopoverComponent);

const sortProfiles = (profiles?: UserProfileWithAvatar[]) => {
const sortProfiles = (profiles?: UserProfileWithAvatar[] | null) => {
if (!profiles) {
return;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@
* 2.0.
*/

import { getUserDisplayName } from '@kbn/security-plugin/common';
import { UserProfileUserInfo } from '@kbn/user-profile-components/target_types/user_profile';
import { getUserDisplayName, UserProfileUserInfo } from '@kbn/user-profile-components';
import { isEmpty } from 'lodash';
import * as i18n from './translations';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,17 @@ export const useSuggestUserProfiles = ({

const toasts = useToasts();

return useQuery<UserProfile[], ServerError>(
return useQuery<UserProfile[] | null, ServerError>(
[
USER_PROFILES_CACHE_KEY,
USER_PROFILES_SUGGEST_CACHE_KEY,
{ name: debouncedName, owners, size },
],
() => {
if (isEmpty(name)) {
return [];
return null;
}

const abortCtrlRef = new AbortController();
return suggestUserProfiles({
http,
Expand All @@ -67,4 +68,4 @@ export const useSuggestUserProfiles = ({
);
};

export type UseSuggestUserProfiles = UseQueryResult<UserProfile[], ServerError>;
export type UseSuggestUserProfiles = UseQueryResult<UserProfile[] | null, ServerError>;

0 comments on commit ae3f44b

Please sign in to comment.