Skip to content

Commit

Permalink
fixed review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
mishramonalisha76 committed Nov 7, 2024
1 parent ef4a287 commit f256b8e
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 34 deletions.
54 changes: 27 additions & 27 deletions src/common/components/InAppChatNotifications.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,33 @@ type InAppChatNotificationsProps = {
onClose: () => void;
};

const getContentText = (chatDetail: any) => {
if (chatDetail.message.type === 'Text') return chatDetail.message.content;
if (chatDetail.message.type === 'Image') return 'Image';
if (chatDetail.message.type === 'File') return 'File';
if (chatDetail.message.type === 'MediaEmbed' || chatDetail.message.type === 'GIF') return 'GIF';
};
const getContentImage = (chatDetail: any) => {
if (
chatDetail.message.type === 'Image' ||
chatDetail.message.type === 'MediaEmbed' ||
chatDetail.message.type === 'GIF'
)
return (
<Image
size={16}
color="icon-tertiary"
/>
);
if (chatDetail.message.type === 'File')
return (
<Pin
size={16}
color="icon-tertiary"
/>
);
};

const InAppChatNotifications: FC<InAppChatNotificationsProps> = ({ chatDetails, onClose }) => {
const { web3NameList }: AppContextType = useContext(AppContext)!;
const fromAddress = caip10ToWallet(chatDetails[0]?.from);
Expand All @@ -45,33 +72,6 @@ const InAppChatNotifications: FC<InAppChatNotificationsProps> = ({ chatDetails,

const latestTimestamp = convertTimeStamp(chatDetails[chatDetails.length - 1]?.timestamp);

const getContentText = (chatDetail: any) => {
if (chatDetail.message.type === 'Text') return chatDetail.message.content;
if (chatDetail.message.type === 'Image') return 'Image';
if (chatDetail.message.type === 'File') return 'File';
if (chatDetail.message.type === 'MediaEmbed' || chatDetail.message.type === 'GIF') return 'GIF';
};
const getContentImage = (chatDetail: any) => {
if (
chatDetail.message.type === 'Image' ||
chatDetail.message.type === 'MediaEmbed' ||
chatDetail.message.type === 'GIF'
)
return (
<Image
size={16}
color="icon-tertiary"
/>
);
if (chatDetail.message.type === 'File')
return (
<Pin
size={16}
color="icon-tertiary"
/>
);
};

//optimise it and fix the close button z-index
return (
<Box
Expand Down
6 changes: 3 additions & 3 deletions src/queries/hooks/chat/useGetGroupInfo.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { useQuery, UseQueryOptions } from '@tanstack/react-query';
import { useSelector } from 'react-redux';

import { userProfileDetails } from '../../queryKeys';
import { groupInfo } from '../../queryKeys';
import { getGroupInfo } from '../../services';

import { UserStoreType } from 'types';
Expand All @@ -17,9 +17,9 @@ export const useGetGroupInfo = (chatId?: string, config?: Partial<UseQueryOption
});

const query = useQuery<GroupInfoResponse>({
queryKey: [userProfileDetails, userPushSDKInstance?.account, chatId || ''],
queryKey: [groupInfo, userPushSDKInstance?.account, chatId],
enabled: !!chatId,
queryFn: () => getGroupInfo(userPushSDKInstance, chatId || ''),
queryFn: () => getGroupInfo(userPushSDKInstance, chatId!),
...config,
});
return query;
Expand Down
2 changes: 1 addition & 1 deletion src/queries/hooks/user/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ export * from './useGetUserSubscriptions';
export * from './useSubscribeChannel';
export * from './useUnsubscribeChannel';
export * from './useUpdateNotificationSettings';
export * from './useGetProfileDetails';
export * from './useGetUserProfileDetails';
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,9 @@ export const useGetUserProfileDetails = (
});

const query = useQuery<UserProfileDetailsResponse>({
queryKey: [userProfileDetails, userPushSDKInstance?.account, userAddress || null],
queryFn: () => getUserProfileDetails(userPushSDKInstance, userAddress),
queryKey: [userProfileDetails, userPushSDKInstance?.account, userAddress],
enabled: !!userAddress,
queryFn: () => getUserProfileDetails(userPushSDKInstance, userAddress!),
...config,
});
return query;
Expand Down
1 change: 1 addition & 0 deletions src/queries/queryKeys.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ export const creatingNewChannel = 'creatingNewChannel';
export const deactivatingChannel = 'deactivatingChannel';
export const discordDetails = 'discordDetails';
export const generateUserIdByWallet = 'generateUserIdByWallet';
export const groupInfo = 'groupInfo';
export const initiateNewChain = 'initiateNewChain';
export const pointsVaultApprovedUsers = 'pointsVaultApprovedUsers';
export const pointsVaultPendingUsers = 'pointsVaultPendingUsers';
Expand Down
2 changes: 1 addition & 1 deletion src/queries/services/user/getUserProfileDetails.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { PushAPI } from '@pushprotocol/restapi';
import { getUserProfileDetailsModelCreator } from 'queries/models';

export const getUserProfileDetails = (userPushSDKInstance: PushAPI, address?: string) =>
export const getUserProfileDetails = (userPushSDKInstance: PushAPI, address: string) =>
userPushSDKInstance.profile.info({ overrideAccount: address }).then(getUserProfileDetailsModelCreator);

0 comments on commit f256b8e

Please sign in to comment.