Skip to content

Commit

Permalink
Merge pull request #160 from us3r-network/u3-dev
Browse files Browse the repository at this point in the history
U3 dev
  • Loading branch information
sin-bufan authored Oct 17, 2023
2 parents 5c61634 + 50bf2c2 commit 5e6d9d5
Show file tree
Hide file tree
Showing 44 changed files with 2,163 additions and 214 deletions.
5 changes: 4 additions & 1 deletion apps/u3/.eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ module.exports = {
rules: {
/** js语法 **/
// 允许使用console
"no-console": "off",
'no-console': 'off',
// 不限制js的语法 (如:不禁止使用for of语法)
'no-restricted-syntax': 'off',
// 允许在for循环中使用一元运算符 ++,-- (其它位置仍给出警告)
Expand All @@ -47,6 +47,9 @@ module.exports = {
'import/prefer-default-export': 'off',

/** typescript **/
'@typescript-eslint/no-explicit-any': 'off',
'@typescript-eslint/no-unused-vars': ['warn', { argsIgnorePattern: '^_' }],
'@typescript-eslint/no-unsafe-enum-comparison': 'off',
//解决 styled 结构顺序问题
'@typescript-eslint/no-use-before-define': 'off',
'@typescript-eslint/no-unsafe-member-access': 'off',
Expand Down
12 changes: 7 additions & 5 deletions apps/u3/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,10 @@
"@reduxjs/toolkit": "^1.8.3",
"@us3r-network/auth-with-rainbowkit": "^0.1.11",
"@us3r-network/link": "0.2.4",
"@us3r-network/profile": "^0.5.7",
"@us3r-network/profile": "0.5.9-alpha.1",
"@xmtp/content-type-remote-attachment": "^1.1.2",
"@xmtp/xmtp-js": "^11.1.1",
"@livepeer/react": "^2.8.8",
"antd": "^5.0.7",
"assert": "^2.0.0",
"axios": "^0.27.2",
Expand All @@ -38,6 +39,7 @@
"marked": "^4.0.18",
"material-ui-popup-state": "^4.0.1",
"node-sass": "^8.0.0",
"plyr-react": "^5.3.0",
"process": "^0.11.10",
"pubsub-js": "^1.9.4",
"qs": "^6.11.0",
Expand Down Expand Up @@ -74,7 +76,7 @@
"swiper": "^8.2.4",
"three": "^0.147.0",
"tslib": "^2.3.0",
"typescript": "^4.9.5",
"typescript": "^5.2.2",
"viem": "^0.3.37",
"wagmi": "^1.0.7",
"web-vitals": "^2.1.4",
Expand Down Expand Up @@ -125,13 +127,13 @@
"@types/react-slick": "^0.23.10",
"@types/styled-components": "^5.1.25",
"@types/three": "^0.146.0",
"@typescript-eslint/eslint-plugin": "~5.44.0",
"@typescript-eslint/parser": "~5.44.0",
"@typescript-eslint/eslint-plugin": "^6.7.2",
"@typescript-eslint/parser": "^6.7.2",
"babel-jest": "27.5.1",
"babel-plugin-styled-components": "1.10.7",
"cross-env": "^7.0.2",
"cypress": "^9.1.0",
"eslint": "~8.15.0",
"eslint": "^8.50.0",
"eslint-config-airbnb": "^19.0.4",
"eslint-config-airbnb-typescript": "^17.0.0",
"eslint-config-prettier": "8.1.0",
Expand Down
Binary file added apps/u3/public/social/imgs/channel-home.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
22 changes: 17 additions & 5 deletions apps/u3/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,12 @@ import { ProfileStateProvider } from '@us3r-network/profile';
import { LinkStateProvider } from '@us3r-network/link';
import { init } from '@airstack/airstack-react';

import {
createReactClient,
LivepeerConfig,
studioProvider,
} from '@livepeer/react';

import dayjs from 'dayjs';
import relativeTime from 'dayjs/plugin/relativeTime';

Expand All @@ -34,6 +40,10 @@ import { AppLensProvider } from './contexts/AppLensCtx';
import { NavProvider } from './contexts/NavCtx';
import FarcasterProvider from './contexts/FarcasterCtx';

const livepeerClient = createReactClient({
provider: studioProvider({ apiKey: '' }),
});

init(AIRSTACK_API_KEY);
dayjs.extend(relativeTime);

Expand All @@ -60,11 +70,13 @@ function App() {
<ReduxProvider store={store}>
<GlobalStyle />
<BrowserRouter>
<AliveScope>
<NavProvider>
<Layout />
</NavProvider>
</AliveScope>
<LivepeerConfig client={livepeerClient}>
<AliveScope>
<NavProvider>
<Layout />
</NavProvider>
</AliveScope>
</LivepeerConfig>
</BrowserRouter>
</ReduxProvider>
</FarcasterProvider>
Expand Down
39 changes: 39 additions & 0 deletions apps/u3/src/api/farcaster.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ export type FarcasterNotification = {
hash?: Buffer;
text?: string;
userData: unknown;
parent_hash?: Buffer;
};

export type FarcasterPageInfo = {
Expand Down Expand Up @@ -235,3 +236,41 @@ export function getFarcasterRecommendedProfile(
},
});
}

export function getFarcasterChannelFeeds({
channelName,
endFarcasterCursor,
pageSize,
}: {
channelName: string;
endFarcasterCursor?: string;
pageSize?: number;
}): AxiosPromise<
ApiResp<{
data: { data: FarCast; platform: 'farcaster' }[];
farcasterUserData: FarcasterUserData[];
pageInfo: FarcasterPageInfo;
}>
> {
return axios({
url: `${REACT_APP_API_SOCIAL_URL}/3r/farcaster/channel`,
method: 'get',
params: {
name: channelName,
endFarcasterCursor,
pageSize,
},
});
}

export function getFarcasterChannelTrends(
limit = 500
): AxiosPromise<ApiResp<{ parent_url: string; count: string }[]>> {
return axios({
url: `${REACT_APP_API_SOCIAL_URL}/3r/farcaster/channel/trends`,
method: 'get',
params: {
limit,
},
});
}
36 changes: 36 additions & 0 deletions apps/u3/src/components/icons/ArrowDown.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
export default function ArrowDown() {
return (
<svg
width="12"
height="12"
viewBox="0 0 12 12"
fill="none"
xmlns="http://www.w3.org/2000/svg"
xmlnsXlink="http://www.w3.org/1999/xlink"
>
<rect
y="12"
width="12"
height="12"
transform="rotate(-90 0 12)"
fill="url(#pattern0)"
/>
<defs>
<pattern
id="pattern0"
patternContentUnits="objectBoundingBox"
width="1"
height="1"
>
<use xlinkHref="#arrow_down" transform="scale(0.0111111)" />
</pattern>
<image
id="arrow_down"
width="90"
height="90"
xlinkHref="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAFoAAABaCAYAAAA4qEECAAAACXBIWXMAAAsTAAALEwEAmpwYAAABNklEQVR4nO3asWoCQRhF4dXCVfC9TRGCrY0PYSG+kVUgJIGUJwzYpUg3v3vnfHWKn8NlYzHTJEmSJEmSpEUBZuAVeAe+gROwq74rMfKVv07Vt40Qufmsvm+EyM1H9Y0jRG7equ8cIfK1/V31rYsFbIDLP5FvwLb61sXCyEaOgEs2cgRcspEj4JKNHAGXbOQIuGQjR8AlGzkCLtnIEXDJRo6ASzZyBFyykSPgkrtEnn3c0if0iy+I+oS++4LI0DmAg5+OPqFn/xl2gj/v+sHYxo6EyzZ2JFy2sSPhso0dCZdt7Ei4bGNHwmUbOxIu29iRcNnGjoTLNnYkXLaxI+Gy+/GRzvPFPva8aeTYX8Cq+s4RYv8A6+obR4h9rr4tNfbx8bloSz4D++q7YgErv8uSJEmSJE3JfgFhVy9RbsoXswAAAABJRU5ErkJggg=="
/>
</defs>
</svg>
);
}
30 changes: 30 additions & 0 deletions apps/u3/src/components/icons/ChannelHome.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
export default function ChannelHome() {
return (
<svg
width="12"
height="12"
viewBox="0 0 12 12"
fill="none"
xmlns="http://www.w3.org/2000/svg"
xmlnsXlink="http://www.w3.org/1999/xlink"
>
<rect width="12" height="12" fill="url(#pattern0_channel_home)" />
<defs>
<pattern
id="pattern0_channel_home"
patternContentUnits="objectBoundingBox"
width="1"
height="1"
>
<use xlinkHref="#channel_home" transform="scale(0.0111111)" />
</pattern>
<image
id="channel_home"
width="90"
height="90"
xlinkHref="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAFoAAABaCAYAAAA4qEECAAAACXBIWXMAAAsTAAALEwEAmpwYAAACW0lEQVR4nO3cu27UQBSH8RMRLTRIWwdEBQV0pOERAg200FFRcSlp6RIegQop8AKh4glIaAgVDRUINiWXSChSEB9ysNASnKx313NmPPP/lSvvxZ8s20ezspmIiIiIjAFOAY+BEbADrFWvjW8jcwKWgC3+9wY4N+/nix1Evgx84GifgSuKNd+RfBP4wWR7wG3FnhJwoj4HT+sJsDjt9xUJOA1sMLuXwDD2fiQNOA+8Y37vgYux9ydJwArwhe58B67H3q+kAHeAfbr3E3hopePPELJOeOuThhtgMDYQHb59rC7MA+vxEPIaP9V3LR3zeybd5axZhkNIKKOjhpuGI/mwHesT4FbLISSUxuGmzRst8yEklH+GmzZvsJ4MIS9Iz9/hps3GljLgQkdDSCgHw02bDS1VwDXgK+lrNShZioAH9cCQDUsJcBJ4SoasByshWbAUAMvARzJmsSUwhLiIGTi1ISSoWJGH9Q1/SYbekVMfQkION5e8Il/teCWkb6qVmxuhI2c3hMzoF/AIWOg6cLX68HzWX5WxZ52uvACrsfcoYatdhq7WzaTZSKF9fOoydDFDSexTx6COrVNIjL8hUBiLhcKYQvtQaCcK7UShnSh0gxAXdoVuoNBOFNqJQjtRaCcK7UShnSi0E4V2otBOFNqJQjtRaCcK7UShnSi0E4V2otBOFNqJQjtRaCcK7UShnSh0j+l/HU4UuoDQu5TjW8zQng8IjG0zZuj7lONu7Mf6vCV/29GfTQqczTz2NnDGUlAf2feq81gmF8hd4FV1uoh+JIuIiIiIiIiIWHp+AyQbWTgpWw5yAAAAAElFTkSuQmCC"
/>
</defs>
</svg>
);
}
10 changes: 7 additions & 3 deletions apps/u3/src/components/notification/NotificationModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,10 @@ export function FarcasterNotificationItem({
onClick={() => {
navigate(
`/social/post-detail/fcast/${Buffer.from(
notification.hash
).toString('hex')}`
notification.parent_hash
).toString('hex')}#${Buffer.from(notification.hash).toString(
'hex'
)}`
);
setOpenNotificationModal(false);
}}
Expand Down Expand Up @@ -235,7 +237,9 @@ function LensNotificationItem({
return (
<NotificationItem
onClick={() => {
navigate(`/social/post-detail/lens/${notification.comment.id}`);
navigate(
`/social/post-detail/lens/${notification?.comment?.commentOn?.id}#${notification?.comment?.id}`
);
setOpenNotificationModal(false);
}}
>
Expand Down
43 changes: 14 additions & 29 deletions apps/u3/src/components/profile/ProfileSocial.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import { useActiveProfile } from '@lens-protocol/react-web';
import InfiniteScroll from 'react-infinite-scroll-component';
import { FeedsType } from './ProfilePageNav';
import { useLoadProfileFeeds } from '../../hooks/useLoadProfileFeeds';
import useFarcasterCurrFid from '../../hooks/farcaster/useFarcasterCurrFid';
import Loading from '../common/loading/Loading';
import LensPostCard from '../social/lens/LensPostCard';
import FCast from '../social/farcaster/FCast';
Expand All @@ -15,21 +14,20 @@ import Rss3Content from '../fren/Rss3Content';
import { NoActivity } from '../../container/Activity';

export default function ProfileSocial({
wallet,
address,
lensProfileId,
fid,
feedsType,
}: {
wallet: string;
address: string;
lensProfileId: string;
fid: string;
feedsType: FeedsType;
}) {
const {
openFarcasterQR,
farcasterUserData,
isConnected: isConnectedFarcaster,
} = useFarcasterCtx();
const { openFarcasterQR, farcasterUserData } = useFarcasterCtx();
const { data: activeLensProfile, loading: activeLensProfileLoading } =
useActiveProfile();

const fid = useFarcasterCurrFid();
const {
firstLoading,
moreLoading,
Expand All @@ -43,35 +41,21 @@ export default function ProfileSocial({
if (feedsType === FeedsType.ACTIVITIES) return;
loadFirstFeeds({
activeLensProfileId: activeLensProfile?.id,
lensProfileId: activeLensProfile?.id,
fid: isConnectedFarcaster ? fid : undefined,
lensProfileId,
fid,
group: feedsType as unknown as ProfileFeedsGroups,
});
}, [
loadFirstFeeds,
activeLensProfile?.id,
fid,
feedsType,
wallet,
isConnectedFarcaster,
]);
}, [loadFirstFeeds, activeLensProfile?.id, fid, feedsType, lensProfileId]);

const loadMoreSocialFeeds = useCallback(() => {
if (feedsType === FeedsType.ACTIVITIES) return;
loadMoreFeeds({
activeLensProfileId: activeLensProfile?.id,
lensProfileId: activeLensProfile?.id,
fid: isConnectedFarcaster ? fid : undefined,
lensProfileId,
fid,
group: feedsType as unknown as ProfileFeedsGroups,
});
}, [
loadMoreFeeds,
activeLensProfile?.id,
fid,
feedsType,
wallet,
isConnectedFarcaster,
]);
}, [loadMoreFeeds, activeLensProfile?.id, fid, feedsType, lensProfileId]);

useEffect(() => {
if (activeLensProfileLoading) return;
Expand All @@ -84,6 +68,7 @@ export default function ProfileSocial({
if (feedsType === FeedsType.ACTIVITIES) {
return (
<Rss3Content
address={[address]}
empty={
<NoActivityWrapper>
<NoActivity />
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { useFarcasterCtx } from 'src/contexts/FarcasterCtx';
import useFarcasterFollowData from 'src/hooks/farcaster/useFarcasterFollowData';
import Loading from 'src/components/common/loading/Loading';

Expand All @@ -10,10 +9,9 @@ import {

import FarcasterFollowProfileCard from './FarcasterFollowProfileCard';

export default function FarcasterFollowers({ fid }: { fid?: string | number }) {
const { currFid } = useFarcasterCtx();
export default function FarcasterFollowers({ fid }: { fid: string | number }) {
const { farcasterFollowData, loading } = useFarcasterFollowData({
fid: fid || currFid,
fid,
});
const followers = farcasterFollowData.followerData;
const following = farcasterFollowData.followingData;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { useFarcasterCtx } from 'src/contexts/FarcasterCtx';
import useFarcasterFollowData from 'src/hooks/farcaster/useFarcasterFollowData';
import Loading from 'src/components/common/loading/Loading';

Expand All @@ -9,13 +8,11 @@ import {
} from '../FollowListWidgets';
import FarcasterFollowProfileCard from './FarcasterFollowProfileCard';

export default function FarcasterFollowing({ fid }: { fid?: string | number }) {
const { currFid } = useFarcasterCtx();
export default function FarcasterFollowing({ fid }: { fid: string | number }) {
const { farcasterFollowData, loading } = useFarcasterFollowData({
fid: fid || currFid,
fid,
});
const following = farcasterFollowData.followingData;
console.log({ following });

if (loading) {
return (
Expand Down
Loading

0 comments on commit 5e6d9d5

Please sign in to comment.