Merge branch 'streaks' into 'main'

Support Streaks

See merge request soapbox-pub/soapbox!3327
This commit is contained in:
Alex Gleason 2025-02-06 22:22:28 +00:00
commit 5fa10f4e58
3 changed files with 19 additions and 2 deletions

View File

@ -10,10 +10,11 @@ import type { Account } from 'soapbox/schemas/index.ts';
const messages = defineMessages({
followers: { id: 'account.followers', defaultMessage: 'Followers' },
follows: { id: 'account.follows', defaultMessage: 'Following' },
streak: { id: 'account.streak', defaultMessage: 'Day Streak' },
});
interface IProfileStats {
account: Pick<Account, 'acct' | 'followers_count' | 'following_count'> | undefined;
account: Pick<Account, 'acct' | 'followers_count' | 'following_count' | 'ditto'> | undefined;
onClickHandler?: React.MouseEventHandler;
}
@ -48,6 +49,17 @@ const ProfileStats: React.FC<IProfileStats> = ({ account, onClickHandler }) => {
</Text>
</HStack>
</NavLink>
{account.ditto.streak.days > 0 && (
<HStack alignItems='center' space={1}>
<Text theme='primary' weight='bold' size='sm'>
{shortNumberFormat(account.ditto.streak.days)}
</Text>
<Text weight='bold' size='sm'>
{intl.formatMessage(messages.streak)}
</Text>
</HStack>
)}
</HStack>
);
};

View File

@ -55,6 +55,7 @@
"account.search_self": "Search your posts",
"account.share": "Share @{name}'s profile",
"account.show_reblogs": "Show reposts from @{name}",
"account.streak": "Day Streak",
"account.subscribe": "Subscribe to notifications from @{name}",
"account.subscribe.failure": "An error occurred trying to subscribe to this account.",
"account.subscribe.success": "You have subscribed to this account.",

View File

@ -38,8 +38,12 @@ const baseAccountSchema = z.object({
display_name: z.string().catch(''),
ditto: coerceObject({
accepts_zaps: z.boolean().catch(false),
is_registered: z.boolean().catch(false),
external_url: z.string().optional().catch(undefined),
streak: coerceObject({
days: z.number().catch(0),
start: z.string().datetime().nullable().catch(null),
end: z.string().datetime().nullable().catch(null),
}),
}),
domain: z.string().optional().catch(undefined),
emojis: filteredArray(customEmojiSchema),