no more default export

This commit is contained in:
Ren Amamiya
2023-05-30 10:33:00 +07:00
parent 763af0da14
commit 8256bc46a7
89 changed files with 154 additions and 325 deletions

View File

@@ -1,9 +1,8 @@
import { Image } from "@shared/image";
import { DEFAULT_AVATAR } from "@stores/constants";
import { useProfile } from "@utils/hooks/useProfile";
export default function ActiveAccount({ data }: { data: any }) {
export function ActiveAccount({ data }: { data: any }) {
const { user } = useProfile(data.pubkey);
return (

View File

@@ -3,7 +3,7 @@ import { Image } from "@shared/image";
import { DEFAULT_AVATAR } from "@stores/constants";
import { useProfile } from "@utils/hooks/useProfile";
export default function InactiveAccount({ data }: { data: any }) {
export function InactiveAccount({ data }: { data: any }) {
const { user } = useProfile(data.npub);
return (

View File

@@ -1,8 +1,7 @@
import { usePageContext } from "@utils/hooks/usePageContext";
import { twMerge } from "tailwind-merge";
export default function ActiveLink({
export function ActiveLink({
href,
className,
activeClassName,

View File

@@ -1,6 +1,5 @@
import ArrowLeftIcon from "@icons/arrowLeft";
import ArrowRightIcon from "@icons/arrowRight";
import EventCollector from "@shared/eventCollector";
import { EventCollector } from "@shared/eventCollector";
import { ArrowLeftIcon, ArrowRightIcon } from "@shared/icons";
export function AppHeader() {
const goBack = () => {

View File

@@ -1,10 +1,8 @@
import PlusCircleIcon from "@shared/icons/plusCircle";
import { createBlobFromFile } from "@utils/createBlobFromFile";
import { PlusCircleIcon } from "@shared/icons";
import { open } from "@tauri-apps/api/dialog";
import { listen } from "@tauri-apps/api/event";
import { Body, fetch } from "@tauri-apps/api/http";
import { createBlobFromFile } from "@utils/createBlobFromFile";
import { useCallback, useEffect, useState } from "react";
import { Transforms } from "slate";
import { useSlateStatic } from "slate-react";

View File

@@ -1,10 +1,12 @@
import { Dialog, Transition } from "@headlessui/react";
import CancelIcon from "@icons/cancel";
import ChevronDownIcon from "@icons/chevronDown";
import ChevronRightIcon from "@icons/chevronRight";
import ComposeIcon from "@icons/compose";
import { Post } from "@shared/composer/types/post";
import { User } from "@shared/composer/user";
import {
CancelIcon,
ChevronDownIcon,
ChevronRightIcon,
ComposeIcon,
} from "@shared/icons";
import { useActiveAccount } from "@stores/accounts";
import { Fragment, useState } from "react";

View File

@@ -1,11 +1,8 @@
import { ImageUploader } from "@shared/composer/imageUploader";
import TrashIcon from "@shared/icons/trash";
import { TrashIcon } from "@shared/icons";
import { RelayContext } from "@shared/relayProvider";
import { WRITEONLY_RELAYS } from "@stores/constants";
import { dateToUnix } from "@utils/date";
import { getEventHash, getSignature } from "nostr-tools";
import { useCallback, useContext, useMemo, useState } from "react";
import { Node, Transforms, createEditor } from "slate";

View File

@@ -1,4 +1,4 @@
import HeartBeatIcon from "@icons/heartbeat";
import { HeartBeatIcon } from "@shared/icons";
import { RelayContext } from "@shared/relayProvider";
import { useActiveAccount } from "@stores/accounts";
import { READONLY_RELAYS } from "@stores/constants";
@@ -8,7 +8,7 @@ import { getParentID, nip02ToArray } from "@utils/transform";
import { useContext } from "react";
import useSWRSubscription from "swr/subscription";
export default function EventCollector() {
export function EventCollector() {
const pool: any = useContext(RelayContext);
const account = useActiveAccount((state: any) => state.account);

View File

@@ -1,6 +1,6 @@
import { SVGProps } from "react";
export default function ArrowLeftIcon(
export function ArrowLeftIcon(
props: JSX.IntrinsicAttributes & SVGProps<SVGSVGElement>,
) {
return (

View File

@@ -1,6 +1,6 @@
import { SVGProps } from "react";
export default function ArrowRightIcon(
export function ArrowRightIcon(
props: JSX.IntrinsicAttributes & SVGProps<SVGSVGElement>,
) {
return (

View File

@@ -1,6 +1,6 @@
import { SVGProps } from "react";
export default function BellIcon(
export function BellIcon(
props: JSX.IntrinsicAttributes & SVGProps<SVGSVGElement>,
) {
return (

View File

@@ -1,6 +1,6 @@
import { SVGProps } from "react";
export default function CancelIcon(
export function CancelIcon(
props: JSX.IntrinsicAttributes & SVGProps<SVGSVGElement>,
) {
return (

View File

@@ -1,6 +1,6 @@
import { SVGProps } from "react";
export default function CheckCircleIcon(
export function CheckCircleIcon(
props: JSX.IntrinsicAttributes & SVGProps<SVGSVGElement>,
) {
return (

View File

@@ -1,6 +1,6 @@
import { SVGProps } from "react";
export default function ChevronDownIcon(
export function ChevronDownIcon(
props: JSX.IntrinsicAttributes & SVGProps<SVGSVGElement>,
) {
return (

View File

@@ -1,6 +1,6 @@
import { SVGProps } from "react";
export default function ChevronRightIcon(
export function ChevronRightIcon(
props: JSX.IntrinsicAttributes & SVGProps<SVGSVGElement>,
) {
return (

View File

@@ -1,6 +1,6 @@
import { SVGProps } from "react";
export default function ComposeIcon(
export function ComposeIcon(
props: JSX.IntrinsicAttributes & SVGProps<SVGSVGElement>,
) {
return (

View File

@@ -1,6 +1,6 @@
import { SVGProps } from "react";
export default function CopyIcon(
export function CopyIcon(
props: JSX.IntrinsicAttributes & SVGProps<SVGSVGElement>,
) {
return (

View File

@@ -1,6 +1,6 @@
import { SVGProps } from "react";
export default function EditIcon(
export function EditIcon(
props: JSX.IntrinsicAttributes & SVGProps<SVGSVGElement>,
) {
return (

View File

@@ -1,6 +1,6 @@
import { SVGProps } from "react";
export default function EyeOffIcon(
export function EyeOffIcon(
props: JSX.IntrinsicAttributes & SVGProps<SVGSVGElement>,
) {
return (

View File

@@ -1,6 +1,6 @@
import { SVGProps } from "react";
export default function EyeOnIcon(
export function EyeOnIcon(
props: JSX.IntrinsicAttributes & SVGProps<SVGSVGElement>,
) {
return (

View File

@@ -1,6 +1,6 @@
import { SVGProps } from "react";
export default function HeartBeatIcon(
export function HeartBeatIcon(
props: JSX.IntrinsicAttributes & SVGProps<SVGSVGElement>,
) {
return (

View File

@@ -1,6 +1,6 @@
import { SVGProps } from "react";
export default function HideIcon(
export function HideIcon(
props: JSX.IntrinsicAttributes & SVGProps<SVGSVGElement>,
) {
return (

View File

@@ -0,0 +1,31 @@
// @index('./*.tsx', f => `export * from '${f.path}'`)
export * from "./arrowLeft";
export * from "./arrowRight";
export * from "./bell";
export * from "./cancel";
export * from "./checkCircle";
export * from "./chevronDown";
export * from "./chevronRight";
export * from "./compose";
export * from "./copy";
export * from "./edit";
export * from "./eyeOff";
export * from "./eyeOn";
export * from "./heartbeat";
export * from "./hide";
export * from "./like";
export * from "./lume";
export * from "./mute";
export * from "./myspace";
export * from "./navArrowDown";
export * from "./plus";
export * from "./plusCircle";
export * from "./refresh";
export * from "./reply";
export * from "./replyMessage";
export * from "./repost";
export * from "./threads";
export * from "./trash";
export * from "./world";
export * from "./zap";
// @endindex

View File

@@ -1,6 +1,6 @@
import { SVGProps } from "react";
export default function LikeIcon(
export function LikeIcon(
props: JSX.IntrinsicAttributes & SVGProps<SVGSVGElement>,
) {
return (

View File

@@ -1,4 +1,4 @@
export default function LumeIcon({ className }: { className: string }) {
export function LumeIcon({ className }: { className: string }) {
return (
<svg
xmlns="http://www.w3.org/2000/svg"

View File

@@ -1,6 +1,6 @@
import { SVGProps } from "react";
export default function MuteIcon(
export function MuteIcon(
props: JSX.IntrinsicAttributes & SVGProps<SVGSVGElement>,
) {
return (

View File

@@ -1,6 +1,6 @@
import { SVGProps } from "react";
export default function MyspaceIcon(
export function MyspaceIcon(
props: JSX.IntrinsicAttributes & SVGProps<SVGSVGElement>,
) {
return (

View File

@@ -1,6 +1,6 @@
import { SVGProps } from "react";
export default function NavArrowDownIcon(
export function NavArrowDownIcon(
props: JSX.IntrinsicAttributes & SVGProps<SVGSVGElement>,
) {
return (

View File

@@ -1,6 +1,6 @@
import { SVGProps } from "react";
export default function PlusIcon(
export function PlusIcon(
props: JSX.IntrinsicAttributes & SVGProps<SVGSVGElement>,
) {
return (

View File

@@ -1,6 +1,6 @@
import { SVGProps } from "react";
export default function PlusCircleIcon(
export function PlusCircleIcon(
props: JSX.IntrinsicAttributes & SVGProps<SVGSVGElement>,
) {
return (

View File

@@ -1,6 +1,6 @@
import { SVGProps } from "react";
export default function RefreshIcon(
export function RefreshIcon(
props: JSX.IntrinsicAttributes & SVGProps<SVGSVGElement>,
) {
return (

View File

@@ -1,6 +1,6 @@
import { SVGProps } from "react";
export default function ReplyIcon(
export function ReplyIcon(
props: JSX.IntrinsicAttributes & SVGProps<SVGSVGElement>,
) {
return (

View File

@@ -1,6 +1,6 @@
import { SVGProps } from "react";
export default function ReplyMessageIcon(
export function ReplyMessageIcon(
props: JSX.IntrinsicAttributes & SVGProps<SVGSVGElement>,
) {
return (

View File

@@ -1,6 +1,6 @@
import { SVGProps } from "react";
export default function RepostIcon(
export function RepostIcon(
props: JSX.IntrinsicAttributes & SVGProps<SVGSVGElement>,
) {
return (

View File

@@ -1,6 +1,6 @@
import { SVGProps } from "react";
export default function ThreadsIcon(
export function ThreadsIcon(
props: JSX.IntrinsicAttributes & SVGProps<SVGSVGElement>,
) {
return (

View File

@@ -1,6 +1,6 @@
import { SVGProps } from "react";
export default function TrashIcon(
export function TrashIcon(
props: JSX.IntrinsicAttributes & SVGProps<SVGSVGElement>,
) {
return (

View File

@@ -1,6 +1,6 @@
import { SVGProps } from "react";
export default function WorldIcon(
export function WorldIcon(
props: JSX.IntrinsicAttributes & SVGProps<SVGSVGElement>,
) {
return (

View File

@@ -1,6 +1,6 @@
import { SVGProps } from "react";
export default function ZapIcon(
export function ZapIcon(
props: JSX.IntrinsicAttributes & SVGProps<SVGSVGElement>,
) {
return (

View File

@@ -1,19 +1,14 @@
import ActiveAccount from "@shared/accounts/active";
import InactiveAccount from "@shared/accounts/inactive";
import BellIcon from "@icons/bell";
import PlusIcon from "@icons/plus";
import { ActiveAccount } from "@shared/accounts/active";
import { InactiveAccount } from "@shared/accounts/inactive";
import { BellIcon, PlusIcon } from "@shared/icons";
import { APP_VERSION } from "@stores/constants";
import { getAccounts, getActiveAccount } from "@utils/storage";
import useSWR from "swr";
const allFetcher = () => getAccounts();
const fetcher = () => getActiveAccount();
export default function MultiAccounts() {
export function MultiAccounts() {
const { data: accounts }: any = useSWR("allAccounts", allFetcher);
const { data: activeAccount }: any = useSWR("activeAccount", fetcher);

View File

@@ -1,14 +1,12 @@
import ChannelsList from "@app/channel/components/list";
import ChatsList from "@app/chat/components/list";
import { ChannelsList } from "@app/channel/components/list";
import { ChatsList } from "@app/chat/components/list";
import { Disclosure } from "@headlessui/react";
import NavArrowDownIcon from "@icons/navArrowDown";
import ThreadsIcon from "@icons/threads";
import WorldIcon from "@icons/world";
import ActiveLink from "@shared/activeLink";
import { ActiveLink } from "@shared/activeLink";
import { AppHeader } from "@shared/appHeader";
import { ComposerModal } from "@shared/composer/modal";
import { NavArrowDownIcon, ThreadsIcon, WorldIcon } from "@shared/icons";
export default function Navigation() {
export function Navigation() {
return (
<div className="flex w-[232px] h-full flex-col gap-3 border-r border-zinc-900">
<AppHeader />

View File

@@ -1,26 +0,0 @@
import { RelayContext } from "@shared/relaysProvider";
import { UserFollow } from "@shared/user/follow";
import { READONLY_RELAYS } from "@stores/constants";
import destr from "destr";
import { Author } from "nostr-relaypool";
import { useContext, useEffect, useState } from "react";
export default function ProfileFollowers({ id }: { id: string }) {
const pool: any = useContext(RelayContext);
const [followers, setFollowers] = useState(null);
useEffect(() => {
const user = new Author(pool, READONLY_RELAYS, id);
user.followers((res) => setFollowers(destr(res.tags)), 0, 100);
}, [id, pool]);
return (
<div className="flex flex-col gap-3 px-3 py-5">
{followers?.map((follower) => (
<UserFollow key={follower[1]} pubkey={follower[1]} />
))}
</div>
);
}

View File

@@ -1,25 +0,0 @@
import { RelayContext } from "@shared/relaysProvider";
import { UserFollow } from "@shared/user/follow";
import { READONLY_RELAYS } from "@stores/constants";
import { Author } from "nostr-relaypool";
import { useContext, useEffect, useState } from "react";
export default function ProfileFollows({ id }: { id: string }) {
const pool: any = useContext(RelayContext);
const [follows, setFollows] = useState(null);
useEffect(() => {
const user = new Author(pool, READONLY_RELAYS, id);
user.follows((res) => setFollows(res), 0);
}, [id, pool]);
return (
<div className="flex flex-col gap-3 px-3 py-5">
{follows?.map((follow) => (
<UserFollow key={follow.pubkey} pubkey={follow.pubkey} />
))}
</div>
);
}

View File

@@ -1,61 +0,0 @@
import { Image } from "@shared/image";
import { RelayContext } from "@shared/relayProvider";
import { DEFAULT_AVATAR, READONLY_RELAYS } from "@stores/constants";
import { shortenKey } from "@utils/shortenKey";
import destr from "destr";
import { Author } from "nostr-relaypool";
import { useContext, useEffect, useState } from "react";
const DEFAULT_BANNER =
"https://bafybeiacwit7hjmdefqggxqtgh6ht5dhth7ndptwn2msl5kpkodudsr7py.ipfs.w3s.link/banner-1.jpg";
export default function ProfileMetadata({ id }: { id: string }) {
const pool: any = useContext(RelayContext);
const [profile, setProfile] = useState(null);
useEffect(() => {
const user = new Author(pool, READONLY_RELAYS, id);
user.metaData((res) => setProfile(destr(res.content)), 0);
}, [id, pool]);
return (
<>
<div className="relative">
<div className="relative h-56 w-full rounded-t-lg bg-zinc-800">
<Image
src={profile?.banner || DEFAULT_BANNER}
alt="user's banner"
className="h-58 w-full object-cover"
/>
</div>
<div className="relative -top-8 z-10 px-4">
<div className="relative h-16 w-16 rounded-lg bg-zinc-900 ring-2 ring-zinc-900">
<Image
src={profile?.picture || DEFAULT_AVATAR}
alt={id}
className="h-16 w-16 rounded-lg object-cover"
/>
</div>
</div>
</div>
<div className="-mt-4 mb-8 px-4">
<div>
<div className="mb-3 flex flex-col">
<h3 className="text-lg font-semibold leading-tight text-white">
{profile?.display_name || profile?.name}
</h3>
<span className="text-base leading-tight text-zinc-500">
{profile?.username || (id && shortenKey(id))}
</span>
</div>
<div className="prose-sm prose-zinc leading-tight dark:prose-invert">
{profile?.about}
</div>
</div>
</div>
</>
);
}

View File

@@ -1,27 +0,0 @@
import { NoteBase } from "@shared/note/base";
import { RelayContext } from "@shared/relaysProvider";
import { READONLY_RELAYS } from "@stores/constants";
import { Author } from "nostr-relaypool";
import { useContext, useEffect, useState } from "react";
export default function ProfileNotes({ id }: { id: string }) {
const pool: any = useContext(RelayContext);
const [data, setData] = useState([]);
useEffect(() => {
const user = new Author(pool, READONLY_RELAYS, id);
user.text((res) => setData((data) => [...data, res]), 100, 0);
}, [id, pool]);
return (
<div className="flex flex-col">
{data.map((item) => (
<div key={item.id}>
<NoteBase event={item} />
</div>
))}
</div>
);
}