mirror of
https://github.com/aljazceru/mutiny-web.git
synced 2026-01-29 19:14:19 +01:00
Sync nostr contacts
This commit is contained in:
committed by
Paul Miller
parent
749bf6313d
commit
62b0ff1cad
@@ -46,6 +46,7 @@ export const ActivityAmount: ParentComponent<{
|
||||
|
||||
function LabelCircle(props: {
|
||||
name?: string;
|
||||
image_url?: string;
|
||||
contact: boolean;
|
||||
label: boolean;
|
||||
channel?: HackActivityType;
|
||||
@@ -72,6 +73,9 @@ function LabelCircle(props: {
|
||||
style={{ background: bg() }}
|
||||
>
|
||||
<Switch>
|
||||
<Match when={props.image_url}>
|
||||
<img src={props.image_url} alt={"image"} />
|
||||
</Match>
|
||||
<Match when={props.channel === "ChannelOpen"}>
|
||||
<img src={on} alt="channel open" />
|
||||
</Match>
|
||||
@@ -134,6 +138,7 @@ export function ActivityItem(props: {
|
||||
<div class="">
|
||||
<LabelCircle
|
||||
name={firstContact()?.name}
|
||||
image_url={firstContact()?.image_url}
|
||||
contact={props.contacts?.length > 0}
|
||||
label={props.labels?.length > 0}
|
||||
channel={props.kind}
|
||||
|
||||
@@ -45,13 +45,18 @@ export function ContactViewer(props: {
|
||||
onClick={() => setIsOpen(true)}
|
||||
class="flex w-16 flex-shrink-0 flex-col items-center gap-2 overflow-x-hidden"
|
||||
>
|
||||
<div
|
||||
class="flex h-16 w-16 flex-none items-center justify-center rounded-full border-b border-t border-b-white/10 border-t-white/50 text-4xl uppercase"
|
||||
style={{ background: props.gradient }}
|
||||
>
|
||||
{props.contact.name[0]}
|
||||
</div>
|
||||
<SmallHeader class="h-4 w-16 overflow-hidden overflow-ellipsis text-center">
|
||||
{props.contact.image_url && (
|
||||
<img src={props.contact.image_url} />
|
||||
)}
|
||||
{!props.contact.image_url && (
|
||||
<div
|
||||
class="flex-none h-16 w-16 rounded-full flex items-center justify-center text-4xl uppercase border-t border-b border-t-white/50 border-b-white/10"
|
||||
style={{ background: props.gradient }}
|
||||
>
|
||||
{props.contact.name[0]}
|
||||
</div>
|
||||
)}
|
||||
<SmallHeader class="overflow-ellipsis w-16 text-center overflow-hidden h-4">
|
||||
{props.contact.name}
|
||||
</SmallHeader>
|
||||
</button>
|
||||
@@ -86,19 +91,35 @@ export function ContactViewer(props: {
|
||||
/>
|
||||
</Match>
|
||||
<Match when={!isEditing()}>
|
||||
<div class="mx-auto flex w-full max-w-[400px] flex-1 flex-col items-center justify-around gap-4">
|
||||
<div class="flex w-full flex-col items-center">
|
||||
<div
|
||||
class="flex h-32 w-32 flex-none items-center justify-center rounded-full border-b border-t border-b-white/10 border-t-white/50 text-8xl uppercase"
|
||||
style={{
|
||||
background: props.gradient
|
||||
}}
|
||||
>
|
||||
{props.contact.name[0]}
|
||||
</div>
|
||||
<h1 class="mb-4 mt-2 text-2xl font-semibold uppercase">
|
||||
<div class="flex flex-col flex-1 justify-around items-center gap-4 max-w-[400px] mx-auto w-full">
|
||||
<div class="flex flex-col items-center w-full">
|
||||
{props.contact.image_url && (
|
||||
<img
|
||||
src={props.contact.image_url}
|
||||
/>
|
||||
)}
|
||||
{!props.contact.image_url && (
|
||||
<div
|
||||
class="flex-none h-32 w-32 rounded-full flex items-center justify-center text-8xl uppercase border-t border-b border-t-white/50 border-b-white/10"
|
||||
style={{
|
||||
background: props.gradient
|
||||
}}
|
||||
>
|
||||
{props.contact.name[0]}
|
||||
</div>
|
||||
)}
|
||||
<h1 class="text-2xl font-semibold uppercase mt-2 mb-4">
|
||||
{props.contact.name}
|
||||
</h1>
|
||||
<h1 class="text-2xl font-semibold uppercase mt-2 mb-4">
|
||||
{props.contact.npub}
|
||||
</h1>
|
||||
<h1 class="text-2xl font-semibold uppercase mt-2 mb-4">
|
||||
{props.contact.ln_address}
|
||||
</h1>
|
||||
<h1 class="text-2xl font-semibold uppercase mt-2 mb-4">
|
||||
{props.contact.lnurl}
|
||||
</h1>
|
||||
<Card
|
||||
title={i18n.t(
|
||||
"contacts.payment_history"
|
||||
|
||||
63
src/routes/settings/SyncNostrContacts.tsx
Normal file
63
src/routes/settings/SyncNostrContacts.tsx
Normal file
@@ -0,0 +1,63 @@
|
||||
import { TextField } from "@kobalte/core";
|
||||
import { createSignal } from "solid-js";
|
||||
import NavBar from "~/components/NavBar";
|
||||
import {
|
||||
Button,
|
||||
DefaultMain,
|
||||
InnerCard,
|
||||
LargeHeader,
|
||||
MutinyWalletGuard,
|
||||
SafeArea
|
||||
} from "~/components/layout";
|
||||
import { BackLink } from "~/components/layout/BackLink";
|
||||
import { useMegaStore } from "~/state/megaStore";
|
||||
|
||||
export default function SyncNostrContacts() {
|
||||
const [state, _] = useMegaStore();
|
||||
|
||||
const [value, setValue] = createSignal("");
|
||||
|
||||
const onSubmit = async (e: SubmitEvent) => {
|
||||
e.preventDefault();
|
||||
|
||||
const npub = value().trim();
|
||||
await state.mutiny_wallet?.sync_nostr_contacts(npub);
|
||||
|
||||
setValue("");
|
||||
};
|
||||
|
||||
return (
|
||||
<MutinyWalletGuard>
|
||||
<SafeArea>
|
||||
<DefaultMain>
|
||||
<BackLink href="/settings" title="Settings" />
|
||||
<LargeHeader>Sync Nostr Contacts</LargeHeader>
|
||||
<InnerCard>
|
||||
<form class="flex flex-col gap-4" onSubmit={onSubmit}>
|
||||
<TextField.Root
|
||||
value={value()}
|
||||
onChange={setValue}
|
||||
class="flex flex-col gap-4"
|
||||
>
|
||||
<TextField.Label class="text-sm font-semibold uppercase">
|
||||
Sync Nostr Contacts
|
||||
</TextField.Label>
|
||||
<TextField.Input
|
||||
class="w-full p-2 rounded-lg text-black"
|
||||
// placeholder="LNURL..."
|
||||
/>
|
||||
<TextField.ErrorMessage class="text-red-500">
|
||||
Doesn't look right...
|
||||
</TextField.ErrorMessage>
|
||||
</TextField.Root>
|
||||
<Button layout="small" type="submit">
|
||||
Sync
|
||||
</Button>
|
||||
</form>
|
||||
</InnerCard>
|
||||
</DefaultMain>
|
||||
<NavBar activeTab="settings" />
|
||||
</SafeArea>
|
||||
</MutinyWalletGuard>
|
||||
);
|
||||
}
|
||||
@@ -120,6 +120,10 @@ export default function Settings() {
|
||||
{
|
||||
href: "/settings/lnurlauth",
|
||||
text: i18n.t("settings.lnurl_auth.title")
|
||||
},
|
||||
{
|
||||
href: "/settings/syncnostrcontacts",
|
||||
text: "Sync Nostr Contacts"
|
||||
}
|
||||
]}
|
||||
/>
|
||||
|
||||
Reference in New Issue
Block a user