small fixes
This commit is contained in:
@@ -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>
|
||||
|
||||
Reference in New Issue
Block a user