From c80414a72da698f04b137cf8f44d1757a1cc7c6e Mon Sep 17 00:00:00 2001 From: Ren Amamiya <123083837+reyamir@users.noreply.github.com> Date: Thu, 28 Sep 2023 07:29:05 +0700 Subject: [PATCH] small fixes and support $ boost sign --- src-tauri/Cargo.toml | 2 +- src/app/auth/import/step-3.tsx | 4 ++-- src/app/auth/welcome.tsx | 30 +++-------------------------- src/shared/notes/index.ts | 1 + src/shared/notes/kinds/text.tsx | 4 ++++ src/shared/notes/mentions/boost.tsx | 5 +++++ src/shared/notes/mentions/user.tsx | 18 +++++++++-------- src/utils/parser.ts | 5 +++++ 8 files changed, 31 insertions(+), 38 deletions(-) create mode 100644 src/shared/notes/mentions/boost.tsx diff --git a/src-tauri/Cargo.toml b/src-tauri/Cargo.toml index 2e7d3753..096a0f38 100644 --- a/src-tauri/Cargo.toml +++ b/src-tauri/Cargo.toml @@ -16,7 +16,7 @@ tauri-build = { version = "1.4", features = [] } [dependencies] serde_json = "1.0" serde = { version = "1.0", features = ["derive"] } -tauri = { version = "1.4", features = [ +tauri = { version = "1.4", features = [ "macos-private-api", "window-close", "window-print", "window-create", diff --git a/src/app/auth/import/step-3.tsx b/src/app/auth/import/step-3.tsx index bf8bbff7..0f100cfe 100644 --- a/src/app/auth/import/step-3.tsx +++ b/src/app/auth/import/step-3.tsx @@ -80,8 +80,8 @@ export function ImportStep3Screen() { )} - By clicking 'Continue', Lume will sync your old relay list and - metadata.
It may take a bit, please be patient. + By clicking 'Continue', Lume will download your old relay list and + metadata. It may take a bit
diff --git a/src/app/auth/welcome.tsx b/src/app/auth/welcome.tsx index d6dcc157..375ae582 100644 --- a/src/app/auth/welcome.tsx +++ b/src/app/auth/welcome.tsx @@ -1,34 +1,10 @@ -import { LogicalSize, getCurrent } from '@tauri-apps/api/window'; -import { useEffect } from 'react'; import { Link } from 'react-router-dom'; import { ArrowRightCircleIcon } from '@shared/icons/arrowRightCircle'; export function WelcomeScreen() { - const appWindow = getCurrent(); - - async function setWindow() { - await appWindow.setSize(new LogicalSize(400, 500)); - await appWindow.setResizable(false); - await appWindow.center(); - } - - async function resetWindow() { - await appWindow.setSize(new LogicalSize(1080, 800)); - await appWindow.setResizable(true); - await appWindow.center(); - } - - useEffect(() => { - setWindow(); - - return () => { - resetWindow(); - }; - }, []); - return ( -
+

Welcome to Lume

@@ -54,8 +30,8 @@ export function WelcomeScreen() {
-
- lume +
+ lume
); diff --git a/src/shared/notes/index.ts b/src/shared/notes/index.ts index 9c30f1f7..15002a58 100644 --- a/src/shared/notes/index.ts +++ b/src/shared/notes/index.ts @@ -22,5 +22,6 @@ export * from './child'; export * from './skeleton'; export * from './actions'; export * from './mentions/hashtag'; +export * from './mentions/boost'; export * from './stats'; export * from './wrapper'; diff --git a/src/shared/notes/kinds/text.tsx b/src/shared/notes/kinds/text.tsx index a572c082..748e1693 100644 --- a/src/shared/notes/kinds/text.tsx +++ b/src/shared/notes/kinds/text.tsx @@ -3,6 +3,7 @@ import { Link } from 'react-router-dom'; import remarkGfm from 'remark-gfm'; import { + Boost, Hashtag, ImagePreview, LinkPreview, @@ -56,6 +57,9 @@ export function TextNote(props: { content?: string }) { if (key.startsWith('tag')) { return ; } + if (key.startsWith('boost')) { + return ; + } }, }} disallowedElements={['h1', 'h2', 'h3', 'h4', 'h5', 'h6']} diff --git a/src/shared/notes/mentions/boost.tsx b/src/shared/notes/mentions/boost.tsx new file mode 100644 index 00000000..12820306 --- /dev/null +++ b/src/shared/notes/mentions/boost.tsx @@ -0,0 +1,5 @@ +export function Boost({ boost }: { boost: string }) { + return ( + {boost} + ); +} diff --git a/src/shared/notes/mentions/user.tsx b/src/shared/notes/mentions/user.tsx index f24e84e2..2bf3e6ed 100644 --- a/src/shared/notes/mentions/user.tsx +++ b/src/shared/notes/mentions/user.tsx @@ -1,11 +1,12 @@ +import { memo } from 'react'; + import { useStorage } from '@libs/storage/provider'; import { WidgetKinds, useWidgets } from '@stores/widgets'; import { useProfile } from '@utils/hooks/useProfile'; -import { displayNpub } from '@utils/shortenKey'; -export function MentionUser({ pubkey }: { pubkey: string }) { +export const MentionUser = memo(function MentionUser({ pubkey }: { pubkey: string }) { const { db } = useStorage(); const { user } = useProfile(pubkey); @@ -31,11 +32,12 @@ export function MentionUser({ pubkey }: { pubkey: string }) { } className="break-words text-fuchsia-400 hover:text-fuchsia-500" > - {user?.name || - user?.display_name || - user?.displayName || - user?.username || - displayNpub(pubkey, 16)} + {'@' + + (user?.name || + user?.display_name || + user?.displayName || + user?.username || + 'unknown')} ); -} +}); diff --git a/src/utils/parser.ts b/src/utils/parser.ts index 9ded8551..cfe0ed78 100644 --- a/src/utils/parser.ts +++ b/src/utils/parser.ts @@ -57,6 +57,11 @@ export function parser(eventContent: string) { return word.replace(word, `~tag-${word}~`); } + // boost + if (word.startsWith('$') && word.length > 1) { + return word.replace(word, `~boost-${word}~`); + } + // nostr account references if (word.startsWith('nostr:npub1') || word.startsWith('npub1')) { const npub = word.replace('nostr:', '').replace(/[^a-zA-Z0-9 ]/g, '');