Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 25 additions & 15 deletions components/brain/left-sidebar/waves/MemesWaveFooter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,19 +23,31 @@ const MemesWaveFooter: React.FC<MemesWaveFooterProps> = ({
onOpenQuickVote,
onPrefetchQuickVote,
}) => {
const { isReady, uncastPower, unratedCount, votingLabel } =
const { isAvailable, isReady, uncastPower, unratedCount, votingLabel } =
useMemesWaveFooterStats();
const buttonAriaLabel =
isReady && typeof uncastPower === "number"
? `Uncast Power, ${formatNumberWithCommas(uncastPower)} ${
votingLabel ?? "Votes"
} left, ${formatNumberWithCommas(unratedCount)} unrated`
: "Quick vote";
const buttonTitle = isReady ? "Uncast votes" : "Quick vote";
const votingPowerLabel = votingLabel ? ` ${votingLabel}` : " votes";
const buttonValue =
isReady && typeof uncastPower === "number"
? `${formatNumberWithCommas(uncastPower)}${votingPowerLabel}`
: "Open quick vote";

const handleOpenQuickVote = () => {
if (unratedCount <= 0) {
if (!isAvailable) {
return;
}

onOpenQuickVote();
};

const handlePrefetchQuickVote = () => {
if (unratedCount <= 0) {
if (!isAvailable) {
return;
}

Expand All @@ -44,7 +56,7 @@ const MemesWaveFooter: React.FC<MemesWaveFooterProps> = ({

return (
<AnimatePresence>
{isReady && typeof uncastPower === "number" && (
{isAvailable && (
<motion.div
initial={{ opacity: 0, y: 16 }}
animate={{ opacity: 1, y: 0 }}
Expand All @@ -58,18 +70,15 @@ const MemesWaveFooter: React.FC<MemesWaveFooterProps> = ({
>
{collapsed ? (
<MemesWaveQuickVoteTrigger
isAvailable={isAvailable}
onOpenQuickVote={handleOpenQuickVote}
onPrefetchQuickVote={handlePrefetchQuickVote}
unratedCount={unratedCount}
/>
) : (
<button
type="button"
aria-label={`Uncast Power, ${formatNumberWithCommas(
uncastPower
)} ${votingLabel ?? "Votes"} left, ${formatNumberWithCommas(
unratedCount
)} unexplored`}
aria-label={buttonAriaLabel}
onClick={handleOpenQuickVote}
onFocus={handlePrefetchQuickVote}
onMouseEnter={handlePrefetchQuickVote}
Expand All @@ -82,21 +91,22 @@ const MemesWaveFooter: React.FC<MemesWaveFooterProps> = ({
/>
<div className="tw-relative tw-z-10 tw-flex tw-min-w-0 tw-flex-col tw-gap-1.5">
<span className="tw-text-[10px] tw-font-bold tw-uppercase tw-tracking-widest tw-text-[#6b7c93]">
Uncast votes
{buttonTitle}
</span>

<div className="tw-flex tw-items-center tw-gap-2">
<MemesWaveZapIcon className="tw-size-4 tw-flex-shrink-0 tw-fill-primary-400/20 tw-text-primary-400" />
<span className="tw-truncate tw-text-sm tw-font-semibold tw-tracking-tight tw-text-white">
{formatNumberWithCommas(uncastPower)}
{votingLabel ? ` ${votingLabel}` : " votes"}
{buttonValue}
</span>
</div>
</div>

<span className="tw-relative tw-z-10 tw-text-xs tw-font-semibold tw-text-[#8199ea] tw-shadow-sm">
{formatNumberWithCommas(unratedCount)} unexplored
</span>
{isReady && (
<span className="tw-relative tw-z-10 tw-text-xs tw-font-semibold tw-text-[#8199ea] tw-shadow-sm">
{formatNumberWithCommas(unratedCount)} unrated
</span>
)}
</div>
</button>
)}
Expand Down
22 changes: 16 additions & 6 deletions components/brain/left-sidebar/waves/MemesWaveQuickVoteTrigger.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,27 +5,35 @@ import { formatNumberWithCommas } from "@/helpers/Helpers";
import React from "react";

interface MemesWaveQuickVoteTriggerProps {
readonly isAvailable?: boolean | undefined;
readonly className?: string | undefined;
readonly onOpenQuickVote: () => void;
readonly onPrefetchQuickVote?: (() => void) | undefined;
readonly unratedCount: number;
}

const MemesWaveQuickVoteTrigger: React.FC<MemesWaveQuickVoteTriggerProps> = ({
isAvailable = true,
className,
onOpenQuickVote,
onPrefetchQuickVote,
unratedCount,
}) => {
if (unratedCount <= 0) {
if (!isAvailable) {
return null;
}

const label =
unratedCount > 0
? `${unratedCount} unrated submissions in the memes wave`
: "Quick vote";
const title = unratedCount > 0 ? `${unratedCount} unrated` : "Quick vote";

return (
<button
type="button"
aria-label={`${unratedCount} submissions left unrated in memes wave`}
title={`${unratedCount} left`}
aria-label={label}
title={title}
onClick={onOpenQuickVote}
onFocus={onPrefetchQuickVote}
onMouseEnter={onPrefetchQuickVote}
Expand All @@ -34,9 +42,11 @@ const MemesWaveQuickVoteTrigger: React.FC<MemesWaveQuickVoteTriggerProps> = ({
}`}
>
<MemesWaveZapIcon className="tw-size-4 tw-flex-shrink-0 tw-fill-primary-300/20" />
<span className="tw-text-xs tw-font-semibold">
{formatNumberWithCommas(unratedCount)}
</span>
{unratedCount > 0 && (
<span className="tw-text-xs tw-font-semibold">
{formatNumberWithCommas(unratedCount)}
</span>
)}
</button>
);
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ export default function MemesQuickVoteControls({
>
<div className="tw-hidden tw-shrink-0 tw-flex-wrap tw-gap-2 tw-px-8 md:tw-flex md:tw-pb-6 md:tw-pt-6">
<span className="tw-rounded-full tw-border tw-border-solid tw-border-white/5 tw-bg-white/[0.03] tw-px-4 tw-py-1.5 tw-text-[13px] tw-font-bold tw-text-iron-300 tw-shadow-sm tw-backdrop-blur-md">
{formatNumberWithCommas(remainingCount)} unexplored
{formatNumberWithCommas(remainingCount)} unrated
</span>
</div>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -169,9 +169,17 @@ function MemesQuickVoteDialogContent({
]
);

const queueSkip = () => {
skipDrop(activeDrop);
};
const queueSkip = useCallback(() => {
skipDrop(activeDrop)
.then((wasQueued) => {
if (!wasQueued) {
setIsAdvancing(false);
}
})
.catch(() => {
setIsAdvancing(false);
});
}, [activeDrop, skipDrop]);

const handleSkip = () => {
if (isControlsSubmitting) {
Expand All @@ -198,7 +206,7 @@ function MemesQuickVoteDialogContent({

<div className="tw-flex tw-min-w-0 tw-flex-col tw-items-center tw-justify-center tw-px-3">
<span className="tw-truncate tw-text-[13px] tw-font-bold tw-leading-tight tw-text-iron-300">
{formatNumberWithCommas(remainingCount)} unexplored
{formatNumberWithCommas(remainingCount)} unrated
</span>
</div>

Expand All @@ -211,7 +219,7 @@ function MemesQuickVoteDialogContent({
<div className="tw-min-h-0 tw-flex-1">
<MemesQuickVotePreview
drop={activeDrop}
isBusy={isAdvancing}
isBusy={isControlsSubmitting}
isMobile={isMobile}
remainingCount={remainingCount}
swipeVoteAmount={swipeVoteAmount}
Expand All @@ -227,6 +235,7 @@ function MemesQuickVoteDialogContent({
return;
}

setIsAdvancing(true);
queueVoteAmount(swipeVoteAmount);
}}
/>
Expand Down Expand Up @@ -272,7 +281,7 @@ function MemesQuickVoteDialogContent({
<div className="tw-min-h-0 tw-flex-1 md:tw-min-h-0 md:tw-border-y-0 md:tw-border-b-0 md:tw-border-l-0 md:tw-border-r md:tw-border-solid md:tw-border-white/10">
<MemesQuickVotePreview
drop={activeDrop}
isBusy={isAdvancing}
isBusy={isControlsSubmitting}
isMobile={isMobile}
remainingCount={remainingCount}
swipeVoteAmount={swipeVoteAmount}
Expand All @@ -288,6 +297,7 @@ function MemesQuickVoteDialogContent({
return;
}

setIsAdvancing(true);
queueVoteAmount(swipeVoteAmount);
}}
/>
Expand Down Expand Up @@ -381,10 +391,10 @@ function MemesQuickVoteDialogErrorState({
<div className="tw-flex tw-min-h-full tw-items-center tw-justify-center tw-py-8">
<div className="tw-w-full tw-max-w-xl tw-rounded-[1.75rem] tw-border tw-border-solid tw-border-white/10 tw-bg-white/[0.03] tw-px-6 tw-py-10 tw-text-center tw-shadow-[0_24px_60px_rgba(0,0,0,0.35)] tw-backdrop-blur-sm">
<p className="tw-mb-2 tw-text-lg tw-font-semibold tw-text-white">
Couldn&apos;t load your queue
Couldn&apos;t load quick vote
</p>
<p className="tw-mb-4 tw-text-sm tw-text-iron-400">
Quick vote couldn&apos;t reach the leaderboard. Try again.
Quick vote couldn&apos;t load the next meme. Try again.
</p>
<button
type="button"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,7 @@ export default function MemesQuickVoteDialogSkeleton() {
className="tw-flex tw-h-full tw-flex-col md:tw-grid md:tw-min-h-0 md:tw-grid-cols-[minmax(0,1.22fr)_minmax(25rem,1fr)] md:tw-items-stretch"
>
<p className="tw-sr-only">
Loading your queue. Pulling unrated memes and your recent quick-vote
amounts.
Loading your next meme and your recent quick-vote amounts.
</p>

<div data-testid="quick-vote-preview-status" className="tw-hidden">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,7 @@ function MemesQuickVotePreviewContent({
aria-hidden="true"
className="tw-rounded-full tw-border tw-border-solid tw-border-white/5 tw-bg-white/[0.03] tw-px-4 tw-py-1.5 tw-text-[13px] tw-font-bold tw-text-iron-300 tw-shadow-sm tw-backdrop-blur-md"
>
{formatNumberWithCommas(remainingCount)} unexplored
{formatNumberWithCommas(remainingCount)} unrated
</span>
</div>

Expand Down
5 changes: 3 additions & 2 deletions components/brain/mobile/FloatingMemesQuickVoteTrigger.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,16 @@ export default function FloatingMemesQuickVoteTrigger({
onOpenQuickVote,
onPrefetchQuickVote,
}: FloatingMemesQuickVoteTriggerProps) {
const { isReady, uncastPower, unratedCount } = useMemesWaveFooterStats();
const { isAvailable, unratedCount } = useMemesWaveFooterStats();

if (!isReady || typeof uncastPower !== "number" || unratedCount <= 0) {
if (!isAvailable) {
return null;
}

return (
<div className="tw-absolute tw-right-2 tw-top-2 tw-z-20 sm:tw-right-4 sm:tw-top-3">
<MemesWaveQuickVoteTrigger
isAvailable={isAvailable}
onOpenQuickVote={onOpenQuickVote}
onPrefetchQuickVote={onPrefetchQuickVote}
unratedCount={unratedCount}
Expand Down
8 changes: 0 additions & 8 deletions generated/models/ApiCreateNewWaveParticipationConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
import { ApiCreateNewWaveScope } from '../models/ApiCreateNewWaveScope';
import { ApiIntRange } from '../models/ApiIntRange';
import { ApiWaveParticipationRequirement } from '../models/ApiWaveParticipationRequirement';
import { ApiWaveParticipationSubmissionStrategy } from '../models/ApiWaveParticipationSubmissionStrategy';
import { ApiWaveRequiredMetadata } from '../models/ApiWaveRequiredMetadata';
import { HttpFile } from '../http/http';

Expand All @@ -38,7 +37,6 @@ export class ApiCreateNewWaveParticipationConfig {
*/
'terms': string | null;
'period'?: ApiIntRange;
'submission_strategy'?: ApiWaveParticipationSubmissionStrategy | null;

static readonly discriminator: string | undefined = undefined;

Expand Down Expand Up @@ -86,12 +84,6 @@ export class ApiCreateNewWaveParticipationConfig {
"baseName": "period",
"type": "ApiIntRange",
"format": ""
},
{
"name": "submission_strategy",
"baseName": "submission_strategy",
"type": "ApiWaveParticipationSubmissionStrategy",
"format": ""
} ];

static getAttributeTypeMap() {
Expand Down
6 changes: 3 additions & 3 deletions generated/models/ApiDrop.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

import { ApiDropContextProfileContext } from '../models/ApiDropContextProfileContext';
import { ApiDropMentionedUser } from '../models/ApiDropMentionedUser';
import { ApiDropMetadataResponse } from '../models/ApiDropMetadataResponse';
import { ApiDropMetadata } from '../models/ApiDropMetadata';
import { ApiDropNftLink } from '../models/ApiDropNftLink';
import { ApiDropPart } from '../models/ApiDropPart';
import { ApiDropRater } from '../models/ApiDropRater';
Expand Down Expand Up @@ -57,7 +57,7 @@ export class ApiDrop {
'referenced_nfts': Array<ApiDropReferencedNFT>;
'mentioned_users': Array<ApiDropMentionedUser>;
'mentioned_waves': Array<ApiMentionedWave>;
'metadata': Array<ApiDropMetadataResponse>;
'metadata': Array<ApiDropMetadata>;
'rating': number;
'realtime_rating': number;
'rating_prediction': number;
Expand Down Expand Up @@ -175,7 +175,7 @@ export class ApiDrop {
{
"name": "metadata",
"baseName": "metadata",
"type": "Array<ApiDropMetadataResponse>",
"type": "Array<ApiDropMetadata>",
"format": ""
},
{
Expand Down
2 changes: 1 addition & 1 deletion generated/models/ApiDropRatingRequest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import { HttpFile } from '../http/http';

export class ApiDropRatingRequest {
'rating': number;
'category': string;
'category'?: string | null;

static readonly discriminator: string | undefined = undefined;

Expand Down
6 changes: 3 additions & 3 deletions generated/models/ApiDropWithoutWave.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

import { ApiDropContextProfileContext } from '../models/ApiDropContextProfileContext';
import { ApiDropMentionedUser } from '../models/ApiDropMentionedUser';
import { ApiDropMetadataResponse } from '../models/ApiDropMetadataResponse';
import { ApiDropMetadata } from '../models/ApiDropMetadata';
import { ApiDropNftLink } from '../models/ApiDropNftLink';
import { ApiDropPart } from '../models/ApiDropPart';
import { ApiDropRater } from '../models/ApiDropRater';
Expand Down Expand Up @@ -55,7 +55,7 @@ export class ApiDropWithoutWave {
'referenced_nfts': Array<ApiDropReferencedNFT>;
'mentioned_users': Array<ApiDropMentionedUser>;
'mentioned_waves': Array<ApiMentionedWave>;
'metadata': Array<ApiDropMetadataResponse>;
'metadata': Array<ApiDropMetadata>;
'rating': number;
'realtime_rating': number;
'rating_prediction': number;
Expand Down Expand Up @@ -167,7 +167,7 @@ export class ApiDropWithoutWave {
{
"name": "metadata",
"baseName": "metadata",
"type": "Array<ApiDropMetadataResponse>",
"type": "Array<ApiDropMetadata>",
"format": ""
},
{
Expand Down
Loading
Loading