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

Search issue #1270

Merged
merged 5 commits into from
May 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { ChatPreviewSearchList } from '@pushprotocol/uiweb';
import styled from 'styled-components';

const ChatPreviewSearchListTest = () => {
const walletAddress = "0xFA3F8E79fb9B03e7a04295594785b91588Aa4DC8";
return (
<>
<Conatiner>
<ChatPreviewSearchList searchParamter={walletAddress} />
</Conatiner>
</>
);
};

export default ChatPreviewSearchListTest;

const Conatiner = styled.div`
background: '#ffeded',
border: '1px solid rgb(226,8,128)',
height: '28.5vh',
`;
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ const ChatUITest = () => {
CHAT BUBBLE
</Link>
<Link to="/ChatViewList" className="nav-button">
CHAT VIEW LIST
CHAT VIEW LIST
</Link>
<Link to="/ChatView" className="nav-button">
CHAT VIEW
Expand All @@ -44,6 +44,9 @@ const ChatUITest = () => {
<Link to="/ChatPreviewList" className="nav-button">
CHAT PREVIEW LIST
</Link>
<Link to="/ChatPreviewSearchList" className="nav-button">
CHAT PREVIEW SEARCH LIST
</Link>
<Link to="/userProfile" className="nav-button">
USER PROFILE COMPONENT
</Link>
Expand Down
5 changes: 5 additions & 0 deletions packages/examples/sdk-frontend-react/src/app/app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ import { SubscriptionManagerTest } from './widget/SubscriptionManagerTest';
import Widget from './widget/Widget';
// import { SubscriptionManagerTest } from './widget/SubscriptionManagerTest';
import { UserProfileTest } from './ChatUITest/UserProfileTest';
import ChatPreviewSearchListTest from './ChatUITest/ChatPreviewSearchList';

window.Buffer = window.Buffer || Buffer;

Expand Down Expand Up @@ -656,6 +657,10 @@ export function App() {
path="ChatPreview"
element={<ChatPreviewTest />}
/>
<Route
path="ChatPreviewSearchList"
element={<ChatPreviewSearchListTest />}
/>
<Route
path="ChatPreviewList"
element={<ChatPreviewListTest />}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -610,10 +610,9 @@ export const ChatPreviewList: React.FC<IChatPreviewListProps> = (options: IChatP
message: 'Invalid search',
};
}

console.debug(error);
if (!error) {
const chatInfo = await fetchChat({ chatId: formattedChatId });

if (chatInfo && chatInfo?.meta?.group)
groupProfile = await getGroupByIDnew({
groupId: formattedChatId,
Expand All @@ -622,7 +621,6 @@ export const ChatPreviewList: React.FC<IChatPreviewListProps> = (options: IChatP
formattedChatId = pCAIP10ToWallet(
chatInfo?.participants.find((address) => address != walletToPCAIP10(user?.account)) || formattedChatId
);

//fetch profile
if (!groupProfile) {
userProfile = await getNewChatUser({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,8 +156,6 @@ export const ChatViewList: React.FC<IChatViewListProps> = (options: IChatViewLis

return () => clearTimeout(timer);
}

return () => {};
}, [chatAcceptStream, participantJoinStream]);

// Change listtype to 'UINITIALIZED' and hidden to true when participantRemoveStream or participantLeaveStream is received
Expand Down
2 changes: 1 addition & 1 deletion packages/uiweb/src/lib/dataProviders/ChatDataProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ export const ChatUIProvider = ({

console.debug(`UIWeb::ChatDataProvider::user changed - ${new Date().toISOString()}`, user);

if (!user.readmode()) {
if (!user?.readmode()) {
await initStream(user);
}

Expand Down
8 changes: 2 additions & 6 deletions packages/uiweb/src/lib/helpers/chat/search.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,6 @@ export const getNewChatUser = async ({
let chatProfile: IUser | undefined;
let address: string | null = null;
address = await getAddress(searchText, env);
// const provider = new ethers.providers.InfuraProvider();
mishramonalisha76 marked this conversation as resolved.
Show resolved Hide resolved
// address = await provider.resolveName(searchText);
// if (!address) {
// address = await getAddress(searchText, env);
// }
if (address) {
chatProfile = await fetchChatProfile({ profileId: address, env, user });
if (!chatProfile) chatProfile = displayDefaultUser({ caip10: walletToPCAIP10(address) });
Expand All @@ -70,7 +65,8 @@ export const getAddress = async (searchText: string, env: Env) => {
let address: string | null = null;
if (searchText.includes('.')) {
try {
address = await udResolver.owner(searchText);
if (!udResolver) throw new Error('No udResolver available for the network');
address = await udResolver?.owner(searchText);
} catch (err) {
try {
address = await provider.resolveName(searchText);
Expand Down
38 changes: 21 additions & 17 deletions packages/uiweb/src/lib/helpers/udResolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,27 @@ import Resolution from '@unstoppabledomains/resolution';
import { ethers } from 'ethers';
import { allowedNetworks, InfuraAPIKey, NETWORK_DETAILS } from '../config';

export const getUdResolver = (env:Env): Resolution => {
const l1ChainId = allowedNetworks[env].includes(1) ? 1 : 5;
const l2ChainId = allowedNetworks[env].includes(137) ? 137 : 80002;
// ToDo: Enable for sepolia chainId once UD supports it
// const l1ChainId = appConfig.allowedNetworks.includes(1) ? 1 : 11155111;
return Resolution.fromEthersProvider({
uns: {
locations: {
Layer1: {
network: "mainnet", // add config for sepolia once it's supported by UD
provider: new ethers.providers.InfuraProvider(l1ChainId, InfuraAPIKey),
},
Layer2: {
network: NETWORK_DETAILS[l2ChainId].network,
provider: new ethers.providers.InfuraProvider(l2ChainId, InfuraAPIKey),
export const getUdResolver = (env: Env): Resolution => {
try {
const l1ChainId = allowedNetworks[env].includes(1) ? 1 : 5;
const l2ChainId = allowedNetworks[env].includes(137) ? 137 : 80002;
Comment on lines +8 to +9
Copy link
Collaborator

Choose a reason for hiding this comment

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

General Question?:

What's 1,5,137, 80002?

For now is it possible to have string values instead of these?

If no can we atleast store them into const which will help us giving them proper names and reuse across files.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

keeping it numbers because ud doesnot have follow the constants defined, these are specifically used for ud not reused anywhere @rohitmalhotra1420

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Everywhere else in the sdk we use a constant for determining chain-id but for ud its kind of an exception, as it doesnot support the test l1 and l1 chains

Copy link
Collaborator

Choose a reason for hiding this comment

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

What do you think about using these like:

const NUM1 = 1; // or const UD1 = 1 and similar approach for all others.

Copy link
Collaborator

Choose a reason for hiding this comment

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

@mishramonalisha76 and this one as well

// ToDo: Enable for sepolia chainId once UD supports it
// const l1ChainId = appConfig.allowedNetworks.includes(1) ? 1 : 11155111;
return Resolution.fromEthersProvider({
uns: {
locations: {
Layer1: {
network: 'mainnet', // add config for sepolia once it's supported by UD
provider: new ethers.providers.InfuraProvider(l1ChainId, InfuraAPIKey),
},
Layer2: {
network: NETWORK_DETAILS[l2ChainId].network,
provider: new ethers.providers.InfuraProvider(l2ChainId, InfuraAPIKey),
},
},
},
},
});
});
} catch (e) {
console.debug(`Errored:UIWeb::helpers::getUdResolver::UD doesnot provide support for the network`);
}
};
Loading