mirror of
https://github.com/luminous-devs/lume.git
synced 2024-09-19 11:43:30 +00:00
small fixes
This commit is contained in:
parent
fa0d7cac31
commit
5a6dd172b1
@ -60,7 +60,7 @@ export function NotificationScreen() {
|
|||||||
<p className="text-sm font-medium text-white/50">Loading</p>
|
<p className="text-sm font-medium text-white/50">Loading</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
) : activities.length < 1 ? (
|
) : activities.length <= 1 ? (
|
||||||
<div className="flex h-full w-full flex-col items-center justify-center">
|
<div className="flex h-full w-full flex-col items-center justify-center">
|
||||||
<p className="mb-1 text-4xl">🎉</p>
|
<p className="mb-1 text-4xl">🎉</p>
|
||||||
<p className="font-medium text-white/50">
|
<p className="font-medium text-white/50">
|
||||||
|
@ -19,7 +19,7 @@ export function AccountMoreActions({ pubkey }: { pubkey: string }) {
|
|||||||
</button>
|
</button>
|
||||||
</DropdownMenu.Trigger>
|
</DropdownMenu.Trigger>
|
||||||
<DropdownMenu.Portal>
|
<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>
|
<DropdownMenu.Item asChild>
|
||||||
<Link
|
<Link
|
||||||
to={`/users/${pubkey}`}
|
to={`/users/${pubkey}`}
|
||||||
|
@ -45,7 +45,7 @@ export function MoreActions({ id, pubkey }: { id: string; pubkey: string }) {
|
|||||||
</Tooltip.Portal>
|
</Tooltip.Portal>
|
||||||
</Tooltip.Root>
|
</Tooltip.Root>
|
||||||
<DropdownMenu.Portal>
|
<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>
|
<DropdownMenu.Item asChild>
|
||||||
<button
|
<button
|
||||||
type="button"
|
type="button"
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
import { NDKKind } from '@nostr-dev-kit/ndk';
|
||||||
import * as Popover from '@radix-ui/react-popover';
|
import * as Popover from '@radix-ui/react-popover';
|
||||||
import { useState } from 'react';
|
import { useState } from 'react';
|
||||||
|
|
||||||
@ -44,7 +45,7 @@ export function NoteReaction({ id, pubkey }: { id: string; pubkey: string }) {
|
|||||||
|
|
||||||
const event = await publish({
|
const event = await publish({
|
||||||
content: content,
|
content: content,
|
||||||
kind: 7,
|
kind: NDKKind.Reaction,
|
||||||
tags: [
|
tags: [
|
||||||
['e', id],
|
['e', id],
|
||||||
['p', pubkey],
|
['p', pubkey],
|
||||||
|
@ -1,25 +1,39 @@
|
|||||||
|
import { NDKKind } from '@nostr-dev-kit/ndk';
|
||||||
import * as AlertDialog from '@radix-ui/react-alert-dialog';
|
import * as AlertDialog from '@radix-ui/react-alert-dialog';
|
||||||
import * as Tooltip from '@radix-ui/react-tooltip';
|
import * as Tooltip from '@radix-ui/react-tooltip';
|
||||||
|
import { message } from '@tauri-apps/api/dialog';
|
||||||
import { useState } from 'react';
|
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 { useNostr } from '@utils/hooks/useNostr';
|
||||||
|
import { sendNativeNotification } from '@utils/notification';
|
||||||
|
|
||||||
export function NoteRepost({ id, pubkey }: { id: string; pubkey: string }) {
|
export function NoteRepost({ id, pubkey }: { id: string; pubkey: string }) {
|
||||||
const { publish } = useNostr();
|
const { publish } = useNostr();
|
||||||
|
const { relayUrls } = useNDK();
|
||||||
|
|
||||||
const [open, setOpen] = useState(false);
|
const [open, setOpen] = useState(false);
|
||||||
|
const [isLoading, setIsLoading] = useState(false);
|
||||||
|
const [isRepost, setIsRepost] = useState(false);
|
||||||
|
|
||||||
const submit = async () => {
|
const submit = async () => {
|
||||||
|
setIsLoading(true);
|
||||||
const tags = [
|
const tags = [
|
||||||
['e', id, 'wss://relayable.org', 'root'],
|
['e', id, relayUrls[0], 'root'],
|
||||||
['p', pubkey],
|
['p', pubkey],
|
||||||
];
|
];
|
||||||
const event = await publish({ content: '', kind: 6, tags: tags });
|
const event = await publish({ content: '', kind: NDKKind.Repost, tags: tags });
|
||||||
if (event) {
|
if (event) {
|
||||||
setOpen(false);
|
setOpen(false);
|
||||||
|
setIsRepost(true);
|
||||||
|
await sendNativeNotification('Reposted successfully', 'Lume');
|
||||||
} else {
|
} 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"
|
type="button"
|
||||||
className="group inline-flex h-7 w-7 items-center justify-center"
|
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>
|
</button>
|
||||||
</AlertDialog.Trigger>
|
</AlertDialog.Trigger>
|
||||||
</Tooltip.Trigger>
|
</Tooltip.Trigger>
|
||||||
@ -56,18 +75,22 @@ export function NoteRepost({ id, pubkey }: { id: string; pubkey: string }) {
|
|||||||
action.
|
action.
|
||||||
</AlertDialog.Description>
|
</AlertDialog.Description>
|
||||||
</div>
|
</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>
|
<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
|
Cancel
|
||||||
</button>
|
</button>
|
||||||
</AlertDialog.Cancel>
|
</AlertDialog.Cancel>
|
||||||
<button
|
<button
|
||||||
type="button"
|
type="button"
|
||||||
onClick={() => submit()}
|
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>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -19,8 +19,8 @@ import { compactNumber } from '@utils/number';
|
|||||||
|
|
||||||
export function NoteZap({ id, pubkey }: { id: string; pubkey: string }) {
|
export function NoteZap({ id, pubkey }: { id: string; pubkey: string }) {
|
||||||
const { createZap } = useNostr();
|
const { createZap } = useNostr();
|
||||||
const { data: event } = useEvent(id);
|
|
||||||
const { user } = useProfile(pubkey);
|
const { user } = useProfile(pubkey);
|
||||||
|
const { data: event } = useEvent(id);
|
||||||
|
|
||||||
const [amount, setAmount] = useState<string>('21');
|
const [amount, setAmount] = useState<string>('21');
|
||||||
const [zapMessage, setZapMessage] = useState<string>('');
|
const [zapMessage, setZapMessage] = useState<string>('');
|
||||||
|
@ -17,9 +17,9 @@ import { User } from '@shared/user';
|
|||||||
|
|
||||||
import { useEvent } from '@utils/hooks/useEvent';
|
import { useEvent } from '@utils/hooks/useEvent';
|
||||||
|
|
||||||
export function Repost({ event }: { event: NDKEvent }) {
|
export function Repost({ event, root }: { event: NDKEvent; root?: string }) {
|
||||||
// @ts-expect-error, root_id isn't exist on NDKEvent
|
const rootPost = root ?? event.tags.find((el) => el[0] === 'e')?.[1];
|
||||||
const { status, data } = useEvent(event.root_id ?? event.id, event.content);
|
const { status, data } = useEvent(rootPost, event.content);
|
||||||
|
|
||||||
const renderKind = useCallback(
|
const renderKind = useCallback(
|
||||||
(repostEvent: NDKEvent) => {
|
(repostEvent: NDKEvent) => {
|
||||||
|
@ -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"
|
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">
|
<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)}
|
{user?.name || user?.display_name || shortenKey(pubkey)}
|
||||||
</h5>
|
</h5>
|
||||||
<span className="text-white/50">reposted</span>
|
<span className="text-white/50">reposted</span>
|
||||||
|
@ -88,7 +88,7 @@ export function User({
|
|||||||
</div>
|
</div>
|
||||||
<Popover.Portal>
|
<Popover.Portal>
|
||||||
<Popover.Content
|
<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}
|
sideOffset={5}
|
||||||
>
|
>
|
||||||
<div className="flex gap-2.5 border-b border-white/5 px-3 py-3">
|
<div className="flex gap-2.5 border-b border-white/5 px-3 py-3">
|
||||||
@ -115,7 +115,7 @@ export function User({
|
|||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
<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}
|
{user?.about}
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
@ -124,13 +124,13 @@ export function User({
|
|||||||
<div className="flex items-center gap-2 px-3 py-3">
|
<div className="flex items-center gap-2 px-3 py-3">
|
||||||
<Link
|
<Link
|
||||||
to={`/users/${pubkey}`}
|
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
|
View profile
|
||||||
</Link>
|
</Link>
|
||||||
<Link
|
<Link
|
||||||
to={`/chats/${pubkey}`}
|
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
|
Message
|
||||||
</Link>
|
</Link>
|
||||||
|
@ -13,7 +13,7 @@ import { Widget } from '@utils/types';
|
|||||||
export function GlobalArticlesWidget({ params }: { params: Widget }) {
|
export function GlobalArticlesWidget({ params }: { params: Widget }) {
|
||||||
const { ndk } = useNDK();
|
const { ndk } = useNDK();
|
||||||
const { status, data } = useQuery(
|
const { status, data } = useQuery(
|
||||||
['global-articles-widget'],
|
[params.id + '-' + params.title],
|
||||||
async () => {
|
async () => {
|
||||||
const events = await ndk.fetchEvents({
|
const events = await ndk.fetchEvents({
|
||||||
kinds: [NDKKind.Article],
|
kinds: [NDKKind.Article],
|
||||||
|
@ -13,7 +13,7 @@ import { Widget } from '@utils/types';
|
|||||||
export function GlobalFilesWidget({ params }: { params: Widget }) {
|
export function GlobalFilesWidget({ params }: { params: Widget }) {
|
||||||
const { ndk } = useNDK();
|
const { ndk } = useNDK();
|
||||||
const { status, data } = useQuery(
|
const { status, data } = useQuery(
|
||||||
['global-files-widget'],
|
[params.id + '-' + params.title],
|
||||||
async () => {
|
async () => {
|
||||||
const events = await ndk.fetchEvents({
|
const events = await ndk.fetchEvents({
|
||||||
// @ts-expect-error, NDK not support file metadata yet
|
// @ts-expect-error, NDK not support file metadata yet
|
||||||
|
@ -22,7 +22,7 @@ import { Widget } from '@utils/types';
|
|||||||
export function GlobalHashtagWidget({ params }: { params: Widget }) {
|
export function GlobalHashtagWidget({ params }: { params: Widget }) {
|
||||||
const { ndk } = useNDK();
|
const { ndk } = useNDK();
|
||||||
const { status, data } = useQuery(
|
const { status, data } = useQuery(
|
||||||
['global-hashtag-widget', params.content],
|
[params.id + '-' + params.title],
|
||||||
async () => {
|
async () => {
|
||||||
const events = await ndk.fetchEvents({
|
const events = await ndk.fetchEvents({
|
||||||
kinds: [NDKKind.Text, NDKKind.Repost, NDKKind.Article],
|
kinds: [NDKKind.Text, NDKKind.Repost, NDKKind.Article],
|
||||||
|
@ -15,7 +15,7 @@ export function LocalArticlesWidget({ params }: { params: Widget }) {
|
|||||||
const { db } = useStorage();
|
const { db } = useStorage();
|
||||||
const { status, data, hasNextPage, isFetchingNextPage, fetchNextPage } =
|
const { status, data, hasNextPage, isFetchingNextPage, fetchNextPage } =
|
||||||
useInfiniteQuery({
|
useInfiniteQuery({
|
||||||
queryKey: ['local-articles-widget'],
|
queryKey: [params.id + '-' + params.title],
|
||||||
queryFn: async ({ pageParam = 0 }) => {
|
queryFn: async ({ pageParam = 0 }) => {
|
||||||
return await db.getAllEventsByKinds([NDKKind.Article], 20, pageParam);
|
return await db.getAllEventsByKinds([NDKKind.Article], 20, pageParam);
|
||||||
},
|
},
|
||||||
|
@ -23,7 +23,7 @@ export function LocalFeedsWidget({ params }: { params: Widget }) {
|
|||||||
const { db } = useStorage();
|
const { db } = useStorage();
|
||||||
const { status, data, hasNextPage, isFetchingNextPage, fetchNextPage } =
|
const { status, data, hasNextPage, isFetchingNextPage, fetchNextPage } =
|
||||||
useInfiniteQuery({
|
useInfiniteQuery({
|
||||||
queryKey: ['local-feeds-widget', params.content],
|
queryKey: [params.id + '-' + params.title],
|
||||||
queryFn: async ({ pageParam = 0 }) => {
|
queryFn: async ({ pageParam = 0 }) => {
|
||||||
const authors = JSON.parse(params.content);
|
const authors = JSON.parse(params.content);
|
||||||
return await db.getAllEventsByAuthors(authors, 20, pageParam);
|
return await db.getAllEventsByAuthors(authors, 20, pageParam);
|
||||||
@ -71,7 +71,7 @@ export function LocalFeedsWidget({ params }: { params: Widget }) {
|
|||||||
data-index={index}
|
data-index={index}
|
||||||
ref={virtualizer.measureElement}
|
ref={virtualizer.measureElement}
|
||||||
>
|
>
|
||||||
<Repost key={dbEvent.id} event={event} />
|
<Repost key={dbEvent.id} event={event} root={dbEvent.root_id} />
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
case 1063:
|
case 1063:
|
||||||
|
@ -15,7 +15,7 @@ export function LocalFilesWidget({ params }: { params: Widget }) {
|
|||||||
const { db } = useStorage();
|
const { db } = useStorage();
|
||||||
const { status, data, hasNextPage, isFetchingNextPage, fetchNextPage } =
|
const { status, data, hasNextPage, isFetchingNextPage, fetchNextPage } =
|
||||||
useInfiniteQuery({
|
useInfiniteQuery({
|
||||||
queryKey: ['local-files-widget'],
|
queryKey: [params.id + '-' + params.title],
|
||||||
queryFn: async ({ pageParam = 0 }) => {
|
queryFn: async ({ pageParam = 0 }) => {
|
||||||
return await db.getAllEventsByKinds([1063], 20, pageParam);
|
return await db.getAllEventsByKinds([1063], 20, pageParam);
|
||||||
},
|
},
|
||||||
|
@ -23,7 +23,7 @@ export function LocalFollowsWidget({ params }: { params: Widget }) {
|
|||||||
const { db } = useStorage();
|
const { db } = useStorage();
|
||||||
const { status, data, hasNextPage, isFetchingNextPage, fetchNextPage } =
|
const { status, data, hasNextPage, isFetchingNextPage, fetchNextPage } =
|
||||||
useInfiniteQuery({
|
useInfiniteQuery({
|
||||||
queryKey: ['local-follows-widget'],
|
queryKey: [params.id + '-' + params.title],
|
||||||
queryFn: async ({ pageParam = 0 }) => {
|
queryFn: async ({ pageParam = 0 }) => {
|
||||||
return await db.getAllEventsByAuthors(db.account.follows, 20, pageParam);
|
return await db.getAllEventsByAuthors(db.account.follows, 20, pageParam);
|
||||||
},
|
},
|
||||||
@ -70,7 +70,7 @@ export function LocalFollowsWidget({ params }: { params: Widget }) {
|
|||||||
data-index={index}
|
data-index={index}
|
||||||
ref={virtualizer.measureElement}
|
ref={virtualizer.measureElement}
|
||||||
>
|
>
|
||||||
<Repost key={dbEvent.id} event={event} />
|
<Repost key={dbEvent.id} event={event} root={dbEvent.root_id} />
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
case 1063:
|
case 1063:
|
||||||
|
@ -73,7 +73,7 @@ export function LocalNetworkWidget() {
|
|||||||
data-index={index}
|
data-index={index}
|
||||||
ref={virtualizer.measureElement}
|
ref={virtualizer.measureElement}
|
||||||
>
|
>
|
||||||
<Repost key={dbEvent.id} event={event} />
|
<Repost key={dbEvent.id} event={event} root={dbEvent.root_id} />
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
case 1063:
|
case 1063:
|
||||||
|
@ -23,7 +23,7 @@ import { Widget } from '@utils/types';
|
|||||||
export function LocalUserWidget({ params }: { params: Widget }) {
|
export function LocalUserWidget({ params }: { params: Widget }) {
|
||||||
const { ndk } = useNDK();
|
const { ndk } = useNDK();
|
||||||
const { status, data } = useQuery(
|
const { status, data } = useQuery(
|
||||||
['local-user-widget', params.content],
|
[params.id + '-' + params.title],
|
||||||
async () => {
|
async () => {
|
||||||
const events = await ndk.fetchEvents({
|
const events = await ndk.fetchEvents({
|
||||||
kinds: [1, 6],
|
kinds: [1, 6],
|
||||||
|
Loading…
Reference in New Issue
Block a user