Skip to content

Commit

Permalink
chore: tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
v0l committed Dec 11, 2023
1 parent 0f6fe23 commit 07e4240
Show file tree
Hide file tree
Showing 5 changed files with 62 additions and 43 deletions.
27 changes: 11 additions & 16 deletions packages/app/src/Element/Embed/MediaElement.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,27 +18,22 @@ export function MediaElement(props: MediaElementProps) {

if (props.mime.startsWith("image/")) {
return (
// constant height container avoids layout shift when images load
<div className="-mx-4 md:mx-0 my-3 md:h-80 flex items-center justify-center">
<ProxyImg key={props.url} src={props.url} onClick={props.onMediaClick} className="max-h-[80vh] md:max-h-80" />
</div>
<ProxyImg key={props.url} src={props.url} onClick={props.onMediaClick} className="max-h-[80vh] mx-auto" />
);
} else if (props.mime.startsWith("audio/")) {
return <audio key={props.url} src={props.url} controls />;
} else if (props.mime.startsWith("video/")) {
return (
<div className="-mx-4 md:mx-0 my-3 md:h-80 flex items-center justify-center">
<video
autoPlay={autoplay}
loop={true}
muted={autoplay}
key={props.url}
src={props.url}
controls
poster={proxy(props.url)}
className="max-h-[80vh] md:max-h-80"
/>
</div>
<video
autoPlay={autoplay}
loop={true}
muted={autoplay}
key={props.url}
src={props.url}
controls
poster={proxy(props.url)}
className="max-h-[80vh] mx-auto"
/>
);
} else {
return (
Expand Down
46 changes: 33 additions & 13 deletions packages/app/src/Pages/DonatePage.tsx
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
import { useEffect, useState } from "react";
import { useEffect, useState, useSyncExternalStore } from "react";
import { FormattedMessage } from "react-intl";
import { HexKey } from "@snort/system";

import { ApiHost, DeveloperAccounts, SnortPubKey } from "@/Const";
import ProfilePreview from "@/Element/User/ProfilePreview";
import ZapButton from "@/Element/Event/ZapButton";
import { bech32ToHex } from "@/SnortUtils";
import { bech32ToHex, unwrap } from "@/SnortUtils";
import SnortApi, { RevenueSplit, RevenueToday } from "@/External/SnortApi";
import Modal from "@/Element/Modal";
import AsyncButton from "@/Element/Button/AsyncButton";
import QrCode from "@/Element/QrCode";
import Copy from "@/Element/Copy";
import { Link } from "react-router-dom";
import { ZapPoolController, ZapPoolRecipientType } from "@/ZapPoolController";
import { ZapPoolTarget } from "./ZapPool";

const Contributors = [
bech32ToHex("npub10djxr5pvdu97rjkde7tgcsjxzpdzmdguwacfjwlchvj7t88dl7nsdl54nf"), // ivan
Expand Down Expand Up @@ -59,6 +61,10 @@ const DonatePage = () => {
const [today, setSumToday] = useState<RevenueToday>();
const [onChain, setOnChain] = useState("");
const api = new SnortApi(ApiHost);
const zapPool = useSyncExternalStore(
c => unwrap(ZapPoolController).hook(c),
() => unwrap(ZapPoolController).snapshot(),
);

async function getOnChainAddress() {
const { address } = await api.onChainDonation();
Expand Down Expand Up @@ -95,14 +101,11 @@ const DonatePage = () => {
</h2>
<p>
<FormattedMessage
defaultMessage="{site} is an open source project built by passionate people in their free time"
id="6TfgXX"
defaultMessage="{site} is an open source project built by passionate people in their free time, your donations are greatly appreciated"
id="XhpBfA"
values={{ site: CONFIG.appNameCapitalized }}
/>
</p>
<p>
<FormattedMessage defaultMessage="Your donations are greatly appreciated" id="nn1qb3" />
</p>
<p>
<FormattedMessage
defaultMessage="Check out the code here: {link}"
Expand All @@ -129,12 +132,6 @@ const DonatePage = () => {
}}
/>
</p>
<p>
<FormattedMessage
defaultMessage="Each contributor will get paid a percentage of all donations and NIP-05 orders, you can see the split amounts below"
id="mH91FY"
/>
</p>
<div className="flex flex-col g12">
<div className="b br p">
<div className="flex items-center justify-between">
Expand Down Expand Up @@ -173,6 +170,29 @@ const DonatePage = () => {
</div>
</Modal>
)}
{CONFIG.features.zapPool && <>
<h3>
<FormattedMessage defaultMessage="ZapPool" id="pRess9" />
</h3>
<p>
<FormattedMessage defaultMessage="Fund the services that you use by splitting a portion of all your zaps into a pool of funds!" id="x/Fx2P" />
</p>
<p>
<Link to="/zap-pool" className="underline">
<FormattedMessage defaultMessage="Configure zap pool" id="kqPQJD" />
</Link>
</p>
<ZapPoolTarget
target={
zapPool.find(b => b.pubkey === bech32ToHex(SnortPubKey) && b.type === ZapPoolRecipientType.Generic) ?? {
type: ZapPoolRecipientType.Generic,
pubkey: bech32ToHex(SnortPubKey),
split: 0,
sum: 0,
}
}
/>
</>}
<h3>
<FormattedMessage defaultMessage="Primary Developers" id="4IPzdn" />
</h3>
Expand Down
2 changes: 1 addition & 1 deletion packages/app/src/Pages/Layout/NavSidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ export default function NavSidebar({ narrow = false }) {
<div
className={classNames(
{ "xl:items-start": !narrow, "xl:gap-2": !narrow },
"gap-1 flex flex-col items-center text-lg",
"gap-1 flex flex-col items-center text-lg font-bold",
)}>
{MENU_ITEMS.filter(a => {
if ((CONFIG.hideFromNavbar ?? []).includes(a.link)) {
Expand Down
20 changes: 12 additions & 8 deletions packages/app/src/Pages/Profile/ProfilePage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ import { useMuteList, usePinList } from "@/Hooks/useLists";

import messages from "../messages";
import FollowedBy from "@/Element/User/FollowedBy";
import AsyncButton from "@/Element/Button/AsyncButton";

interface ProfilePageProps {
id?: string;
Expand Down Expand Up @@ -192,14 +193,14 @@ export default function ProfilePage({ id: propId, state }: ProfilePageProps) {
targets={
lnurl?.lnurl && id
? [
{
type: "lnurl",
value: lnurl?.lnurl,
weight: 1,
name: user?.display_name || user?.name,
zap: { pubkey: id },
} as ZapTarget,
]
{
type: "lnurl",
value: lnurl?.lnurl,
weight: 1,
name: user?.display_name || user?.name,
zap: { pubkey: id },
} as ZapTarget,
]
: undefined
}
show={showLnQr}
Expand Down Expand Up @@ -299,6 +300,9 @@ export default function ProfilePage({ id: propId, state }: ProfilePageProps) {
<div className="profile-actions">
{renderIcons()}
{!isMe && id && <FollowButton pubkey={id} />}
{isMe && id && <AsyncButton className="secondary">
<FormattedMessage defaultMessage="Edit" id="wEQDC6" />
</AsyncButton>}
</div>
</div>
);
Expand Down
10 changes: 5 additions & 5 deletions packages/app/src/Pages/ZapPool.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ const DataProviders = [
},
];

function ZapTarget({ target }: { target: ZapPoolRecipient }) {
export function ZapPoolTarget({ target }: { target: ZapPoolRecipient }) {
if (!ZapPoolController) return;
const login = useLogin();
const profile = useUserProfile(target.pubkey);
Expand Down Expand Up @@ -158,7 +158,7 @@ export default function ZapPoolPage() {
)}
</p>
<div>
<ZapTarget
<ZapPoolTarget
target={
zapPool.find(b => b.pubkey === bech32ToHex(SnortPubKey) && b.type === ZapPoolRecipientType.Generic) ?? {
type: ZapPoolRecipientType.Generic,
Expand All @@ -175,7 +175,7 @@ export default function ZapPoolPage() {
{relayConnections.map(a => (
<div>
<h4>{getRelayName(a.address)}</h4>
<ZapTarget
<ZapPoolTarget
target={
zapPool.find(b => b.pubkey === a.pubkey && b.type === ZapPoolRecipientType.Relay) ?? {
type: ZapPoolRecipientType.Relay,
Expand All @@ -193,7 +193,7 @@ export default function ZapPoolPage() {
{UploaderServices.map(a => (
<div>
<h4>{a.name}</h4>
<ZapTarget
<ZapPoolTarget
target={
zapPool.find(b => b.pubkey === a.owner && b.type === ZapPoolRecipientType.FileHost) ?? {
type: ZapPoolRecipientType.FileHost,
Expand All @@ -211,7 +211,7 @@ export default function ZapPoolPage() {
{DataProviders.map(a => (
<div>
<h4>{a.name}</h4>
<ZapTarget
<ZapPoolTarget
target={
zapPool.find(b => b.pubkey === a.owner && b.type === ZapPoolRecipientType.DataProvider) ?? {
type: ZapPoolRecipientType.DataProvider,
Expand Down

0 comments on commit 07e4240

Please sign in to comment.