show only 1 task at a time
This commit is contained in:
@ -8,7 +8,7 @@ import { FormattedMessage, useIntl } from "react-intl";
|
|||||||
import { useLongPress } from "use-long-press";
|
import { useLongPress } from "use-long-press";
|
||||||
|
|
||||||
import { AsyncIcon, AsyncIconProps } from "@/Components/Button/AsyncIcon";
|
import { AsyncIcon, AsyncIconProps } from "@/Components/Button/AsyncIcon";
|
||||||
import { ZapsSummary } from "@/Components/Event/Zap";
|
import { ZapsSummary } from "@/Components/Event/ZapsSummary";
|
||||||
import Icon from "@/Components/Icons/Icon";
|
import Icon from "@/Components/Icons/Icon";
|
||||||
import SendSats from "@/Components/SendSats/SendSats";
|
import SendSats from "@/Components/SendSats/SendSats";
|
||||||
import useEventPublisher from "@/Hooks/useEventPublisher";
|
import useEventPublisher from "@/Hooks/useEventPublisher";
|
||||||
|
@ -1,8 +1,7 @@
|
|||||||
import "./Zap.css";
|
import "./Zap.css";
|
||||||
|
|
||||||
import { ParsedZap } from "@snort/system";
|
import { ParsedZap } from "@snort/system";
|
||||||
import { useMemo } from "react";
|
import { FormattedMessage } from "react-intl";
|
||||||
import { FormattedMessage, useIntl } from "react-intl";
|
|
||||||
|
|
||||||
import Text from "@/Components/Text/Text";
|
import Text from "@/Components/Text/Text";
|
||||||
import ProfileImage from "@/Components/User/ProfileImage";
|
import ProfileImage from "@/Components/User/ProfileImage";
|
||||||
@ -32,49 +31,4 @@ const Zap = ({ zap, showZapped = true }: { zap: ParsedZap; showZapped?: boolean
|
|||||||
) : null;
|
) : null;
|
||||||
};
|
};
|
||||||
|
|
||||||
interface ZapsSummaryProps {
|
|
||||||
zaps: ParsedZap[];
|
|
||||||
}
|
|
||||||
|
|
||||||
export const ZapsSummary = ({ zaps }: ZapsSummaryProps) => {
|
|
||||||
const { formatMessage } = useIntl();
|
|
||||||
const sortedZaps = useMemo(() => {
|
|
||||||
const pub = [...zaps.filter(z => z.sender && z.valid)];
|
|
||||||
const priv = [...zaps.filter(z => !z.sender && z.valid)];
|
|
||||||
pub.sort((a, b) => b.amount - a.amount);
|
|
||||||
return pub.concat(priv);
|
|
||||||
}, [zaps]);
|
|
||||||
|
|
||||||
if (zaps.length === 0) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
const [topZap, ...restZaps] = sortedZaps;
|
|
||||||
const { sender, amount, anonZap } = topZap;
|
|
||||||
|
|
||||||
return (
|
|
||||||
<div className="zaps-summary">
|
|
||||||
{amount && (
|
|
||||||
<div className={`top-zap`}>
|
|
||||||
<div className="summary">
|
|
||||||
{sender && (
|
|
||||||
<ProfileImage
|
|
||||||
pubkey={anonZap ? "" : sender}
|
|
||||||
showFollowDistance={false}
|
|
||||||
overrideUsername={anonZap ? formatMessage({ defaultMessage: "Anonymous", id: "LXxsbk" }) : undefined}
|
|
||||||
/>
|
|
||||||
)}
|
|
||||||
{restZaps.length > 0 ? (
|
|
||||||
<FormattedMessage {...messages.Others} values={{ n: restZaps.length }} />
|
|
||||||
) : (
|
|
||||||
<FormattedMessage {...messages.Zapped} />
|
|
||||||
)}{" "}
|
|
||||||
<FormattedMessage {...messages.OthersZapped} values={{ n: restZaps.length }} />
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
export default Zap;
|
export default Zap;
|
||||||
|
50
packages/app/src/Components/Event/ZapsSummary.tsx
Normal file
50
packages/app/src/Components/Event/ZapsSummary.tsx
Normal file
@ -0,0 +1,50 @@
|
|||||||
|
import { ParsedZap } from "@snort/system";
|
||||||
|
import { useMemo } from "react";
|
||||||
|
import { FormattedMessage, useIntl } from "react-intl";
|
||||||
|
|
||||||
|
import messages from "@/Components/messages";
|
||||||
|
import ProfileImage from "@/Components/User/ProfileImage";
|
||||||
|
|
||||||
|
interface ZapsSummaryProps {
|
||||||
|
zaps: ParsedZap[];
|
||||||
|
}
|
||||||
|
export const ZapsSummary = ({ zaps }: ZapsSummaryProps) => {
|
||||||
|
const { formatMessage } = useIntl();
|
||||||
|
const sortedZaps = useMemo(() => {
|
||||||
|
const pub = [...zaps.filter(z => z.sender && z.valid)];
|
||||||
|
const priv = [...zaps.filter(z => !z.sender && z.valid)];
|
||||||
|
pub.sort((a, b) => b.amount - a.amount);
|
||||||
|
return pub.concat(priv);
|
||||||
|
}, [zaps]);
|
||||||
|
|
||||||
|
if (zaps.length === 0) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
const [topZap, ...restZaps] = sortedZaps;
|
||||||
|
const { sender, amount, anonZap } = topZap;
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className="zaps-summary">
|
||||||
|
{amount && (
|
||||||
|
<div className={`top-zap`}>
|
||||||
|
<div className="summary">
|
||||||
|
{sender && (
|
||||||
|
<ProfileImage
|
||||||
|
pubkey={anonZap ? "" : sender}
|
||||||
|
showFollowDistance={false}
|
||||||
|
overrideUsername={anonZap ? formatMessage({ defaultMessage: "Anonymous", id: "LXxsbk" }) : undefined}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
{restZaps.length > 0 ? (
|
||||||
|
<FormattedMessage {...messages.Others} values={{ n: restZaps.length }} />
|
||||||
|
) : (
|
||||||
|
<FormattedMessage {...messages.Zapped} />
|
||||||
|
)}{" "}
|
||||||
|
<FormattedMessage {...messages.OthersZapped} values={{ n: restZaps.length }} />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
};
|
@ -54,6 +54,7 @@ export const TaskList = () => {
|
|||||||
<div className="task-list">
|
<div className="task-list">
|
||||||
{tasks
|
{tasks
|
||||||
.filter(a => (user ? a.check(user, session) : false))
|
.filter(a => (user ? a.check(user, session) : false))
|
||||||
|
.slice(0, 1)
|
||||||
.map(a => {
|
.map(a => {
|
||||||
if (a.noBaseStyle) {
|
if (a.noBaseStyle) {
|
||||||
return <Fragment key={a.id}>{a.render()}</Fragment>;
|
return <Fragment key={a.id}>{a.render()}</Fragment>;
|
||||||
|
Reference in New Issue
Block a user