Skip to content

Commit

Permalink
Merge branch 'main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
nikomatt69 authored Nov 14, 2023
2 parents 571be49 + 71be76d commit 37d8f9d
Show file tree
Hide file tree
Showing 112 changed files with 1,571 additions and 1,277 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/cron-downgradeProfiles.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@ jobs:
run: |
curl -X DELETE \
-d '{"secret": "'"$WORKER_SECRET"'"}' \
https://pro.hey.xyz/downgradeProfiles
https://internal.hey.xyz/pro/downgradeProfiles
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
</div>
<br>
<div align="center">
<a href="https://hey.xyz/u/yoginth">
<img src="https://lens-badge.vercel.app/api/badge/yoginth.lens" alt="Lens">
<a href="https://hey.xyz/u/hey">
<img src="https://lens-badge.vercel.app/api/badge/lens/hey" alt="Lens">
</a>
<a href="https://vercel.com/heyxyz?utm_source=Hey&utm_campaign=oss">
<img src="https://therealsujitk-vercel-badge.vercel.app/?app=heyxyz" alt="Vercel">
Expand Down
12 changes: 6 additions & 6 deletions apps/web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
"private": true,
"license": "AGPL-3.0",
"scripts": {
"build:sw": "node script/build-sw.mjs",
"build": "pnpm build:sw; next build",
"build:sw": "node script/build-sw.mjs",
"dev": "next dev --port 4783",
"lint": "eslint . --ext .ts,.tsx",
"lint:fix": "eslint . --fix --ext .ts,.tsx",
Expand All @@ -16,8 +16,8 @@
},
"dependencies": {
"@apollo/client": "^3.8.7",
"@aws-sdk/client-s3": "^3.445.0",
"@aws-sdk/lib-storage": "^3.445.0",
"@aws-sdk/client-s3": "^3.450.0",
"@aws-sdk/lib-storage": "^3.450.0",
"@dnd-kit/core": "^6.1.0",
"@dnd-kit/sortable": "^8.0.0",
"@headlessui/react": "^1.7.17",
Expand Down Expand Up @@ -46,7 +46,7 @@
"dayjs-twitter": "^0.5.0",
"dotenv": "^16.3.1",
"esbuild": "^0.19.5",
"framer-motion": "^10.16.4",
"framer-motion": "^10.16.5",
"graphql": "^16.8.1",
"lexical": "^0.12.2",
"next": "^14.0.2",
Expand All @@ -55,7 +55,7 @@
"plyr-react": "^5.3.0",
"rc-slider": "^10.4.0",
"react": "^18.2.0",
"react-activity-calendar": "^2.1.2",
"react-activity-calendar": "^2.1.8",
"react-cool-inview": "^3.0.1",
"react-device-detect": "^2.2.3",
"react-dom": "^18.2.0",
Expand All @@ -71,7 +71,7 @@
"use-resize-observer": "^9.1.0",
"usehooks-ts": "^2.9.1",
"uuid": "^9.0.1",
"viem": "^1.19.0",
"viem": "^1.19.1",
"wagmi": "^1.4.6",
"zod": "^3.22.4",
"zustand": "^4.4.6"
Expand Down
15 changes: 5 additions & 10 deletions apps/web/src/components/Common/Layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import GlobalBanners from '@components/Shared/GlobalBanners';
import BottomNavigation from '@components/Shared/Navbar/BottomNavigation';
import type { Profile } from '@hey/lens';
import { useCurrentProfileQuery } from '@hey/lens';
import getCurrentSessionProfileId from '@lib/getCurrentSessionProfileId';
import getCurrentSession from '@lib/getCurrentSession';
import getToastOptions from '@lib/getToastOptions';
import Head from 'next/head';
import { useTheme } from 'next-themes';
Expand All @@ -12,7 +12,6 @@ import { Toaster } from 'react-hot-toast';
import { useAppStore } from 'src/store/useAppStore';
import { hydrateAuthTokens, signOut } from 'src/store/useAuthPersistStore';
import { useFeatureFlagsStore } from 'src/store/useFeatureFlagsStore';
import { useNonceStore } from 'src/store/useNonceStore';
import { usePreferencesStore } from 'src/store/usePreferencesStore';
import { useProStore } from 'src/store/useProStore';
import { useEffectOnce, useIsMounted } from 'usehooks-ts';
Expand Down Expand Up @@ -44,15 +43,12 @@ const Layout: FC<LayoutProps> = ({ children }) => {
);
const loadingPro = useProStore((state) => state.loadingPro);
const resetPro = useProStore((state) => state.resetPro);
const setLensHubOnchainSigNonce = useNonceStore(
(state) => state.setLensHubOnchainSigNonce
);

const isMounted = useIsMounted();
const { connector } = useAccount();
const { disconnect } = useDisconnect();

const currentSessionProfileId = getCurrentSessionProfileId();
const { id: sessionProfileId } = getCurrentSession();

const logout = () => {
resetPreferences();
Expand All @@ -63,11 +59,10 @@ const Layout: FC<LayoutProps> = ({ children }) => {
};

const { loading } = useCurrentProfileQuery({
variables: { request: { forProfileId: currentSessionProfileId } },
skip: !currentSessionProfileId || isAddress(currentSessionProfileId),
onCompleted: ({ profile, userSigNonces }) => {
variables: { request: { forProfileId: sessionProfileId } },
skip: !sessionProfileId || isAddress(sessionProfileId),
onCompleted: ({ profile }) => {
setCurrentProfile(profile as Profile);
setLensHubOnchainSigNonce(userSigNonces.lensHubOnchainSigNonce);
}
});

Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import { FEATURES_WORKER_URL } from '@hey/data/constants';
import { FeatureFlag } from '@hey/data/feature-flags';
import getCurrentSessionProfileId from '@lib/getCurrentSessionProfileId';
import getCurrentSession from '@lib/getCurrentSession';
import { useQuery } from '@tanstack/react-query';
import axios from 'axios';
import { type FC } from 'react';
import { useFeatureFlagsStore } from 'src/store/useFeatureFlagsStore';
import { isAddress } from 'viem';

const FeatureFlagsProvider: FC = () => {
const currentSessionProfileId = getCurrentSessionProfileId();
const { id: sessionProfileId } = getCurrentSession();
const setFeatureFlags = useFeatureFlagsStore(
(state) => state.setFeatureFlags
);
Expand All @@ -22,13 +22,10 @@ const FeatureFlagsProvider: FC = () => {

const fetchFeatureFlags = async () => {
try {
if (
Boolean(currentSessionProfileId) &&
!isAddress(currentSessionProfileId)
) {
if (Boolean(sessionProfileId) && !isAddress(sessionProfileId)) {
const response = await axios.get(
`${FEATURES_WORKER_URL}/getFeatureFlags`,
{ params: { id: currentSessionProfileId } }
{ params: { id: sessionProfileId } }
);
const {
data
Expand All @@ -47,7 +44,7 @@ const FeatureFlagsProvider: FC = () => {
};

useQuery({
queryKey: ['fetchFeatureFlags', currentSessionProfileId || ''],
queryKey: ['fetchFeatureFlags', sessionProfileId || ''],
queryFn: fetchFeatureFlags
});

Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import { API_URL } from '@hey/data/constants';
import {
AuthorizationRecordRevokedDocument,
NewNotificationDocument,
AuthorizationRecordRevokedSubscriptionDocument,
NewNotificationSubscriptionDocument,
type Notification,
type UserSigNonces,
UserSigNoncesDocument
UserSigNoncesSubscriptionDocument,
useUserSigNoncesQuery
} from '@hey/lens';
import { BrowserPush } from '@lib/browserPush';
import getCurrentSessionId from '@lib/getCurrentSessionId';
import getCurrentSessionProfileId from '@lib/getCurrentSessionProfileId';
import getCurrentSession from '@lib/getCurrentSession';
import getPushNotificationData from '@lib/getPushNotificationData';
import { type FC } from 'react';
import useWebSocket from 'react-use-websocket';
Expand All @@ -21,14 +21,17 @@ import { isAddress } from 'viem';
import { useAccount } from 'wagmi';

const LensSubscriptionsProvider: FC = () => {
const currentSessionProfileId = getCurrentSessionProfileId();
const setLatestNotificationId = useNotificationPersistStore(
(state) => state.setLatestNotificationId
);
const setLensHubOnchainSigNonce = useNonceStore(
(state) => state.setLensHubOnchainSigNonce
);
const setLensPublicActProxyOnchainSigNonce = useNonceStore(
(state) => state.setLensPublicActProxyOnchainSigNonce
);
const { address } = useAccount();
const { authorizationId, id: sessionProfileId } = getCurrentSession();

const { sendJsonMessage, lastMessage, readyState } = useWebSocket(
API_URL.replace('http', 'ws'),
Expand All @@ -40,38 +43,41 @@ const LensSubscriptionsProvider: FC = () => {
});

useUpdateEffect(() => {
if (readyState === 1 && currentSessionProfileId && address) {
if (!isAddress(currentSessionProfileId)) {
if (readyState === 1 && sessionProfileId && address) {
if (!isAddress(sessionProfileId)) {
sendJsonMessage({
id: '1',
type: 'start',
payload: {
variables: { for: currentSessionProfileId },
query: NewNotificationDocument
variables: { for: sessionProfileId },
query: NewNotificationSubscriptionDocument
}
});
}
sendJsonMessage({
id: '2',
type: 'start',
payload: { variables: { address }, query: UserSigNoncesDocument }
payload: {
variables: { address },
query: UserSigNoncesSubscriptionDocument
}
});
sendJsonMessage({
id: '3',
type: 'start',
payload: {
variables: { authorizationId: getCurrentSessionId() },
query: AuthorizationRecordRevokedDocument
variables: { authorizationId },
query: AuthorizationRecordRevokedSubscriptionDocument
}
});
}
}, [readyState, currentSessionProfileId]);
}, [readyState, sessionProfileId]);

useUpdateEffect(() => {
const jsonData = JSON.parse(lastMessage?.data || '{}');
const wsData = jsonData?.payload?.data;

if (currentSessionProfileId && address && wsData) {
if (sessionProfileId && address && wsData) {
if (jsonData.id === '1') {
const notification = wsData.newNotification as Notification;
if (notification && getPushNotificationData(notification)) {
Expand All @@ -85,6 +91,9 @@ const LensSubscriptionsProvider: FC = () => {
if (jsonData.id === '2') {
const userSigNonces = wsData.userSigNonces as UserSigNonces;
setLensHubOnchainSigNonce(userSigNonces.lensHubOnchainSigNonce);
setLensPublicActProxyOnchainSigNonce(
userSigNonces.lensPublicActProxyOnchainSigNonce
);
}
if (jsonData.id === '3') {
signOut();
Expand All @@ -93,9 +102,20 @@ const LensSubscriptionsProvider: FC = () => {
}
}, [lastMessage]);

useUserSigNoncesQuery({
onCompleted: (data) => {
setLensHubOnchainSigNonce(data.userSigNonces.lensHubOnchainSigNonce);
setLensPublicActProxyOnchainSigNonce(
data.userSigNonces.lensPublicActProxyOnchainSigNonce
);
},
skip: !sessionProfileId
});

// Sync zustand stores between tabs
if (isSupported()) {
share('lensHubOnchainSigNonce', useNonceStore);
share('lensPublicActProxyOnchainSigNonce', useNonceStore);
}

return null;
Expand Down
13 changes: 5 additions & 8 deletions apps/web/src/components/Common/Providers/PreferencesProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import {
FEATURES_WORKER_URL,
PREFERENCES_WORKER_URL
} from '@hey/data/constants';
import getCurrentSessionProfileId from '@lib/getCurrentSessionProfileId';
import getCurrentSession from '@lib/getCurrentSession';
import { useQuery } from '@tanstack/react-query';
import axios from 'axios';
import { type FC } from 'react';
Expand All @@ -11,7 +11,7 @@ import { usePreferencesStore } from 'src/store/usePreferencesStore';
import { isAddress } from 'viem';

const PreferencesProvider: FC = () => {
const currentSessionProfileId = getCurrentSessionProfileId();
const { id: sessionProfileId } = getCurrentSession();
const setVerifiedMembers = useAppStore((state) => state.setVerifiedMembers);
const setIsPride = usePreferencesStore((state) => state.setIsPride);
const setHighSignalNotificationFilter = usePreferencesStore(
Expand All @@ -23,14 +23,11 @@ const PreferencesProvider: FC = () => {

const fetchPreferences = async () => {
try {
if (
Boolean(currentSessionProfileId) &&
!isAddress(currentSessionProfileId)
) {
if (Boolean(sessionProfileId) && !isAddress(sessionProfileId)) {
const response = await axios.get(
`${PREFERENCES_WORKER_URL}/getPreferences`,
{
params: { id: currentSessionProfileId }
params: { id: sessionProfileId }
}
);
const { data } = response;
Expand All @@ -47,7 +44,7 @@ const PreferencesProvider: FC = () => {
};

useQuery({
queryKey: ['fetchPreferences', currentSessionProfileId || ''],
queryKey: ['fetchPreferences', sessionProfileId || ''],
queryFn: fetchPreferences
});

Expand Down
13 changes: 5 additions & 8 deletions apps/web/src/components/Common/Providers/ProProvider.tsx
Original file line number Diff line number Diff line change
@@ -1,24 +1,21 @@
import { PRO_WORKER_URL } from '@hey/data/constants';
import getCurrentSessionProfileId from '@lib/getCurrentSessionProfileId';
import getCurrentSession from '@lib/getCurrentSession';
import { useQuery } from '@tanstack/react-query';
import axios from 'axios';
import { type FC } from 'react';
import { useProStore } from 'src/store/useProStore';
import { isAddress } from 'viem';

const ProProvider: FC = () => {
const currentSessionProfileId = getCurrentSessionProfileId();
const { id: sessionProfileId } = getCurrentSession();
const setIsPro = useProStore((state) => state.setIsPro);
const setLoadingPro = useProStore((state) => state.setLoadingPro);

const fetchProEnabled = async () => {
try {
if (
Boolean(currentSessionProfileId) &&
!isAddress(currentSessionProfileId)
) {
if (Boolean(sessionProfileId) && !isAddress(sessionProfileId)) {
const response = await axios.get(`${PRO_WORKER_URL}/getProEnabled`, {
params: { id: currentSessionProfileId }
params: { id: sessionProfileId }
});
const { data } = response;
setIsPro(data?.enabled || false);
Expand All @@ -30,7 +27,7 @@ const ProProvider: FC = () => {
};

useQuery({
queryKey: ['fetchProEnabled', currentSessionProfileId || ''],
queryKey: ['fetchProEnabled', sessionProfileId || ''],
queryFn: fetchProEnabled
});

Expand Down
4 changes: 2 additions & 2 deletions apps/web/src/components/Composer/Actions/Gif/Gifs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ const Gifs: FC<CategoriesProps> = ({

if (isFetching) {
return (
<div className="grid w-full w-full grid-cols-3 gap-1 overflow-y-auto">
<div className="grid w-full grid-cols-3 gap-1 overflow-y-auto">
{Array.from(Array(12).keys()).map((_, index) => (
<div
key={index}
Expand All @@ -55,7 +55,7 @@ const Gifs: FC<CategoriesProps> = ({
}

return (
<div className="grid w-full w-full grid-cols-3 gap-1 overflow-y-auto">
<div className="grid w-full grid-cols-3 gap-1 overflow-y-auto">
{gifs?.pages.map((page: any) =>
page.data.map((gif: IGif) => (
<button
Expand Down
Loading

0 comments on commit 37d8f9d

Please sign in to comment.