Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixes ui representation for domain resolution #1336

Merged
merged 8 commits into from
Jun 7, 2024
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,6 @@ export const ChatPreviewSearchList: React.FC<IChatPreviewSearchListProps> = (opt
const groupInfo = await getGroupByIDnew({
groupId: derivedChatId,
});

if (groupInfo) {
searchedChat = {
...searchedChat,
Expand All @@ -230,19 +229,21 @@ export const ChatPreviewSearchList: React.FC<IChatPreviewSearchListProps> = (opt
} else {
const userProfile = await user?.info({ overrideAccount: chatInfo.recipient });
console.debug('UIWeb::components::ChatPreviewSearchList::loadMoreChats::userProfile', userProfile);

searchedChat = {
...searchedChat,
chatId: derivedChatId,
chatParticipant: derivedChatId,
chatParticipant: derivedChatId
? formattedChatId.includes('.')
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's put formattedChatId.includes('.') this in a utility function. Something like

const getChatId=(id:string)=> id.includes(".")? id : null

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

okay

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rohitmalhotra1420 added the change

? formattedChatId
: derivedChatId
: derivedChatId,
chatGroup: false,
chatPic: userProfile?.profile?.picture || null,
chatMsg: {
messageType: 'Text',
messageContent: chatInfo?.list === 'CHATS' ? 'Resume Chat!' : 'Start Chat!',
},
};

resolved = true;
}
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,7 @@ export const ChatProfile: React.FC<IChatProfile> = ({
profile.abbrRecipient = getAbbreiatedRecipient(recipient);
profile.desc = profileInfo.profile?.desc;
profile.isGroup = false;
profile.web3Name = chatId.includes('.') ? chatId : null;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mishramonalisha76 I meant using the function everywhere so we don't have to use .includes everywhere and keep this logic in a single function.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

understood

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rohitmalhotra1420 this logic is only in two places , most of the places we have to check if chatID.includes('.') then it doesnot something or something else. Should we just make a function to check if a string includes another substring?

} else {
throw new Error(
'UIWeb::ChatProfile::user.profile.info fetch error, possible push user does not exist.'
Expand All @@ -180,13 +181,14 @@ export const ChatProfile: React.FC<IChatProfile> = ({
profile.icon = null;
profile.chatId = derivedChatId;
profile.recipient = recipient;
profile.web3Name = chatId.includes('.') ? chatId : null;
profile.abbrRecipient = getAbbreiatedRecipient(recipient);
profile.desc = '';
profile.isGroup = false;
}

// get and set web3 name asynchrounously
if (profile.recipient) {
if (profile.recipient && !profile.web3Name) {
setupWeb3Name(profile.recipient);
}
}
Expand Down
2 changes: 0 additions & 2 deletions packages/uiweb/src/lib/components/chat/helpers/helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,6 @@ export const formatAddress = async (chatPreviewPayload: IChatPreviewPayload, env
// check and remove eip155:
if (formattedAddress.includes('eip155:')) {
formattedAddress = formattedAddress.replace('eip155:', '');
} else if (formattedAddress.includes('.')) {
formattedAddress = (await getAddress(formattedAddress, env))!;
}
}

Expand Down
Loading