Skip to content

Commit

Permalink
turn on focus mode (#531)
Browse files Browse the repository at this point in the history
  • Loading branch information
hellno authored Oct 22, 2024
1 parent 520b2e4 commit 38ce344
Show file tree
Hide file tree
Showing 9 changed files with 99 additions and 117 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ GRANT

👋 **Welcome, new contributors!**

Whether you're a seasoned developer or just getting started, your contributions are valuable to us. Don't hesitate to jump in, explore the project, and make an impact. To start contributing, please check out our [Contribution Guidelines](CONTRIBUTING.md).
Whether you're a seasoned developer or just getting started, your contributions are valuable to us. Don't hesitate to jump in, explore the project, and make an impact. To start contributing, please check out our [Contribution Guidelines](CONTRIBUTING.md).

## License

Expand Down
3 changes: 1 addition & 2 deletions next.config.mjs
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
/** @type {import('next').NextConfig} */
import { withSentryConfig } from '@sentry/nextjs';
import path from 'path'; // Ensure you import path
import path from 'path'; // Ensure you import path
import { fileURLToPath } from 'url';

// Get the directory path of the current module
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
const nextConfig = {

webpack: (config) => {
config.resolve.alias = {
...config.resolve.alias,
Expand Down
34 changes: 18 additions & 16 deletions src/common/components/CastRow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ import { addToClipboard } from '../helpers/clipboard';
import { Badge } from '@/components/ui/badge';
import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from '@/components/ui/tooltip';
import { getProfile } from '../helpers/profileUtils';
import { Avatar, AvatarFallback, AvatarImage } from '@/components/ui/avatar';

registerPlugin('mention', mentionPlugin);
registerPlugin('cashtag', cashtagPlugin);
Expand Down Expand Up @@ -517,7 +518,9 @@ export const CastRow = ({
recaster = cast.reactions?.recasts?.find((recast) => recast?.viewer_context?.following === true);
}
const badge = (
<span className={cn('ml-9', 'h-5 inline-flex truncate text-sm font-semibold text-foreground/40 hover:underline')}>
<span
className={cn('ml-10', 'h-5 inline-flex truncate text-sm font-semibold text-foreground/40 hover:underline')}
>
<ArrowPathIcon className="h-4 w-4 mt-0.5 mr-1" />
{recaster && `Recasted by ${recaster.fname || recaster.username}`}
</span>
Expand All @@ -535,7 +538,8 @@ export const CastRow = ({
};

const channel = showChannel && 'parent_url' in cast ? getChannelForParentUrl(cast.parent_url) : null;
const pfpUrl = cast.author.pfp_url || cast.author?.pfp?.url;
const pfpUrl = cast.author.pfp_url || cast.author?.pfp?.url || cast.author?.avatar_url;
const username = cast.author.username || cast.author.fname;
const displayName = cast.author.display_name || cast.author.displayName;

const renderChannelButton = () =>
Expand Down Expand Up @@ -690,31 +694,29 @@ export const CastRow = ({
}}
>
{!isEmbed && !hideAuthor && (
<Link href={`/profile/${cast.author.username}`} prefetch={false} className="flex shrink-0">
<img
className="relative h-10 w-10 flex-none bg-background rounded-full"
src={`https://res.cloudinary.com/merkle-manufactory/image/fetch/c_fill,f_png,w_144/${pfpUrl}`}
/>
<Link href={`/profile/${username}`} prefetch={false} className="flex shrink-0">
<Avatar className="relative h-10 w-10 mr-1">
<AvatarImage src={pfpUrl} />
<AvatarFallback>{username?.slice(0, 2)}</AvatarFallback>
</Avatar>
</Link>
)}
<div className="flex flex-col w-full space-y-1">
<div className="flex flex-row flex-wrap justify-between gap-x-4 leading-5">
<div className="flex flex-row">
{hideAuthor ? (
<span className="text-sm leading-5 text-foreground/50">@{cast.author.username}</span>
<span className="text-sm leading-5 text-foreground/50">@{username}</span>
) : (
<MemoizedProfileHoverCard fid={cast.author.fid} viewerFid={userFid} username={cast.author.username}>
<MemoizedProfileHoverCard fid={cast.author.fid} viewerFid={userFid} username={username}>
<span className="items-center flex font-semibold text-foreground truncate cursor-pointer w-full max-w-54 lg:max-w-full">
{isEmbed && (
<img
className="relative h-4 w-4 mr-1 flex-none bg-background rounded-full"
src={`https://res.cloudinary.com/merkle-manufactory/image/fetch/c_fill,f_png,w_144/${pfpUrl}`}
/>
<Avatar className="relative h-4 w-4 mr-1">
<AvatarImage src={pfpUrl} />
<AvatarFallback>{cast.author.username?.slice(0, 2)}</AvatarFallback>
</Avatar>
)}
{displayName}
<span className="hidden text-muted-foreground font-normal lg:ml-1 lg:block">
@{cast.author.username}
</span>
<span className="hidden text-muted-foreground font-normal lg:ml-1 lg:block">@{username}</span>
<span>
{cast.author.power_badge && (
<img
Expand Down
4 changes: 1 addition & 3 deletions src/common/components/ProfileInfoContent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,7 @@ const ProfileInfoContent: React.FC<ProfileInfoContentProps> = ({
<div className="flex flex-row justify-between">
<div className="flex space-x-2">
<Avatar className="sm:h-8 sm:w-8 md:h-10 md:w-10">
<AvatarImage
src={`https://res.cloudinary.com/merkle-manufactory/image/fetch/c_fill,f_png,w_144/${profile.pfp_url}`}
/>
<AvatarImage src={profile.pfp_url} />
<AvatarFallback>{profile.username?.slice(0, 2)}</AvatarFallback>
</Avatar>
<div>
Expand Down
5 changes: 3 additions & 2 deletions src/common/components/RecommendedProfilesCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,14 @@ const defaultProfiles: User[] = [
},
display_name: 'hellno the optimist',
pfp_url:
'https://res.cloudinary.com/merkle-manufactory/image/fetch/c_fill,f_png,w_144/https://i.imgur.com/u5kUjiN.png',
'https://wrpcd.net/cdn-cgi/image/anim=false,fit=contain,f=auto,w=288/https%3A%2F%2Fi.imgur.com%2FqoHFjQD.gif',
},
{
username: 'herocast',
fid: 18665,
display_name: 'herocast',
pfp_url: 'https://i.imgur.com/Ai9jiC3.jpg',
pfp_url:
'https://wrpcd.net/cdn-cgi/imagedelivery/BXluQx4ige9GuW0Ia56BHw/6958dc09-d654-4192-35f6-3e5816246700/anim=false,fit=contain,f=auto,w=336',
profile: {
bio: {
text: 'you are using herocast right now 👋🏻',
Expand Down
25 changes: 1 addition & 24 deletions src/common/components/Sidebar/PublishedCastsRightSidebar.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import React, { useEffect, useState } from 'react';
import { SidebarHeader } from './SidebarHeader';
import { CastRow } from '../CastRow';
import { NeynarAPIClient } from '@neynar/nodejs-sdk';
import { useAccountStore } from '@/stores/useAccountStore';
import { CastWithInteractions } from '@neynar/nodejs-sdk/build/neynar-api/v1';
import { useDraftStore } from '@/stores/useDraftStore';
Expand Down Expand Up @@ -37,13 +36,11 @@ const convertDraftToFakeCast = (

const PublishedCastsRightSidebar = () => {
const { drafts } = useDraftStore();
const [casts, setCasts] = useState<CastWithInteractions[]>([]);
const selectedAccount = useAccountStore((state) => state.accounts[state.selectedAccountIdx]);
const selectedAccountFid = selectedAccount?.platformAccountId;
const [profile, setProfile] = useState<UserProfile | null>(null);

useEffect(() => {
console.log('getProfileFetchIfNeeded()');
const fetchProfile = async () => {
const res = await getProfileFetchIfNeeded({
fid: selectedAccountFid,
Expand All @@ -57,33 +54,13 @@ const PublishedCastsRightSidebar = () => {
}
}, [profile, selectedAccountFid]);

useEffect(() => {
const fetchCasts = async () => {
const neynarClient = new NeynarAPIClient(process.env.NEXT_PUBLIC_NEYNAR_API_KEY!);

const res = await neynarClient.fetchAllCastsCreatedByUser(Number(selectedAccountFid), {
limit: 5,
viewerFid: Number(selectedAccountFid),
});
setCasts(res.result.casts);
};

if (selectedAccountFid) {
fetchCasts();
}
}, [selectedAccountFid, drafts.length]);

const publishedDraftsAsFakeCasts = profile
? drafts
.filter((draft) => draft.accountId === selectedAccount.id && draft.status === 'published' && draft.hash)
.map((draft) => convertDraftToFakeCast(draft, profile))
: [];

const filteredCasts = filter(
[...casts, ...publishedDraftsAsFakeCasts],
(cast) => cast.timestamp && cast?.author?.fid
);

const filteredCasts = filter(publishedDraftsAsFakeCasts, (cast) => cast.timestamp && cast?.author?.fid);
const castsForSidebar = orderBy(uniqBy(filteredCasts, 'hash'), 'timestamp', 'desc');

return (
Expand Down
134 changes: 67 additions & 67 deletions src/home/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -162,56 +162,56 @@ const Home = ({ children }: { children: React.ReactNode }) => {
{
name: 'main',
items: [
{
name: 'Feeds',
router: '/feeds',
icon: <NewspaperIcon className="h-6 w-6 shrink-0" aria-hidden="true" />,
getTitle: getFeedTitle,
getHeaderActions: () => {
const isChannelPinned = channels.findIndex((channel) => channel.url === selectedChannelUrl) !== -1;
const isChannelFeed =
selectedChannelUrl !== CUSTOM_CHANNELS.FOLLOWING &&
selectedChannelUrl !== CUSTOM_CHANNELS.TRENDING &&
!selectedList;
const actions = [
{
name: 'Cast',
onClick: () => {
let parentUrl;
if (isChannelFeed) {
parentUrl = selectedChannelUrl;
}
setCastModalView(CastModalView.New);
addNewPostDraft({
parentUrl,
onSuccess(draftId) {
setCastModalDraftId(draftId);
openNewCastModal();
},
});
},
},
];
if (isChannelFeed) {
actions.push({
name: isChannelPinned ? 'Unpin' : 'Pin',
onClick: () => {
const channel = channels.find((c) => c.url === selectedChannelUrl);
if (!channel) return;
// {
// name: 'Feeds',
// router: '/feeds',
// icon: <NewspaperIcon className="h-6 w-6 shrink-0" aria-hidden="true" />,
// getTitle: getFeedTitle,
// getHeaderActions: () => {
// const isChannelPinned = channels.findIndex((channel) => channel.url === selectedChannelUrl) !== -1;
// const isChannelFeed =
// selectedChannelUrl !== CUSTOM_CHANNELS.FOLLOWING &&
// selectedChannelUrl !== CUSTOM_CHANNELS.TRENDING &&
// !selectedList;
// const actions = [
// {
// name: 'Cast',
// onClick: () => {
// let parentUrl;
// if (isChannelFeed) {
// parentUrl = selectedChannelUrl;
// }
// setCastModalView(CastModalView.New);
// addNewPostDraft({
// parentUrl,
// onSuccess(draftId) {
// setCastModalDraftId(draftId);
// openNewCastModal();
// },
// });
// },
// },
// ];
// if (isChannelFeed) {
// actions.push({
// name: isChannelPinned ? 'Unpin' : 'Pin',
// onClick: () => {
// const channel = channels.find((c) => c.url === selectedChannelUrl);
// if (!channel) return;

if (isChannelPinned) {
removePinnedChannel(channel);
} else {
addPinnedChannel(channel);
}
},
});
}
return actions;
},
shortcut: 'Shift + F',
additionalPaths: ['/conversation/[...slug]'],
},
// if (isChannelPinned) {
// removePinnedChannel(channel);
// } else {
// addPinnedChannel(channel);
// }
// },
// });
// }
// return actions;
// },
// shortcut: 'Shift + F',
// additionalPaths: ['/conversation/[...slug]'],
// },
{
name: 'Post',
router: '/post',
Expand All @@ -229,18 +229,18 @@ const Home = ({ children }: { children: React.ReactNode }) => {
],
icon: <PencilSquareIcon className="h-6 w-6 shrink-0" aria-hidden="true" />,
},
{
name: 'Search',
router: '/search',
icon: <MagnifyingGlassIcon className="h-6 w-6 shrink-0" aria-hidden="true" />,
shortcut: '/',
},
{
name: 'Notifications',
router: '/notifications',
icon: <BellIcon className="h-6 w-6 shrink-0" aria-hidden="true" />,
shortcut: 'Shift + N',
},
// {
// name: 'Search',
// router: '/search',
// icon: <MagnifyingGlassIcon className="h-6 w-6 shrink-0" aria-hidden="true" />,
// shortcut: '/',
// },
// {
// name: 'Notifications',
// router: '/notifications',
// icon: <BellIcon className="h-6 w-6 shrink-0" aria-hidden="true" />,
// shortcut: 'Shift + N',
// },
{
name: 'Analytics',
router: '/analytics',
Expand All @@ -263,12 +263,12 @@ const Home = ({ children }: { children: React.ReactNode }) => {
router: '/upgrade',
icon: <ArrowUpCircleIcon className="h-6 w-6 shrink-0" aria-hidden="true" />,
},
{
name: 'Channels',
router: '/channels',
icon: <RectangleGroupIcon className="h-6 w-6 shrink-0" aria-hidden="true" />,
shortcut: 'Shift + C',
},
// {
// name: 'Channels',
// router: '/channels',
// icon: <RectangleGroupIcon className="h-6 w-6 shrink-0" aria-hidden="true" />,
// shortcut: 'Shift + C',
// },
{
name: 'Accounts',
router: '/accounts',
Expand Down
2 changes: 1 addition & 1 deletion supabase/functions/_shared/email.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ const CastRow: React.FC<CastRowProps> = ({ cast, searchTerm }) => {
'div',
{ className: 'flex items-center mb-2' },
React.createElement(Img, {
src: `https://res.cloudinary.com/merkle-manufactory/image/fetch/c_fill,f_png,w_144/${pfpUrl}`,
src: pfpUrl,
width: '16',
height: '16',
className: 'rounded-full mr-1',
Expand Down
7 changes: 6 additions & 1 deletion supabase/functions/publish-cast-from-db/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { createClient } from '@supabase/supabase-js';
import { HubRestAPIClient } from 'npm:@standard-crypto/farcaster-js-hub-rest';
import * as Sentry from 'https://deno.land/x/sentry/index.mjs';
import axios from 'npm:axios';

Sentry.init({
dsn: Deno.env.get('SENTRY_DSN'),
Expand Down Expand Up @@ -39,8 +40,12 @@ async function submitMessage({
castAddBody: any;
}): Promise<string> {
castAddBody = convertCastAddBodyFromDbToHub(castAddBody);
const axiosInstance = axios.create({
headers: { api_key: Deno.env.get('NEYNAR_API_KEY') },
});
const writeClient = new HubRestAPIClient({
hubUrl: 'https://hub.pinata.cloud',
hubUrl: 'https://hub-api.neynar.com',
axiosInstance,
});
const publishCastResponse = await writeClient.submitCast(castAddBody, fid, signerPrivateKey);
console.log(`new cast hash: ${publishCastResponse.hash}`);
Expand Down

0 comments on commit 38ce344

Please sign in to comment.