From 2f3ea13613c83a25719caf1f85ba16d7f562fdc5 Mon Sep 17 00:00:00 2001
From: Ren Amamiya <123083837+reyamir@users.noreply.github.com>
Date: Wed, 7 Jun 2023 13:30:50 +0700
Subject: [PATCH] temp remove threads
---
src/app/prefetch/pages/index.page.tsx | 19 -----
src/app/threads/_default.page.tsx | 1 -
src/app/threads/components/author.tsx | 38 ----------
src/app/threads/components/base.tsx | 40 ----------
src/app/threads/layout.tsx | 14 ----
src/app/threads/pages/index.page.tsx | 103 --------------------------
src/shared/icons/index.tsx | 2 +-
src/shared/icons/myspace.tsx | 24 ------
src/shared/icons/space.tsx | 22 ++++++
src/shared/navigation.tsx | 10 +--
10 files changed, 28 insertions(+), 245 deletions(-)
delete mode 100644 src/app/threads/_default.page.tsx
delete mode 100644 src/app/threads/components/author.tsx
delete mode 100644 src/app/threads/components/base.tsx
delete mode 100644 src/app/threads/layout.tsx
delete mode 100644 src/app/threads/pages/index.page.tsx
delete mode 100644 src/shared/icons/myspace.tsx
create mode 100644 src/shared/icons/space.tsx
diff --git a/src/app/prefetch/pages/index.page.tsx b/src/app/prefetch/pages/index.page.tsx
index 61055580..d3bd6f5c 100644
--- a/src/app/prefetch/pages/index.page.tsx
+++ b/src/app/prefetch/pages/index.page.tsx
@@ -74,12 +74,6 @@ export function Page() {
since: lastLogin,
});
- // long post
- query.push({
- kinds: [30023],
- since: lastLogin,
- });
-
return query;
}, [account]);
@@ -169,19 +163,6 @@ export function Page() {
event.id,
);
break;
- // long post
- case 30023:
- createNote(
- event.id,
- account.id,
- event.pubkey,
- event.kind,
- event.tags,
- event.content,
- event.created_at,
- event.id,
- );
- break;
default:
break;
}
diff --git a/src/app/threads/_default.page.tsx b/src/app/threads/_default.page.tsx
deleted file mode 100644
index a2814770..00000000
--- a/src/app/threads/_default.page.tsx
+++ /dev/null
@@ -1 +0,0 @@
-export { LayoutNewsfeed as Layout } from "./layout";
diff --git a/src/app/threads/components/author.tsx b/src/app/threads/components/author.tsx
deleted file mode 100644
index c3c51061..00000000
--- a/src/app/threads/components/author.tsx
+++ /dev/null
@@ -1,38 +0,0 @@
-import { Image } from "@shared/image";
-import { DEFAULT_AVATAR } from "@stores/constants";
-import { useProfile } from "@utils/hooks/useProfile";
-import { shortenKey } from "@utils/shortenKey";
-import dayjs from "dayjs";
-
-export function ThreadAuthor({
- pubkey,
- time,
-}: { pubkey: string; time: number }) {
- const { user } = useProfile(pubkey);
-
- return (
-
-
-
-
-
-
-
- {user?.display_name || user?.name || (
-
- )}
-
-
- {user?.nip05 || shortenKey(pubkey)}
- •
- {dayjs().to(dayjs.unix(time), true)}
-
-
-
-
- );
-}
diff --git a/src/app/threads/components/base.tsx b/src/app/threads/components/base.tsx
deleted file mode 100644
index eadedbc4..00000000
--- a/src/app/threads/components/base.tsx
+++ /dev/null
@@ -1,40 +0,0 @@
-import { ThreadAuthor } from "@app/threads/components/author";
-import { Image } from "@shared/image";
-
-export function ThreadBase({ event }: { event: any }) {
- const metadata = JSON.parse(event.tags);
- const title = metadata.find((i: any) => i[0] === "title")?.[1];
- const summary = metadata.find((i: any) => i[0] === "summary")?.[1];
- const image = metadata.find((i: any) => i[0] === "image")?.[1];
-
- if (!title) {
- return null;
- }
-
- return (
-
- );
-}
diff --git a/src/app/threads/layout.tsx b/src/app/threads/layout.tsx
deleted file mode 100644
index 06b9472d..00000000
--- a/src/app/threads/layout.tsx
+++ /dev/null
@@ -1,14 +0,0 @@
-import { MultiAccounts } from "@shared/multiAccounts";
-import { Navigation } from "@shared/navigation";
-
-export function LayoutNewsfeed({ children }: { children: React.ReactNode }) {
- return (
-
- );
-}
diff --git a/src/app/threads/pages/index.page.tsx b/src/app/threads/pages/index.page.tsx
deleted file mode 100644
index dd8e3d99..00000000
--- a/src/app/threads/pages/index.page.tsx
+++ /dev/null
@@ -1,103 +0,0 @@
-import { NoteSkeleton } from "@app/note/components/skeleton";
-import { ThreadBase } from "@app/threads/components/base";
-import { useVirtualizer } from "@tanstack/react-virtual";
-import { getLongNotes } from "@utils/storage";
-import { useEffect, useMemo, useRef } from "react";
-import useSWRInfinite from "swr/infinite";
-
-const ITEM_PER_PAGE = 10;
-const TIME = Math.floor(Date.now() / 1000);
-
-const fetcher = async ([, offset]) => getLongNotes(TIME, ITEM_PER_PAGE, offset);
-
-function isJSON(str: string) {
- try {
- JSON.parse(str);
- } catch (e) {
- return false;
- }
- return true;
-}
-
-export function Page() {
- const getKey = (pageIndex, previousPageData) => {
- if (previousPageData && !previousPageData.data) return null;
- if (pageIndex === 0) return ["following", 0];
- return ["following", previousPageData.nextCursor];
- };
-
- const { data, isLoading, size, setSize } = useSWRInfinite(getKey, fetcher);
-
- const notes = useMemo(
- () => (data ? data.flatMap((d) => d.data) : []),
- [data],
- );
-
- const parentRef = useRef();
- const rowVirtualizer = useVirtualizer({
- count: notes.length,
- getScrollElement: () => parentRef.current,
- estimateSize: () => 400,
- overscan: 2,
- });
- const itemsVirtualizer = rowVirtualizer.getVirtualItems();
-
- useEffect(() => {
- const [lastItem] = [...rowVirtualizer.getVirtualItems()].reverse();
-
- if (!lastItem) {
- return;
- }
-
- if (lastItem.index >= notes.length - 1) {
- setSize(size + 1);
- }
- }, [notes.length, rowVirtualizer.getVirtualItems()]);
-
- return (
-
- {!data || isLoading ? (
-
- ) : (
-
-
- {rowVirtualizer.getVirtualItems().map((virtualRow) => {
- const note = notes[virtualRow.index];
- if (note && isJSON(note.tags)) {
- return (
-
-
-
- );
- }
- })}
-
-
- )}
-
- );
-}
diff --git a/src/shared/icons/index.tsx b/src/shared/icons/index.tsx
index 58f1503f..f984bf38 100644
--- a/src/shared/icons/index.tsx
+++ b/src/shared/icons/index.tsx
@@ -20,7 +20,7 @@ export * from "./like";
export * from "./lume";
export * from "./media";
export * from "./mute";
-export * from "./myspace";
+export * from "./space";
export * from "./navArrowDown";
export * from "./plus";
export * from "./plusCircle";
diff --git a/src/shared/icons/myspace.tsx b/src/shared/icons/myspace.tsx
deleted file mode 100644
index da9a1559..00000000
--- a/src/shared/icons/myspace.tsx
+++ /dev/null
@@ -1,24 +0,0 @@
-import { SVGProps } from "react";
-
-export function MyspaceIcon(
- props: JSX.IntrinsicAttributes & SVGProps,
-) {
- return (
-
- );
-}
diff --git a/src/shared/icons/space.tsx b/src/shared/icons/space.tsx
new file mode 100644
index 00000000..270a707c
--- /dev/null
+++ b/src/shared/icons/space.tsx
@@ -0,0 +1,22 @@
+import { SVGProps } from "react";
+
+export function SpaceIcon(
+ props: JSX.IntrinsicAttributes & SVGProps,
+) {
+ return (
+
+ );
+}
diff --git a/src/shared/navigation.tsx b/src/shared/navigation.tsx
index d3fa6a71..0c843abf 100644
--- a/src/shared/navigation.tsx
+++ b/src/shared/navigation.tsx
@@ -4,7 +4,7 @@ import { Disclosure } from "@headlessui/react";
import { ActiveLink } from "@shared/activeLink";
import { AppHeader } from "@shared/appHeader";
import { ComposerModal } from "@shared/composer/modal";
-import { NavArrowDownIcon, ThreadsIcon, WorldIcon } from "@shared/icons";
+import { NavArrowDownIcon, SpaceIcon, WorldIcon } from "@shared/icons";
export function Navigation() {
return (
@@ -27,19 +27,19 @@ export function Navigation() {
activeClassName="bg-zinc-900/50 hover:bg-zinc-900"
>
-
+
Space
-
+
- Threads
+ Trending