small fixes

This commit is contained in:
Ren Amamiya 2023-09-13 11:10:24 +07:00
parent fa0d7cac31
commit 5a6dd172b1
19 changed files with 57 additions and 33 deletions

BIN
bun.lockb

Binary file not shown.

View File

@ -60,7 +60,7 @@ export function NotificationScreen() {
<p className="text-sm font-medium text-white/50">Loading</p>
</div>
</div>
) : activities.length < 1 ? (
) : activities.length <= 1 ? (
<div className="flex h-full w-full flex-col items-center justify-center">
<p className="mb-1 text-4xl">🎉</p>
<p className="font-medium text-white/50">

View File

@ -19,7 +19,7 @@ export function AccountMoreActions({ pubkey }: { pubkey: string }) {
</button>
</DropdownMenu.Trigger>
<DropdownMenu.Portal>
<DropdownMenu.Content className="flex w-[200px] flex-col overflow-hidden rounded-xl bg-white/10 p-2 backdrop-blur-3xl focus:outline-none">
<DropdownMenu.Content className="flex w-[200px] flex-col overflow-hidden rounded-xl border border-white/10 bg-white/10 p-2 backdrop-blur-3xl focus:outline-none">
<DropdownMenu.Item asChild>
<Link
to={`/users/${pubkey}`}

View File

@ -45,7 +45,7 @@ export function MoreActions({ id, pubkey }: { id: string; pubkey: string }) {
</Tooltip.Portal>
</Tooltip.Root>
<DropdownMenu.Portal>
<DropdownMenu.Content className="flex w-[200px] flex-col overflow-hidden rounded-xl bg-white/10 p-2 backdrop-blur-3xl focus:outline-none">
<DropdownMenu.Content className="flex w-[200px] flex-col overflow-hidden rounded-xl border border-white/10 bg-white/10 p-2 backdrop-blur-3xl focus:outline-none">
<DropdownMenu.Item asChild>
<button
type="button"

View File

@ -1,3 +1,4 @@
import { NDKKind } from '@nostr-dev-kit/ndk';
import * as Popover from '@radix-ui/react-popover';
import { useState } from 'react';
@ -44,7 +45,7 @@ export function NoteReaction({ id, pubkey }: { id: string; pubkey: string }) {
const event = await publish({
content: content,
kind: 7,
kind: NDKKind.Reaction,
tags: [
['e', id],
['p', pubkey],

View File

@ -1,25 +1,39 @@
import { NDKKind } from '@nostr-dev-kit/ndk';
import * as AlertDialog from '@radix-ui/react-alert-dialog';
import * as Tooltip from '@radix-ui/react-tooltip';
import { message } from '@tauri-apps/api/dialog';
import { useState } from 'react';
import { twMerge } from 'tailwind-merge';
import { RepostIcon } from '@shared/icons';
import { useNDK } from '@libs/ndk/provider';
import { LoaderIcon, RepostIcon } from '@shared/icons';
import { useNostr } from '@utils/hooks/useNostr';
import { sendNativeNotification } from '@utils/notification';
export function NoteRepost({ id, pubkey }: { id: string; pubkey: string }) {
const { publish } = useNostr();
const { relayUrls } = useNDK();
const [open, setOpen] = useState(false);
const [isLoading, setIsLoading] = useState(false);
const [isRepost, setIsRepost] = useState(false);
const submit = async () => {
setIsLoading(true);
const tags = [
['e', id, 'wss://relayable.org', 'root'],
['e', id, relayUrls[0], 'root'],
['p', pubkey],
];
const event = await publish({ content: '', kind: 6, tags: tags });
const event = await publish({ content: '', kind: NDKKind.Repost, tags: tags });
if (event) {
setOpen(false);
setIsRepost(true);
await sendNativeNotification('Reposted successfully', 'Lume');
} else {
console.log('failed reposting');
setIsLoading(false);
await message('Repost failed, try again later', { title: 'Lume', type: 'error' });
}
};
@ -32,7 +46,12 @@ export function NoteRepost({ id, pubkey }: { id: string; pubkey: string }) {
type="button"
className="group inline-flex h-7 w-7 items-center justify-center"
>
<RepostIcon className="h-5 w-5 text-white group-hover:text-blue-400" />
<RepostIcon
className={twMerge(
'h-5 w-5 group-hover:text-blue-400',
isRepost ? 'text-blue-400' : 'text-white'
)}
/>
</button>
</AlertDialog.Trigger>
</Tooltip.Trigger>
@ -56,18 +75,22 @@ export function NoteRepost({ id, pubkey }: { id: string; pubkey: string }) {
action.
</AlertDialog.Description>
</div>
<div className="flex justify-end gap-2 px-5 py-3">
<div className="flex justify-end gap-2 px-3 py-3">
<AlertDialog.Cancel asChild>
<button className="inline-flex h-9 items-center justify-center rounded-md px-4 text-sm font-medium leading-none text-white outline-none hover:bg-white/10 hover:backdrop-blur-xl">
<button className="inline-flex h-9 w-20 items-center justify-center rounded-md text-sm font-medium leading-none text-white outline-none hover:bg-white/10 hover:backdrop-blur-xl">
Cancel
</button>
</AlertDialog.Cancel>
<button
type="button"
onClick={() => submit()}
className="inline-flex h-9 items-center justify-center rounded-md bg-white/10 px-4 text-sm font-medium leading-none text-white outline-none hover:bg-fuchsia-500"
className="inline-flex h-9 w-28 items-center justify-center rounded-md bg-white/10 text-sm font-medium leading-none text-white outline-none hover:bg-fuchsia-500"
>
Yes, repost
{isLoading ? (
<LoaderIcon className="h-4 w-4 animate-spin text-white" />
) : (
'Yes, repost'
)}
</button>
</div>
</div>

View File

@ -19,8 +19,8 @@ import { compactNumber } from '@utils/number';
export function NoteZap({ id, pubkey }: { id: string; pubkey: string }) {
const { createZap } = useNostr();
const { data: event } = useEvent(id);
const { user } = useProfile(pubkey);
const { data: event } = useEvent(id);
const [amount, setAmount] = useState<string>('21');
const [zapMessage, setZapMessage] = useState<string>('');

View File

@ -17,9 +17,9 @@ import { User } from '@shared/user';
import { useEvent } from '@utils/hooks/useEvent';
export function Repost({ event }: { event: NDKEvent }) {
// @ts-expect-error, root_id isn't exist on NDKEvent
const { status, data } = useEvent(event.root_id ?? event.id, event.content);
export function Repost({ event, root }: { event: NDKEvent; root?: string }) {
const rootPost = root ?? event.tags.find((el) => el[0] === 'e')?.[1];
const { status, data } = useEvent(rootPost, event.content);
const renderKind = useCallback(
(repostEvent: NDKEvent) => {

View File

@ -18,7 +18,7 @@ export function RepostUser({ pubkey }: { pubkey: string }) {
className="relative z-20 inline-block h-6 w-6 rounded bg-white ring-1 ring-black"
/>
<div className="inline-flex items-baseline gap-1">
<h5 className="max-w-[18rem] truncate text-white/50">
<h5 className="max-w-[13rem] truncate text-white/50">
{user?.name || user?.display_name || shortenKey(pubkey)}
</h5>
<span className="text-white/50">reposted</span>

View File

@ -88,7 +88,7 @@ export function User({
</div>
<Popover.Portal>
<Popover.Content
className="w-[300px] overflow-hidden rounded-lg bg-white/10 backdrop-blur-3xl focus:outline-none"
className="w-[300px] overflow-hidden rounded-xl border border-white/10 bg-white/10 backdrop-blur-3xl focus:outline-none"
sideOffset={5}
>
<div className="flex gap-2.5 border-b border-white/5 px-3 py-3">
@ -115,7 +115,7 @@ export function User({
)}
</div>
<div>
<p className="line-clamp-3 break-all leading-tight text-white">
<p className="line-clamp-3 break-all text-sm leading-tight text-white">
{user?.about}
</p>
</div>
@ -124,13 +124,13 @@ export function User({
<div className="flex items-center gap-2 px-3 py-3">
<Link
to={`/users/${pubkey}`}
className="inline-flex h-10 flex-1 items-center justify-center rounded-md bg-white/10 text-sm font-medium backdrop-blur-xl hover:bg-fuchsia-500"
className="inline-flex h-10 flex-1 items-center justify-center rounded-md bg-white/10 text-sm font-semibold backdrop-blur-xl hover:bg-fuchsia-500"
>
View profile
</Link>
<Link
to={`/chats/${pubkey}`}
className="inline-flex h-10 flex-1 items-center justify-center rounded-md bg-white/10 text-sm font-medium backdrop-blur-xl hover:bg-fuchsia-500"
className="inline-flex h-10 flex-1 items-center justify-center rounded-md bg-white/10 text-sm font-semibold backdrop-blur-xl hover:bg-fuchsia-500"
>
Message
</Link>

View File

@ -13,7 +13,7 @@ import { Widget } from '@utils/types';
export function GlobalArticlesWidget({ params }: { params: Widget }) {
const { ndk } = useNDK();
const { status, data } = useQuery(
['global-articles-widget'],
[params.id + '-' + params.title],
async () => {
const events = await ndk.fetchEvents({
kinds: [NDKKind.Article],

View File

@ -13,7 +13,7 @@ import { Widget } from '@utils/types';
export function GlobalFilesWidget({ params }: { params: Widget }) {
const { ndk } = useNDK();
const { status, data } = useQuery(
['global-files-widget'],
[params.id + '-' + params.title],
async () => {
const events = await ndk.fetchEvents({
// @ts-expect-error, NDK not support file metadata yet

View File

@ -22,7 +22,7 @@ import { Widget } from '@utils/types';
export function GlobalHashtagWidget({ params }: { params: Widget }) {
const { ndk } = useNDK();
const { status, data } = useQuery(
['global-hashtag-widget', params.content],
[params.id + '-' + params.title],
async () => {
const events = await ndk.fetchEvents({
kinds: [NDKKind.Text, NDKKind.Repost, NDKKind.Article],

View File

@ -15,7 +15,7 @@ export function LocalArticlesWidget({ params }: { params: Widget }) {
const { db } = useStorage();
const { status, data, hasNextPage, isFetchingNextPage, fetchNextPage } =
useInfiniteQuery({
queryKey: ['local-articles-widget'],
queryKey: [params.id + '-' + params.title],
queryFn: async ({ pageParam = 0 }) => {
return await db.getAllEventsByKinds([NDKKind.Article], 20, pageParam);
},

View File

@ -23,7 +23,7 @@ export function LocalFeedsWidget({ params }: { params: Widget }) {
const { db } = useStorage();
const { status, data, hasNextPage, isFetchingNextPage, fetchNextPage } =
useInfiniteQuery({
queryKey: ['local-feeds-widget', params.content],
queryKey: [params.id + '-' + params.title],
queryFn: async ({ pageParam = 0 }) => {
const authors = JSON.parse(params.content);
return await db.getAllEventsByAuthors(authors, 20, pageParam);
@ -71,7 +71,7 @@ export function LocalFeedsWidget({ params }: { params: Widget }) {
data-index={index}
ref={virtualizer.measureElement}
>
<Repost key={dbEvent.id} event={event} />
<Repost key={dbEvent.id} event={event} root={dbEvent.root_id} />
</div>
);
case 1063:

View File

@ -15,7 +15,7 @@ export function LocalFilesWidget({ params }: { params: Widget }) {
const { db } = useStorage();
const { status, data, hasNextPage, isFetchingNextPage, fetchNextPage } =
useInfiniteQuery({
queryKey: ['local-files-widget'],
queryKey: [params.id + '-' + params.title],
queryFn: async ({ pageParam = 0 }) => {
return await db.getAllEventsByKinds([1063], 20, pageParam);
},

View File

@ -23,7 +23,7 @@ export function LocalFollowsWidget({ params }: { params: Widget }) {
const { db } = useStorage();
const { status, data, hasNextPage, isFetchingNextPage, fetchNextPage } =
useInfiniteQuery({
queryKey: ['local-follows-widget'],
queryKey: [params.id + '-' + params.title],
queryFn: async ({ pageParam = 0 }) => {
return await db.getAllEventsByAuthors(db.account.follows, 20, pageParam);
},
@ -70,7 +70,7 @@ export function LocalFollowsWidget({ params }: { params: Widget }) {
data-index={index}
ref={virtualizer.measureElement}
>
<Repost key={dbEvent.id} event={event} />
<Repost key={dbEvent.id} event={event} root={dbEvent.root_id} />
</div>
);
case 1063:

View File

@ -73,7 +73,7 @@ export function LocalNetworkWidget() {
data-index={index}
ref={virtualizer.measureElement}
>
<Repost key={dbEvent.id} event={event} />
<Repost key={dbEvent.id} event={event} root={dbEvent.root_id} />
</div>
);
case 1063:

View File

@ -23,7 +23,7 @@ import { Widget } from '@utils/types';
export function LocalUserWidget({ params }: { params: Widget }) {
const { ndk } = useNDK();
const { status, data } = useQuery(
['local-user-widget', params.content],
[params.id + '-' + params.title],
async () => {
const events = await ndk.fetchEvents({
kinds: [1, 6],