From 5655a8136dfed7d42f0f549bc32e3dcb1164a33f Mon Sep 17 00:00:00 2001 From: reya Date: Tue, 5 Nov 2024 19:33:47 +0700 Subject: [PATCH] feat: improve dark mode and some copy --- src/routes.gen.ts | 28 --- src/routes/bootstrap-relays.lazy.tsx | 159 ------------------ src/routes/bootstrap-relays.tsx | 14 -- .../_layout/discover-interests.lazy.tsx | 17 +- .../_layout/discover-newsfeeds.lazy.tsx | 17 +- .../columns/_layout/discover-relays.lazy.tsx | 17 +- .../columns/_layout/events.$id.lazy.tsx | 1 - src/routes/new.lazy.tsx | 12 +- 8 files changed, 45 insertions(+), 220 deletions(-) delete mode 100644 src/routes/bootstrap-relays.lazy.tsx delete mode 100644 src/routes/bootstrap-relays.tsx diff --git a/src/routes.gen.ts b/src/routes.gen.ts index 47c4d9a4..d8e0dd9f 100644 --- a/src/routes.gen.ts +++ b/src/routes.gen.ts @@ -13,7 +13,6 @@ import { createFileRoute } from '@tanstack/react-router' // Import Routes import { Route as rootRoute } from './routes/__root' -import { Route as BootstrapRelaysImport } from './routes/bootstrap-relays' import { Route as AppImport } from './routes/_app' import { Route as NewPostIndexImport } from './routes/new-post/index' import { Route as AppIndexImport } from './routes/_app/index' @@ -91,14 +90,6 @@ const NewLazyRoute = NewLazyImport.update({ getParentRoute: () => rootRoute, } as any).lazy(() => import('./routes/new.lazy').then((d) => d.Route)) -const BootstrapRelaysRoute = BootstrapRelaysImport.update({ - id: '/bootstrap-relays', - path: '/bootstrap-relays', - getParentRoute: () => rootRoute, -} as any).lazy(() => - import('./routes/bootstrap-relays.lazy').then((d) => d.Route), -) - const AppRoute = AppImport.update({ id: '/_app', getParentRoute: () => rootRoute, @@ -389,13 +380,6 @@ declare module '@tanstack/react-router' { preLoaderRoute: typeof AppImport parentRoute: typeof rootRoute } - '/bootstrap-relays': { - id: '/bootstrap-relays' - path: '/bootstrap-relays' - fullPath: '/bootstrap-relays' - preLoaderRoute: typeof BootstrapRelaysImport - parentRoute: typeof rootRoute - } '/new': { id: '/new' path: '/new' @@ -758,7 +742,6 @@ const SettingsIdLazyRouteWithChildren = SettingsIdLazyRoute._addFileChildren( export interface FileRoutesByFullPath { '': typeof AppRouteWithChildren - '/bootstrap-relays': typeof BootstrapRelaysRoute '/new': typeof NewLazyRoute '/$id/set-group': typeof IdSetGroupRoute '/$id/set-interest': typeof IdSetInterestRoute @@ -797,7 +780,6 @@ export interface FileRoutesByFullPath { } export interface FileRoutesByTo { - '/bootstrap-relays': typeof BootstrapRelaysRoute '/new': typeof NewLazyRoute '/$id/set-group': typeof IdSetGroupRoute '/$id/set-interest': typeof IdSetInterestRoute @@ -838,7 +820,6 @@ export interface FileRoutesByTo { export interface FileRoutesById { __root__: typeof rootRoute '/_app': typeof AppRouteWithChildren - '/bootstrap-relays': typeof BootstrapRelaysRoute '/new': typeof NewLazyRoute '/$id/set-group': typeof IdSetGroupRoute '/$id/set-interest': typeof IdSetInterestRoute @@ -881,7 +862,6 @@ export interface FileRouteTypes { fileRoutesByFullPath: FileRoutesByFullPath fullPaths: | '' - | '/bootstrap-relays' | '/new' | '/$id/set-group' | '/$id/set-interest' @@ -919,7 +899,6 @@ export interface FileRouteTypes { | '/columns/users/$id' fileRoutesByTo: FileRoutesByTo to: - | '/bootstrap-relays' | '/new' | '/$id/set-group' | '/$id/set-interest' @@ -958,7 +937,6 @@ export interface FileRouteTypes { id: | '__root__' | '/_app' - | '/bootstrap-relays' | '/new' | '/$id/set-group' | '/$id/set-interest' @@ -1000,7 +978,6 @@ export interface FileRouteTypes { export interface RootRouteChildren { AppRoute: typeof AppRouteWithChildren - BootstrapRelaysRoute: typeof BootstrapRelaysRoute NewLazyRoute: typeof NewLazyRoute IdSetGroupRoute: typeof IdSetGroupRoute IdSetInterestRoute: typeof IdSetInterestRoute @@ -1016,7 +993,6 @@ export interface RootRouteChildren { const rootRouteChildren: RootRouteChildren = { AppRoute: AppRouteWithChildren, - BootstrapRelaysRoute: BootstrapRelaysRoute, NewLazyRoute: NewLazyRoute, IdSetGroupRoute: IdSetGroupRoute, IdSetInterestRoute: IdSetInterestRoute, @@ -1043,7 +1019,6 @@ export const routeTree = rootRoute "filePath": "__root.tsx", "children": [ "/_app", - "/bootstrap-relays", "/new", "/$id/set-group", "/$id/set-interest", @@ -1063,9 +1038,6 @@ export const routeTree = rootRoute "/_app/" ] }, - "/bootstrap-relays": { - "filePath": "bootstrap-relays.tsx" - }, "/new": { "filePath": "new.lazy.tsx" }, diff --git a/src/routes/bootstrap-relays.lazy.tsx b/src/routes/bootstrap-relays.lazy.tsx deleted file mode 100644 index f70afd45..00000000 --- a/src/routes/bootstrap-relays.lazy.tsx +++ /dev/null @@ -1,159 +0,0 @@ -import { commands } from "@/commands.gen"; -import { GoBack } from "@/components"; -import { Frame } from "@/components/frame"; -import { Spinner } from "@/components/spinner"; -import { ArrowLeft, Plus, X } from "@phosphor-icons/react"; -import { createLazyFileRoute } from "@tanstack/react-router"; -import { message } from "@tauri-apps/plugin-dialog"; -import { relaunch } from "@tauri-apps/plugin-process"; -import { useEffect, useState, useTransition } from "react"; - -export const Route = createLazyFileRoute("/bootstrap-relays")({ - component: Screen, -}); - -function Screen() { - const bootstrapRelays = Route.useLoaderData(); - - const [relays, setRelays] = useState([]); - const [newRelay, setNewRelay] = useState(""); - const [isPending, startTransition] = useTransition(); - - const add = () => { - try { - let url = newRelay; - - if (!url.startsWith("wss://")) { - url = `wss://${url}`; - } - - // Validate URL - const relay = new URL(url); - - // Update - setRelays((prev) => [...prev, relay.toString()]); - setNewRelay(""); - } catch { - message("URL is not valid.", { kind: "error" }); - } - }; - - const remove = (relay: string) => { - setRelays((prev) => prev.filter((item) => item !== relay)); - }; - - const submit = () => { - startTransition(async () => { - if (!relays.length) { - await message("You need to add at least 1 relay", { - title: "Manage Relays", - kind: "info", - }); - return; - } - - const merged = relays.join("\r\n"); - const res = await commands.setBootstrapRelays(merged); - - if (res.status === "ok") { - return await relaunch(); - } else { - await message(res.error, { - title: "Manage Relays", - kind: "error", - }); - return; - } - }); - }; - - useEffect(() => { - setRelays(bootstrapRelays); - }, [bootstrapRelays]); - - return ( -
-
-
-

Manage Relays

-

- The default relays that Lume will connected. -

-
-
- -
- setNewRelay(e.target.value)} - onKeyDown={(e) => { - if (e.key === "Enter") add(); - }} - className="flex-1 px-3 rounded-lg h-9 bg-transparent border border-neutral-200 dark:border-neutral-800 focus:border-blue-500 focus:outline-none placeholder:text-neutral-400 dark:placeholder:text-neutral-600" - /> - -
-
- {relays.map((relay) => ( -
-
{relay}
-
- -
-
- ))} -
-
-

- Lume is heavily depend on Negentropy for syncing data. You need - to use at least 1 relay that support Negentropy. If you not - sure, you can keep using the default relay list. -

-
- -
- - - Lume will relaunch after saving. - -
-
-
- - - Back - -
- ); -} diff --git a/src/routes/bootstrap-relays.tsx b/src/routes/bootstrap-relays.tsx deleted file mode 100644 index 92560aba..00000000 --- a/src/routes/bootstrap-relays.tsx +++ /dev/null @@ -1,14 +0,0 @@ -import { commands } from "@/commands.gen"; -import { createFileRoute } from "@tanstack/react-router"; - -export const Route = createFileRoute("/bootstrap-relays")({ - loader: async () => { - const res = await commands.getBootstrapRelays(); - - if (res.status === "ok") { - return res.data.map((item) => item.replace(",", "")); - } else { - throw new Error(res.error); - } - }, -}); diff --git a/src/routes/columns/_layout/discover-interests.lazy.tsx b/src/routes/columns/_layout/discover-interests.lazy.tsx index 33324e00..131de391 100644 --- a/src/routes/columns/_layout/discover-interests.lazy.tsx +++ b/src/routes/columns/_layout/discover-interests.lazy.tsx @@ -143,12 +143,14 @@ function Screen() {

) : isError ? ( -
-

{error?.message ?? "Error"}

+
+

+ {error?.message ?? "Error"} +

) : !data?.length ? ( -
-

+

+

Nothing to show yet, you can use Lume more and comeback lack to see new events.

@@ -156,6 +158,13 @@ function Screen() { ) : ( data?.map((item) => renderItem(item)) )} +
+

+ Lume running sync in the background, +
+ the more you use the more event you see. +

+
{hasNextPage ? (
) : isError ? ( -
-

{error?.message ?? "Error"}

+
+

+ {error?.message ?? "Error"} +

) : !data?.length ? ( -
-

+

+

Nothing to show yet, you can use Lume more and comeback lack to see new events.

@@ -150,6 +152,13 @@ function Screen() { ) : ( data?.map((item) => renderItem(item)) )} +
+

+ Lume running sync in the background, +
+ the more you use the more event you see. +

+
{hasNextPage ? (
) : isError ? ( -
-

{error?.message ?? "Error"}

+
+

+ {error?.message ?? "Error"} +

) : !data?.length ? ( -
-

+

+

Nothing to show yet, you can use Lume more and comeback lack to see new events.

@@ -128,6 +130,13 @@ function Screen() { ) : ( data?.map((item) => renderItem(item)) )} +
+

+ Lume running sync in the background, +
+ the more you use the more event you see. +

+
{hasNextPage ? (