diff --git a/.storybook/manager.ts b/.storybook/manager.ts index 53dfaa15ab..8e1b3233a3 100644 --- a/.storybook/manager.ts +++ b/.storybook/manager.ts @@ -1,7 +1,11 @@ import { addons } from 'storybook/manager-api'; - -import theme from './storybook-theme'; +import { themes } from 'storybook/theming'; addons.setConfig({ - theme, + theme: { + ...themes.normal, + brandTitle: 'Mastodon Storybook', + brandImage: 'logo.svg', + colorSecondary: '#6364FF', + }, }); diff --git a/.storybook/static/logo.svg b/.storybook/static/logo.svg new file mode 100644 index 0000000000..d85fc9ab76 --- /dev/null +++ b/.storybook/static/logo.svg @@ -0,0 +1,21 @@ + + + + + + + + + + + + diff --git a/.storybook/storybook-theme.ts b/.storybook/storybook-theme.ts deleted file mode 100644 index 7a72ba1c75..0000000000 --- a/.storybook/storybook-theme.ts +++ /dev/null @@ -1,7 +0,0 @@ -import { create } from 'storybook/theming'; - -export default create({ - base: 'light', - brandTitle: 'Mastodon Storybook', - brandImage: 'https://joinmastodon.org/logos/wordmark-black-text.svg', -}); diff --git a/.storybook/storybook.d.ts b/.storybook/storybook.d.ts index 4d43912415..5f3d17486b 100644 --- a/.storybook/storybook.d.ts +++ b/.storybook/storybook.d.ts @@ -1,5 +1,8 @@ +/* eslint-disable @typescript-eslint/no-explicit-any */ // The addon package.json incorrectly exports types, so we need to override them here. +import type { PartialDeep } from 'type-fest'; + import type { RootState } from '@/mastodon/store'; // See: https://github.com/storybookjs/storybook/blob/v9.0.4/code/addons/vitest/package.json#L70-L76 @@ -7,13 +10,22 @@ declare module '@storybook/addon-vitest/vitest-plugin' { export * from '@storybook/addon-vitest/dist/vitest-plugin/index'; } -type RootPathKeys = keyof RootState; +type TypedRootState = { + [Key in keyof RootState]?: RootState[Key] extends Immutable.OrderedCollection + ? unknown + : PartialDeep; +}; declare module 'storybook/internal/csf' { export interface InputType { + /** + * Connects an argument value deeply in the Redux state. + * + * Can either be a period separated string or an array. + */ reduxPath?: - | `${RootPathKeys}.${string}` - | [RootPathKeys, ...(string | number)[]]; + | `${keyof TypedRootState}.${string}` + | [keyof TypedRootState, ...(string | number)[]]; } export interface Globals { @@ -21,6 +33,13 @@ declare module 'storybook/internal/csf' { theme: 'light' | 'dark'; loggedIn: 'true' | 'false'; } + + export interface Parameters { + /** Provides the Redux state as a JS object for the component. */ + state?: TypedRootState; + /** Callback that is run with the story arguments to generate Redux state for the component. */ + stateFn?: (args: any) => TypedRootState; + } } export {}; diff --git a/Gemfile.lock b/Gemfile.lock index 600fe8188f..8bc53b035a 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -178,7 +178,7 @@ GEM crack (1.0.1) bigdecimal rexml - crass (1.0.6) + crass (1.0.7) css_parser (3.0.0) addressable ssrf_filter (~> 1.5) diff --git a/app/javascript/entrypoints/public.tsx b/app/javascript/entrypoints/public.tsx index 848e600895..363ca0fec9 100644 --- a/app/javascript/entrypoints/public.tsx +++ b/app/javascript/entrypoints/public.tsx @@ -15,6 +15,7 @@ import { throttle } from 'lodash'; import { determineEmojiMode } from '@/mastodon/features/emoji/mode'; import { updateHtmlWithEmoji } from '@/mastodon/features/emoji/render'; +import type { InitialState } from '@/mastodon/initial_state'; import loadKeyboardExtensions from '@/mastodon/load_keyboard_extensions'; import { loadLocale, getLocale } from '@/mastodon/locales'; import { loadPolyfills } from '@/mastodon/polyfills'; @@ -83,7 +84,7 @@ async function loaded() { document.getElementById('initial-state')?.textContent; if (initialStateText) { const stateEmojiStyle = getNestedProperty( - JSON.parse(initialStateText) as unknown, + JSON.parse(initialStateText) as InitialState, 'meta', 'emoji_style', ); diff --git a/app/javascript/mastodon/api_types/accounts.ts b/app/javascript/mastodon/api_types/accounts.ts index 85ee62ad07..1f5a808298 100644 --- a/app/javascript/mastodon/api_types/accounts.ts +++ b/app/javascript/mastodon/api_types/accounts.ts @@ -60,7 +60,7 @@ export interface BaseApiAccountJSON { show_featured: boolean; noindex?: boolean; note: string; - roles?: ApiAccountJSON[]; + roles?: ApiAccountRoleJSON[]; statuses_count: number; uri: string; url?: string; diff --git a/app/javascript/mastodon/api_types/quotes.ts b/app/javascript/mastodon/api_types/quotes.ts index 2a5e8b4e45..de69394b98 100644 --- a/app/javascript/mastodon/api_types/quotes.ts +++ b/app/javascript/mastodon/api_types/quotes.ts @@ -19,11 +19,13 @@ interface ApiNestedQuoteJSON { quoted_status_id: string; } +export type ApiQuotedStatusJSON = Omit & { + quote?: ApiNestedQuoteJSON | ApiQuoteEmptyJSON; +}; + interface ApiQuoteAcceptedJSON { state: 'accepted'; - quoted_status: Omit & { - quote?: ApiNestedQuoteJSON | ApiQuoteEmptyJSON; - }; + quoted_status: ApiQuotedStatusJSON; } export type ApiQuoteJSON = ApiQuoteAcceptedJSON | ApiQuoteEmptyJSON; diff --git a/app/javascript/mastodon/components/account/account.stories.tsx b/app/javascript/mastodon/components/account/account.stories.tsx index 0b1e9e29b3..62c52ba8c4 100644 --- a/app/javascript/mastodon/components/account/account.stories.tsx +++ b/app/javascript/mastodon/components/account/account.stories.tsx @@ -2,7 +2,10 @@ import type { ComponentProps } from 'react'; import type { Meta, StoryObj } from '@storybook/react-vite'; -import { accountFactoryState, relationshipsFactory } from '@/testing/factories'; +import { + accountFactoryImmutable, + relationshipsFactoryAPI, +} from '@/testing/factories'; import { Account } from './index'; @@ -69,7 +72,7 @@ const meta = { parameters: { state: { accounts: { - '1': accountFactoryState(), + '1': accountFactoryImmutable(), }, }, }, @@ -121,7 +124,7 @@ export const Blocked: Story = { parameters: { state: { relationships: { - '1': relationshipsFactory({ + '1': relationshipsFactoryAPI({ blocking: true, }), }, @@ -134,7 +137,7 @@ export const Muted: Story = { parameters: { state: { relationships: { - '1': relationshipsFactory({ + '1': relationshipsFactoryAPI({ muting: true, }), }, diff --git a/app/javascript/mastodon/components/account_list_item/account_list_item.stories.tsx b/app/javascript/mastodon/components/account_list_item/account_list_item.stories.tsx index 62875b02f6..5b201b4cdf 100644 --- a/app/javascript/mastodon/components/account_list_item/account_list_item.stories.tsx +++ b/app/javascript/mastodon/components/account_list_item/account_list_item.stories.tsx @@ -1,6 +1,9 @@ import type { Meta, StoryObj } from '@storybook/react-vite'; -import { accountFactoryState, relationshipsFactory } from '@/testing/factories'; +import { + accountFactoryImmutable, + relationshipsFactoryAPI, +} from '@/testing/factories'; import { PendingBadge } from '../badge'; @@ -16,7 +19,7 @@ const meta = { parameters: { state: { accounts: { - '1': accountFactoryState(), + '1': accountFactoryImmutable(), }, }, }, @@ -32,7 +35,7 @@ export const FollowsYou: Story = { parameters: { state: { relationships: { - '1': relationshipsFactory({ + '1': relationshipsFactoryAPI({ followed_by: true, }), }, diff --git a/app/javascript/mastodon/components/display_name/display_name.stories.tsx b/app/javascript/mastodon/components/display_name/display_name.stories.tsx index 6f1819a557..f442bcc256 100644 --- a/app/javascript/mastodon/components/display_name/display_name.stories.tsx +++ b/app/javascript/mastodon/components/display_name/display_name.stories.tsx @@ -2,7 +2,7 @@ import type { ComponentProps } from 'react'; import type { Meta, StoryObj } from '@storybook/react-vite'; -import { accountFactoryState } from '@/testing/factories'; +import { accountFactoryImmutable } from '@/testing/factories'; import { DisplayName, LinkedDisplayName } from './index'; @@ -23,7 +23,7 @@ const meta = { tags: [], render({ name, username, loading, ...args }) { const account = !loading - ? accountFactoryState({ + ? accountFactoryImmutable({ display_name: name, acct: username, }) @@ -69,7 +69,7 @@ export const LocalUser: Story = { export const Linked: Story = { render({ name, username, loading, ...args }) { const account = !loading - ? accountFactoryState({ + ? accountFactoryImmutable({ display_name: name, acct: username, }) diff --git a/app/javascript/mastodon/components/form_fields/emoji_text_field.tsx b/app/javascript/mastodon/components/form_fields/emoji_text_field.tsx index 874ec91f79..0b76c3c156 100644 --- a/app/javascript/mastodon/components/form_fields/emoji_text_field.tsx +++ b/app/javascript/mastodon/components/form_fields/emoji_text_field.tsx @@ -8,8 +8,9 @@ import type { } from 'react'; import { useCallback, useId, useRef } from 'react'; +import type { Merge } from 'type-fest'; + import { insertEmojiAtPosition } from '@/mastodon/features/emoji/utils'; -import type { OmitUnion } from '@/mastodon/utils/types'; import { CharacterCounter } from '../character_counter'; import { EmojiPickerButton } from '../emoji/picker_button'; @@ -29,7 +30,7 @@ export type EmojiInputProps = { } & Omit; export const EmojiTextInputField: FC< - OmitUnion, EmojiInputProps> + Merge, EmojiInputProps> > = ({ onChange, value, @@ -72,7 +73,7 @@ export const EmojiTextInputField: FC< }; export const EmojiTextAreaField: FC< - OmitUnion, EmojiInputProps> + Merge, EmojiInputProps> > = ({ onChange, value, diff --git a/app/javascript/mastodon/components/mini_card/index.tsx b/app/javascript/mastodon/components/mini_card/index.tsx index 78e240b01e..6d0272c6f0 100644 --- a/app/javascript/mastodon/components/mini_card/index.tsx +++ b/app/javascript/mastodon/components/mini_card/index.tsx @@ -3,14 +3,14 @@ import type { ComponentPropsWithoutRef, ReactNode } from 'react'; import classNames from 'classnames'; -import type { OmitUnion } from '@/mastodon/utils/types'; +import type { Merge } from 'type-fest'; import { Icon } from '../icon'; import type { IconProp } from '../icon'; import classes from './styles.module.css'; -export type MiniCardProps = OmitUnion< +export type MiniCardProps = Merge< ComponentPropsWithoutRef<'div'>, { label: ReactNode; diff --git a/app/javascript/mastodon/components/mini_card/list.tsx b/app/javascript/mastodon/components/mini_card/list.tsx index c98f57c863..28ced49116 100644 --- a/app/javascript/mastodon/components/mini_card/list.tsx +++ b/app/javascript/mastodon/components/mini_card/list.tsx @@ -3,7 +3,7 @@ import type { ComponentPropsWithoutRef, Key } from 'react'; import classNames from 'classnames'; -import type { OmitUnion } from '@/mastodon/utils/types'; +import type { Merge } from 'type-fest'; import { MiniCard } from '.'; import type { MiniCardProps as BaseCardProps } from '.'; @@ -19,7 +19,7 @@ interface MiniCardListProps { export const MiniCardList = forwardRef< HTMLDListElement, - OmitUnion, MiniCardListProps> + Merge, MiniCardListProps> >(({ cards = [], className, children, ...props }, ref) => { if (!cards.length) { return null; diff --git a/app/javascript/mastodon/components/status/boost_button.stories.tsx b/app/javascript/mastodon/components/status/boost_button.stories.tsx index 402695a829..5ea0040212 100644 --- a/app/javascript/mastodon/components/status/boost_button.stories.tsx +++ b/app/javascript/mastodon/components/status/boost_button.stories.tsx @@ -1,7 +1,7 @@ import type { Meta, StoryObj } from '@storybook/react-vite'; import type { StatusVisibility } from '@/mastodon/api_types/statuses'; -import { statusFactoryState } from '@/testing/factories'; +import { statusFactoryImmutable } from '@/testing/factories'; import { BoostButton } from './boost_button'; @@ -50,7 +50,7 @@ function argsToStatus({ quoteAllowed, alreadyBoosted, }: StoryProps) { - return statusFactoryState({ + return statusFactoryImmutable({ reblogs_count: reblogCount, visibility, reblogged: alreadyBoosted, diff --git a/app/javascript/mastodon/components/status/boost_button.tsx b/app/javascript/mastodon/components/status/boost_button.tsx index c298c1c744..d65018cdaf 100644 --- a/app/javascript/mastodon/components/status/boost_button.tsx +++ b/app/javascript/mastodon/components/status/boost_button.tsx @@ -5,6 +5,8 @@ import { useIntl } from 'react-intl'; import classNames from 'classnames'; +import type { SetRequired } from 'type-fest'; + import { quoteComposeById } from '@/mastodon/actions/compose_typed'; import { toggleReblog } from '@/mastodon/actions/interactions'; import { openModal } from '@/mastodon/actions/modal'; @@ -13,7 +15,6 @@ import { quickBoosting } from '@/mastodon/initial_state'; import type { ActionMenuItem } from '@/mastodon/models/dropdown_menu'; import type { Status } from '@/mastodon/models/status'; import { useAppDispatch, useAppSelector } from '@/mastodon/store'; -import type { SomeRequired } from '@/mastodon/utils/types'; import type { RenderItemFn } from '../dropdown_menu'; import { Dropdown, DropdownMenuItemContent } from '../dropdown_menu'; @@ -91,7 +92,7 @@ interface ReblogButtonProps { counters?: boolean; } -type ActionMenuItemWithIcon = SomeRequired; +type ActionMenuItemWithIcon = SetRequired; const BoostOrQuoteMenu: FC = ({ status, counters }) => { const intl = useIntl(); diff --git a/app/javascript/mastodon/components/status/content.stories.tsx b/app/javascript/mastodon/components/status/content.stories.tsx index cb9bb9d3ec..93dc5fcc3a 100644 --- a/app/javascript/mastodon/components/status/content.stories.tsx +++ b/app/javascript/mastodon/components/status/content.stories.tsx @@ -2,7 +2,7 @@ import type { Meta, StoryObj } from '@storybook/react-vite'; import { fn } from 'storybook/test'; import type { StatusTranslation } from '@/mastodon/models/status'; -import { statusFactoryState } from '@/testing/factories'; +import { statusFactoryImmutable } from '@/testing/factories'; import { StatusContent } from './content'; @@ -57,7 +57,7 @@ const meta = { }, }, stateFn(args: StatusContentProps) { - let status = statusFactoryState(); + let status = statusFactoryImmutable(); if (args.translatedTo) { status = status.set('translation', { contentHtml: `${args.text}

(in ${args.translatedTo})

`, diff --git a/app/javascript/mastodon/components/status/handled_link.stories.tsx b/app/javascript/mastodon/components/status/handled_link.stories.tsx index e343833704..20475955ce 100644 --- a/app/javascript/mastodon/components/status/handled_link.stories.tsx +++ b/app/javascript/mastodon/components/status/handled_link.stories.tsx @@ -1,7 +1,7 @@ import type { Meta, StoryObj } from '@storybook/react-vite'; import { HashtagMenuController } from '@/mastodon/features/ui/components/hashtag_menu_controller'; -import { accountFactoryState } from '@/testing/factories'; +import { accountFactoryImmutable } from '@/testing/factories'; import { HoverCardController } from '../hover_card_controller'; @@ -55,7 +55,7 @@ const meta = { parameters: { state: { accounts: { - '1': accountFactoryState({ id: '1', acct: 'hashtaguser' }), + '1': accountFactoryImmutable({ id: '1', acct: 'hashtaguser' }), }, }, }, diff --git a/app/javascript/mastodon/components/status/status.stories.tsx b/app/javascript/mastodon/components/status/status.stories.tsx index a9244f56c9..6afabcc901 100644 --- a/app/javascript/mastodon/components/status/status.stories.tsx +++ b/app/javascript/mastodon/components/status/status.stories.tsx @@ -9,11 +9,11 @@ import { fn } from 'storybook/test'; import type { ApiMediaAttachmentJSON } from '@/mastodon/api_types/media_attachments'; import type { StatusVisibility } from '@/mastodon/api_types/statuses'; import { - accountFactoryState, - mediaAttachmentFactory, - pollFactory, - statusFactory, - statusFactoryState, + accountFactoryImmutable, + mediaAttachmentFactoryAPI, + pollFactoryImmutable, + statusFactoryAPI, + statusFactoryImmutable, } from '@/testing/factories'; import { TypedStatus } from './types'; @@ -71,7 +71,7 @@ interface StatusStoryProps { showPrepend?: boolean; } -const otherAccount = accountFactoryState({ +const otherAccount = accountFactoryImmutable({ id: '2', display_name: 'Another user', }); @@ -106,14 +106,14 @@ const StatusStoryComponent: FC = (props) => { showPrepend = true, } = props; const { account, status } = useMemo(() => { - const account = accountFactoryState(); + const account = accountFactoryImmutable(); const media_attachments: ApiMediaAttachmentJSON[] = []; switch (attachments) { // Use fall through add attachments depending on count. case 'image-3': media_attachments.push( - mediaAttachmentFactory({ + mediaAttachmentFactoryAPI({ id: '2', url: 'https://cataas.com/cat/EbVq9zMc4Xxv7s73', meta: { @@ -129,7 +129,7 @@ const StatusStoryComponent: FC = (props) => { // eslint-disable-next-line no-fallthrough case 'image-2': media_attachments.push( - mediaAttachmentFactory({ + mediaAttachmentFactoryAPI({ id: '3', url: 'https://cataas.com/cat/YFaQ4xWYoWURSz37', meta: { @@ -145,7 +145,7 @@ const StatusStoryComponent: FC = (props) => { // eslint-disable-next-line no-fallthrough case 'image-1': media_attachments.push( - mediaAttachmentFactory({ + mediaAttachmentFactoryAPI({ id: '4', url: 'https://cataas.com/cat/bYBTjiFUqjUPIBUD', meta: { @@ -161,7 +161,7 @@ const StatusStoryComponent: FC = (props) => { break; case 'video': media_attachments.push( - mediaAttachmentFactory({ + mediaAttachmentFactoryAPI({ type: 'video', url: 'https://www.pexels.com/download/video/11760787/', meta: { @@ -175,7 +175,7 @@ const StatusStoryComponent: FC = (props) => { break; case 'audio': media_attachments.push( - mediaAttachmentFactory({ + mediaAttachmentFactoryAPI({ type: 'audio', url: 'https://upload.wikimedia.org/wikipedia/commons/4/40/Elephant_voice_-_trumpeting.ogg', }), @@ -183,7 +183,7 @@ const StatusStoryComponent: FC = (props) => { break; case 'gifv': media_attachments.push( - mediaAttachmentFactory({ + mediaAttachmentFactoryAPI({ type: 'gifv', url: 'https://www.pexels.com/download/video/11760787/', meta: { @@ -196,13 +196,15 @@ const StatusStoryComponent: FC = (props) => { ); break; case 'unknown': - media_attachments.push(mediaAttachmentFactory({ type: attachments })); + media_attachments.push( + mediaAttachmentFactoryAPI({ type: attachments }), + ); break; } return { account, - status: statusFactoryState({ + status: statusFactoryImmutable({ text, spoiler_text: contentWarning, visibility, @@ -215,7 +217,7 @@ const StatusStoryComponent: FC = (props) => { quote: isQuote ? { state: 'accepted', - quoted_status: { ...statusFactory(), quote: undefined }, + quoted_status: { ...statusFactoryAPI(), quote: undefined }, } : undefined, favourites_count: favouriteCount, @@ -236,7 +238,7 @@ const StatusStoryComponent: FC = (props) => { if (isReblog) { status.set( 'reblog', - statusFactoryState({ id: '2' }).set('account', otherAccount), + statusFactoryImmutable({ id: '2' }).set('account', otherAccount), ); } if (isPoll) { @@ -469,8 +471,8 @@ const meta = { '2': otherAccount, }, polls: { - '1': pollFactory(), - '2': pollFactory({ + '1': pollFactoryImmutable(), + '2': pollFactoryImmutable({ voted: true, voters_count: 1, votes_count: 1, diff --git a/app/javascript/mastodon/components/status_quoted.stories.tsx b/app/javascript/mastodon/components/status_quoted.stories.tsx index 5b78d3a3c5..60a93cbc84 100644 --- a/app/javascript/mastodon/components/status_quoted.stories.tsx +++ b/app/javascript/mastodon/components/status_quoted.stories.tsx @@ -3,7 +3,10 @@ import { Map as ImmutableMap } from 'immutable'; import type { Meta, StoryObj } from '@storybook/react-vite'; import type { ApiQuoteJSON } from '@/mastodon/api_types/quotes'; -import { accountFactoryState, statusFactoryState } from '@/testing/factories'; +import { + accountFactoryImmutable, + statusFactoryImmutable, +} from '@/testing/factories'; import type { StatusQuoteManagerProps } from './status_quoted'; import { StatusQuoteManager } from './status_quoted'; @@ -16,15 +19,15 @@ const meta = { parameters: { state: { accounts: { - '1': accountFactoryState({ id: '1', acct: 'hashtaguser' }), + '1': accountFactoryImmutable({ id: '1', acct: 'hashtaguser' }), }, statuses: { - '1': statusFactoryState({ + '1': statusFactoryImmutable({ id: '1', language: 'en', text: 'Hello world!', }), - '2': statusFactoryState({ + '2': statusFactoryImmutable({ id: '2', language: 'en', text: 'Quote!', @@ -33,19 +36,19 @@ const meta = { quoted_status: '1', }) as unknown as ApiQuoteJSON, }), - '1001': statusFactoryState({ + '1001': statusFactoryImmutable({ id: '1001', language: 'mn-Mong', // meaning: Mongolia text: 'ᠮᠤᠩᠭᠤᠯ', }), - '1002': statusFactoryState({ + '1002': statusFactoryImmutable({ id: '1002', language: 'mn-Mong', // meaning: All human beings are born free and equal in dignity and rights. text: 'ᠬᠦᠮᠦᠨ ᠪᠦᠷ ᠲᠥᠷᠥᠵᠦ ᠮᠡᠨᠳᠡᠯᠡᠬᠦ ᠡᠷᠬᠡ ᠴᠢᠯᠥᠭᠡ ᠲᠡᠢ᠂ ᠠᠳᠠᠯᠢᠬᠠᠨ ᠨᠡᠷ᠎ᠡ ᠲᠥᠷᠥ ᠲᠡᠢ᠂ ᠢᠵᠢᠯ ᠡᠷᠬᠡ ᠲᠡᠢ ᠪᠠᠢᠠᠭ᠃', }), - '1003': statusFactoryState({ + '1003': statusFactoryImmutable({ id: '1003', language: 'mn-Mong', // meaning: Mongolia diff --git a/app/javascript/mastodon/components/tags/tag.tsx b/app/javascript/mastodon/components/tags/tag.tsx index 8192854327..fb373a854b 100644 --- a/app/javascript/mastodon/components/tags/tag.tsx +++ b/app/javascript/mastodon/components/tags/tag.tsx @@ -5,7 +5,8 @@ import { useIntl } from 'react-intl'; import classNames from 'classnames'; -import type { OmitUnion } from '@/mastodon/utils/types'; +import type { Merge } from 'type-fest'; + import CloseIcon from '@/material-icons/400-24px/close.svg?react'; import type { IconProp } from '../icon'; @@ -24,7 +25,7 @@ export interface TagProps { export const Tag = forwardRef< HTMLButtonElement, - OmitUnion, TagProps> + Merge, TagProps> >(({ name, active, icon, className, children, ...props }, ref) => { if (!name) { return null; @@ -47,7 +48,7 @@ Tag.displayName = 'Tag'; export const EditableTag = forwardRef< HTMLSpanElement, - OmitUnion< + Merge< ComponentPropsWithoutRef<'span'>, TagProps & { onRemove: () => void; diff --git a/app/javascript/mastodon/features/annual_report/announcement/announcement.stories.tsx b/app/javascript/mastodon/features/annual_report/announcement/announcement.stories.tsx index 1b96f6f60b..0032602fc0 100644 --- a/app/javascript/mastodon/features/annual_report/announcement/announcement.stories.tsx +++ b/app/javascript/mastodon/features/annual_report/announcement/announcement.stories.tsx @@ -1,17 +1,18 @@ import type { Meta, StoryObj } from '@storybook/react-vite'; import { action } from 'storybook/actions'; +import type { ConditionalExcept } from 'type-fest'; -import type { AnyFunction, OmitValueType } from '@/mastodon/utils/types'; +import type { AnyFunction } from '@/mastodon/utils/types'; import type { AnnualReportAnnouncementProps } from '.'; import { AnnualReportAnnouncement } from '.'; -type Props = OmitValueType< +type Props = ConditionalExcept< // We can't use the name 'state' here because it's reserved for overriding Redux state. Omit & { reportState: AnnualReportAnnouncementProps['state']; }, - AnyFunction // Remove any functions, as they can't meaningfully be controlled in Storybook. + AnyFunction | undefined // Remove any functions, as they can't meaningfully be controlled in Storybook. >; const meta = { diff --git a/app/javascript/mastodon/features/annual_report/annual_report.stories.tsx b/app/javascript/mastodon/features/annual_report/annual_report.stories.tsx index 3ccaceae6c..0d145e076a 100644 --- a/app/javascript/mastodon/features/annual_report/annual_report.stories.tsx +++ b/app/javascript/mastodon/features/annual_report/annual_report.stories.tsx @@ -1,9 +1,9 @@ import type { Meta, StoryObj } from '@storybook/react-vite'; import { - accountFactoryState, - annualReportFactory, - statusFactoryState, + accountFactoryImmutable, + annualReportFactoryState, + statusFactoryImmutable, } from '@/testing/factories'; import { AnnualReport } from '.'; @@ -22,12 +22,12 @@ const meta = { parameters: { state: { accounts: { - '1': accountFactoryState({ display_name: 'Freddie Fruitbat' }), + '1': accountFactoryImmutable({ display_name: 'Freddie Fruitbat' }), }, statuses: { - '1': statusFactoryState(), + '1': statusFactoryImmutable(), }, - annualReport: annualReportFactory({ + annualReport: annualReportFactoryState({ top_hashtag: SAMPLE_HASHTAG, }), }, @@ -54,7 +54,7 @@ export const ArchetypeOracle: Story = { ...InModal, parameters: { state: { - annualReport: annualReportFactory({ + annualReport: annualReportFactoryState({ archetype: 'oracle', top_hashtag: SAMPLE_HASHTAG, }), @@ -66,7 +66,7 @@ export const NoHashtag: Story = { ...InModal, parameters: { state: { - annualReport: annualReportFactory({ + annualReport: annualReportFactoryState({ archetype: 'booster', }), }, @@ -77,7 +77,7 @@ export const NoNewPosts: Story = { ...InModal, parameters: { state: { - annualReport: annualReportFactory({ + annualReport: annualReportFactoryState({ archetype: 'pollster', top_hashtag: SAMPLE_HASHTAG, without_posts: true, @@ -90,7 +90,7 @@ export const NoNewPostsNoHashtag: Story = { ...InModal, parameters: { state: { - annualReport: annualReportFactory({ + annualReport: annualReportFactoryState({ archetype: 'replier', without_posts: true, }), diff --git a/app/javascript/mastodon/features/compose/components/warning.tsx b/app/javascript/mastodon/features/compose/components/warning.tsx index e58b14e812..875d6df58d 100644 --- a/app/javascript/mastodon/features/compose/components/warning.tsx +++ b/app/javascript/mastodon/features/compose/components/warning.tsx @@ -62,7 +62,11 @@ export const Warning = () => { id='compose_form.encryption_warning' defaultMessage='Posts on Mastodon are not end-to-end encrypted. Do not share any dangerous information over Mastodon.' />{' '} - + diff --git a/app/javascript/mastodon/locales/et.json b/app/javascript/mastodon/locales/et.json index 7cb111f5f9..dd411f35f2 100644 --- a/app/javascript/mastodon/locales/et.json +++ b/app/javascript/mastodon/locales/et.json @@ -267,6 +267,7 @@ "admin.impact_report.instance_followers": "Jälgijad, kelle meie kasutajad kaotaks", "admin.impact_report.instance_follows": "Jälgijad, mille nende kasutajad kaotaks", "admin.impact_report.title": "Mõju kokkuvõte", + "alert.need_reload.message": "Mastodoni server on uuendatud. Mõni funktsionaalsus ei pruugi korrektselt toimida enne, kui oled lehe uuesti laadinud.", "alert.rate_limited.message": "Palun proovi uuesti pärast {retry_time, time, medium}.", "alert.rate_limited.title": "Kiiruspiirang", "alert.unexpected.message": "Tekkis ootamatu viga.", diff --git a/app/javascript/mastodon/locales/fi.json b/app/javascript/mastodon/locales/fi.json index 19c2a2956b..5db1abe659 100644 --- a/app/javascript/mastodon/locales/fi.json +++ b/app/javascript/mastodon/locales/fi.json @@ -267,7 +267,7 @@ "admin.impact_report.instance_followers": "Seuraajat, jotka käyttäjämme menettäisivät", "admin.impact_report.instance_follows": "Seuraajat, jotka heidän käyttäjänsä menettäisivät", "admin.impact_report.title": "Vaikutusten yhteenveto", - "alert.need_reload.message": "Mastodon on päivitetty. Jotkin asiat eivät välttämättä toimi oikein, ennen kuin lataat sivun uudelleen.", + "alert.need_reload.message": "Mastodon on päivitetty. Jotkin asiat eivät välttämättä toimi oikein ennen kuin lataat sivun uudelleen.", "alert.rate_limited.message": "Yritä uudelleen kello {retry_time, time, medium} jälkeen.", "alert.rate_limited.title": "Pyyntömäärää rajoitettu", "alert.unexpected.message": "Tapahtui odottamaton virhe.", diff --git a/app/javascript/mastodon/locales/ga.json b/app/javascript/mastodon/locales/ga.json index 1991bf074f..cd66af0fcd 100644 --- a/app/javascript/mastodon/locales/ga.json +++ b/app/javascript/mastodon/locales/ga.json @@ -267,6 +267,7 @@ "admin.impact_report.instance_followers": "Leanúna a chaillfeadh ár n-úsáideoirí", "admin.impact_report.instance_follows": "Leanúna a bheadh ​​​​a n-úsáideoirí chailleadh", "admin.impact_report.title": "Achoimre ar an tionchar", + "alert.need_reload.message": "Tá Mastodon nuashonraithe. Seans nach n-oibreoidh roinnt rudaí i gceart go dtí go ndéanfaidh tú an leathanach a athlódáil.", "alert.rate_limited.message": "Atriail aris tar éis {retry_time, time, medium}.", "alert.rate_limited.title": "Ráta teoranta", "alert.unexpected.message": "Tharla earráid gan choinne.", diff --git a/app/javascript/mastodon/locales/nan-TW.json b/app/javascript/mastodon/locales/nan-TW.json index 181d2da1f6..51e32c717f 100644 --- a/app/javascript/mastodon/locales/nan-TW.json +++ b/app/javascript/mastodon/locales/nan-TW.json @@ -267,6 +267,7 @@ "admin.impact_report.instance_followers": "本站ê跟tuè者ē流失ê數", "admin.impact_report.instance_follows": "In ê跟tuè者ē流失ê數", "admin.impact_report.title": "影響ê摘要", + "alert.need_reload.message": "Mastodon更新ah。直到汝重載入前,一寡物件可能bē當正常運作。", "alert.rate_limited.message": "請tī {retry_time, time, medium} 以後koh試。", "alert.rate_limited.title": "限速ah", "alert.unexpected.message": "發生意外ê錯誤。.", diff --git a/app/javascript/mastodon/locales/sv.json b/app/javascript/mastodon/locales/sv.json index c4082afaf7..dd2d43861e 100644 --- a/app/javascript/mastodon/locales/sv.json +++ b/app/javascript/mastodon/locales/sv.json @@ -46,8 +46,8 @@ "account.featured.new_collection": "Ny samling", "account.field_overflow": "Visa hela innehållet", "account.filters.all": "All aktivitet", - "account.filters.boosts_toggle": "Visa förstärkningar", - "account.filters.posts_boosts": "Inlägg och förstärkningar", + "account.filters.boosts_toggle": "Visa boostar", + "account.filters.posts_boosts": "Inlägg och boostar", "account.filters.posts_only": "Inlägg", "account.filters.posts_replies": "Inlägg och svar", "account.filters.replies_toggle": "Visa svar", @@ -93,7 +93,7 @@ "account.menu.copied": "Kopierade kontolänk till urklipp", "account.menu.copy": "Kopiera länk", "account.menu.direct": "Nämn privat", - "account.menu.hide_reblogs": "Dölj förstärkningar i tidslinjen", + "account.menu.hide_reblogs": "Dölj boostar i tidslinjen", "account.menu.mention": "Nämn", "account.menu.mute": "Tysta konto", "account.menu.note.description": "Endast synlig för dig", @@ -101,7 +101,7 @@ "account.menu.remove_follower": "Ta bort följare", "account.menu.report": "Rapportera konto", "account.menu.share": "Dela…", - "account.menu.show_reblogs": "Visa förstärkningar i tidslinjen", + "account.menu.show_reblogs": "Visa boostar i tidslinjen", "account.menu.unblock": "Avblockera konto", "account.menu.unblock_domain": "Avblockera {domain}", "account.menu.unmute": "Avtysta konto", @@ -290,8 +290,8 @@ "annual_report.shared_page.donate": "Donera", "annual_report.shared_page.footer": "Genererad med {heart} av Mastodon-teamet", "annual_report.shared_page.footer_server_info": "{username} använder {domain}, en av många forum som drivs av Mastodon.", - "annual_report.summary.archetype.booster.desc_public": "{name} jagade efter inlägg att boosta och förstärka andra skapare med perfekt sikte.", - "annual_report.summary.archetype.booster.desc_self": "Du jagade efter inlägg att boosta och förstärka andra skapare med perfekt sikte.", + "annual_report.summary.archetype.booster.desc_public": "{name} letade efter inlägg att boosta och lyfte fram andra skapare med perfekt precision.", + "annual_report.summary.archetype.booster.desc_self": "Du letade efter inlägg att boosta och lyfte fram andra skapare med perfekt precision.", "annual_report.summary.archetype.booster.name": "Bågskytten", "annual_report.summary.archetype.die_drei_fragezeichen": "???", "annual_report.summary.archetype.lurker.desc_public": "Vi vet att {name} var där ute någonstans och njuter av Mastodon på sitt egna tysta sätt.", @@ -313,8 +313,8 @@ "annual_report.summary.close": "Stäng", "annual_report.summary.copy_link": "Kopiera länk", "annual_report.summary.followers.new_followers": "{count, plural, one {ny följare} other {nya följare}}", - "annual_report.summary.highlighted_post.boost_count": "Det här inlägget förstärktes {count, plural, one {en gång} other {# gånger}}.", - "annual_report.summary.highlighted_post.favourite_count": "Det här inlägget favoriserades {count, plural, one {en gång} other {# gånger}}.", + "annual_report.summary.highlighted_post.boost_count": "Det här inlägget boostades {count, plural, one {en gång} other {# gånger}}.", + "annual_report.summary.highlighted_post.favourite_count": "Det här inlägget favoritmarkerades {count, plural, one {en gång} other {# gånger}}.", "annual_report.summary.highlighted_post.reply_count": "Det här inlägget fick {count, plural, one {ett svar} other {# svar}}.", "annual_report.summary.highlighted_post.title": "Mest populära inlägg", "annual_report.summary.most_used_app.most_used_app": "mest använda app", @@ -705,7 +705,7 @@ "filter_modal.select_filter.title": "Filtrera detta inlägg", "filter_modal.title.status": "Filtrera ett inlägg", "filter_warning.matches_filter": "Matchar filtret \"{title}\"", - "filtered_notifications_banner.pending_requests": "Från {count, plural, =0 {ingen} one {en person} other {# personer}} du kanske känner", + "filtered_notifications_banner.pending_requests": "Från {count, plural, =0 {ingen} one {en person} other {# personer}} som du kanske känner", "filtered_notifications_banner.title": "Filtrerade aviseringar", "firehose.all": "Allt", "firehose.local": "Denna server", @@ -767,7 +767,7 @@ "hashtag.mute": "Tysta #{hashtag}", "hashtag.unfeature": "Visa inte på profil", "hashtag.unfollow": "Avfölj hashtagg", - "hashtags.and_other": "…och {count, plural, one {}other {# mer}}", + "hashtags.and_other": "…och {count, plural, one {# till} other {# till}}", "hints.profiles.followers_may_be_missing": "Det kan saknas vissa följare av denna profil.", "hints.profiles.follows_may_be_missing": "Det kan saknas vissa följare av denna profil.", "hints.profiles.posts_may_be_missing": "Det kan saknas vissa följare för denna profil.", @@ -948,7 +948,7 @@ "notification.annual_report.view": "Visa #Wrapstodon", "notification.collection_update": "{name} redigerade en samling du är med i", "notification.favourite": "{name} favoritmarkerade ditt inlägg", - "notification.favourite.name_and_others_with_link": "{name} och {count, plural, one {# annan} other {# andra}} har favoritmarkerat ditt inlägg", + "notification.favourite.name_and_others_with_link": "{name} och {count, plural, one {# annan} other {# andra}} favoritmarkerade ditt inlägg", "notification.favourite_pm": "{name} favoritmarkerade ditt privata omnämnande", "notification.favourite_pm.name_and_others_with_link": "{name} och {count, plural, one {# annan} other {# andra}} favoritmarkerade ditt privata omnämnande", "notification.follow": "{name} följer dig", @@ -975,7 +975,7 @@ "notification.poll": "En enkät som du röstat i har avslutats", "notification.quoted_update": "{name} redigerade ett inlägg du har citerat", "notification.reblog": "{name} boostade ditt inlägg", - "notification.reblog.name_and_others_with_link": "{name} och {count, plural, one {# annan} other {# andra}} har förhöjt ditt inlägg", + "notification.reblog.name_and_others_with_link": "{name} och {count, plural, one {# annan} other {# andra}} boostade ditt inlägg", "notification.relationships_severance_event": "Förlorade kontakter med {name}", "notification.relationships_severance_event.account_suspension": "En administratör från {from} har stängt av {target}, vilket innebär att du inte längre kan ta emot uppdateringar från dem eller interagera med dem.", "notification.relationships_severance_event.domain_block": "En administratör från {from} har blockerat {target}, inklusive {followersCount} av dina följare och {followingCount, plural, one {# konto} other {# konton}} du följer.", @@ -989,7 +989,7 @@ "notification_requests.confirm_accept_multiple.message": "Du håller på att acceptera {count, plural, one {en förfrågan} other {# förfrågningar}} om avisering. Är du säker på att du vill fortsätta?", "notification_requests.confirm_accept_multiple.title": "Vill du acceptera aviseringsförfrågningar?", "notification_requests.confirm_dismiss_multiple.button": "Avvisa {count, plural, one {# förfrågan} other {# förfrågningar}}", - "notification_requests.confirm_dismiss_multiple.message": "Du håller på att avfärda {count, plural, one {en begäran} other {# begäran}} om aviseringar. Du kommer inte enkelt att kunna komma åt {count, plural, one {det} other {dem}} igen. Är du säker på att du vill fortsätta?", + "notification_requests.confirm_dismiss_multiple.message": "Du håller på att avfärda {count, plural, one {en aviseringsförfrågan} other {# aviseringsförfrågningar}}. Du kommer inte enkelt att kunna komma åt {count, plural, one {den} other {dem}} igen. Är du säker på att du vill fortsätta?", "notification_requests.confirm_dismiss_multiple.title": "Vill du acceptera aviseringsförfrågningar?", "notification_requests.dismiss": "Avfärda", "notification_requests.dismiss_multiple": "Avvisa {count, plural, one {# förfrågan} other {# förfrågningar}}...", @@ -1050,7 +1050,7 @@ "notifications.policy.filter_hint": "Skicka till inkorgen för filtrerade aviserings", "notifications.policy.filter_limited_accounts_hint": "Begränsade av servermoderatorer", "notifications.policy.filter_limited_accounts_title": "Modererade konton", - "notifications.policy.filter_new_accounts.hint": "Skapad inom de senaste {days, plural, one {dagen} other {# dagarna}}", + "notifications.policy.filter_new_accounts.hint": "Skapade under de senaste {days, plural, one {# dagen} other {# dagarna}}", "notifications.policy.filter_new_accounts_title": "Nya konton", "notifications.policy.filter_not_followers_hint": "Inklusive personer som har följt dig kortare än {days, plural, one {en dag} other {# dagar}}", "notifications.policy.filter_not_followers_title": "Personer som inte följer dig", @@ -1072,7 +1072,7 @@ "onboarding.profile.display_name": "Visningsnamn", "onboarding.profile.display_name_hint": "Fullständigt namn eller ditt roliga namn…", "onboarding.profile.finish": "Avsluta", - "onboarding.profile.note": "Bio", + "onboarding.profile.note": "Biografi", "onboarding.profile.note_hint": "Du kan @nämna andra personer eller #hashtags…", "onboarding.profile.title": "Konfiguration av profil", "onboarding.profile.upload_avatar": "Ladda upp profilbild", @@ -1227,7 +1227,7 @@ "status.admin_account": "Öppet modereringsgränssnitt för @{name}", "status.admin_domain": "Öppet modereringsgränssnitt för @{domain}", "status.admin_status": "Öppna detta inlägg i modereringsgränssnittet", - "status.all_disabled": "Booster och citat är inaktiverade", + "status.all_disabled": "Boostar och citat är inaktiverade", "status.block": "Blockera @{name}", "status.bookmark": "Bokmärk", "status.cancel_reblog_private": "Sluta boosta", @@ -1259,7 +1259,7 @@ "status.load_more": "Ladda fler", "status.media.open": "Klicka för att öppna", "status.media.show": "Klicka för att visa", - "status.media_hidden": "Media dold", + "status.media_hidden": "Media dolt", "status.mention": "Omnämn @{name}", "status.more": "Mer", "status.mute": "Tysta @{name}", @@ -1335,7 +1335,7 @@ "time_remaining.minutes": "{number, plural, one {# minut} other {# minuter}} kvar", "time_remaining.moments": "Återstående tillfällen", "time_remaining.seconds": "{number, plural, one {# sekund} other {# sekunder}} kvar", - "trends.counter_by_accounts": "{count, plural, one {{counter} person} other {{counter} personer}} senaste {days, plural, one {dygnet} other {{days} dagarna}}", + "trends.counter_by_accounts": "{count, plural, one {{counter} person} other {{counter} personer}} under de senaste {days, plural, one {dygnet} other {{days} dagarna}}", "trends.trending_now": "Trendar nu", "ui.beforeunload": "Ditt utkast kommer att förloras om du lämnar Mastodon.", "units.short.billion": "{count}B", @@ -1378,7 +1378,7 @@ "visibility_modal.helper.privacy_private_self_quote": "Självcitat av privata inlägg kan inte göras publika.", "visibility_modal.helper.private_quoting": "Inlägg som endast är för följare och som författats på Mastodon kan inte citeras av andra.", "visibility_modal.helper.unlisted_quoting": "När folk citerar dig, deras inlägg kommer också att döljas från trendiga tidslinjer.", - "visibility_modal.instructions": "Kontrollera vem som kan interagera med detta inlägg. Du kan också använda inställningar för alla framtida inlägg genom att navigera till Preferences > Posting defaults.", + "visibility_modal.instructions": "Styr vem som kan interagera med det här inlägget. Du kan också använda inställningarna för alla framtida inlägg genom att gå till Inställningar > Standardvärden för inlägg.", "visibility_modal.privacy_label": "Synlighet", "visibility_modal.quote_followers": "Endast följare", "visibility_modal.quote_label": "Vem kan citera", diff --git a/app/javascript/mastodon/locales/vi.json b/app/javascript/mastodon/locales/vi.json index 0dc04cce16..5928b17d95 100644 --- a/app/javascript/mastodon/locales/vi.json +++ b/app/javascript/mastodon/locales/vi.json @@ -267,6 +267,7 @@ "admin.impact_report.instance_followers": "Người theo dõi của thành viên máy chủ sẽ bị mất", "admin.impact_report.instance_follows": "Người mà thành viên máy chủ theo dõi sẽ bị mất", "admin.impact_report.title": "Mô tả ảnh hưởng", + "alert.need_reload.message": "Mastodon vừa được cập nhật. Vài thứ có thể hoạt động không đúng cho tới khi bạn tải lên trang.", "alert.rate_limited.message": "Vui lòng thử lại sau {retry_time, time, medium}.", "alert.rate_limited.title": "Vượt giới hạn", "alert.unexpected.message": "Đã xảy ra lỗi không mong muốn.", diff --git a/app/javascript/mastodon/locales/zh-CN.json b/app/javascript/mastodon/locales/zh-CN.json index d550291910..0313af7551 100644 --- a/app/javascript/mastodon/locales/zh-CN.json +++ b/app/javascript/mastodon/locales/zh-CN.json @@ -153,7 +153,7 @@ "account_edit.advanced_settings.title": "高级设置", "account_edit.bio.add_label": "添加个人简介", "account_edit.bio.edit_label": "编辑个人简介", - "account_edit.bio.placeholder": "添加一段简短介绍,帮助其他人认识你。", + "account_edit.bio.placeholder": "添加一段简短介绍,让别人认识你。", "account_edit.bio.title": "个人简介", "account_edit.bio_modal.add_title": "添加个人简介", "account_edit.bio_modal.edit_title": "编辑个人简介", diff --git a/app/javascript/mastodon/models/account.ts b/app/javascript/mastodon/models/account.ts index ccb6f47621..8a14674ce4 100644 --- a/app/javascript/mastodon/models/account.ts +++ b/app/javascript/mastodon/models/account.ts @@ -11,7 +11,7 @@ import type { import { unescapeHTML } from 'mastodon/utils/html'; import { CustomEmojiFactory } from './custom_emoji'; -import type { CustomEmoji } from './custom_emoji'; +import type { CustomEmoji, CustomEmojiShape } from './custom_emoji'; // AccountField export interface AccountFieldShape extends Required { @@ -59,7 +59,7 @@ export type AccountShapeFull = Omit< AccountShape, 'emojis' | 'fields' | 'roles' > & { - emojis: CustomEmoji[]; + emojis: CustomEmojiShape[]; fields: AccountFieldShape[]; roles: AccountRoleShape[]; }; diff --git a/app/javascript/mastodon/models/custom_emoji.ts b/app/javascript/mastodon/models/custom_emoji.ts index 19ca951a5c..0588de1282 100644 --- a/app/javascript/mastodon/models/custom_emoji.ts +++ b/app/javascript/mastodon/models/custom_emoji.ts @@ -3,7 +3,7 @@ import { Record as ImmutableRecord, isList } from 'immutable'; import type { ApiCustomEmojiJSON } from 'mastodon/api_types/custom_emoji'; -type CustomEmojiShape = Required; // no changes from server shape +export type CustomEmojiShape = Required; // no changes from server shape export type CustomEmoji = RecordOf; export const CustomEmojiFactory = ImmutableRecord({ diff --git a/app/javascript/mastodon/reducers/slices/profile_edit.ts b/app/javascript/mastodon/reducers/slices/profile_edit.ts index bc463ac1bd..83963fe49a 100644 --- a/app/javascript/mastodon/reducers/slices/profile_edit.ts +++ b/app/javascript/mastodon/reducers/slices/profile_edit.ts @@ -1,5 +1,7 @@ import { createSlice } from '@reduxjs/toolkit'; +import type { CamelCase } from 'type-fest'; + import { fetchAccount } from '@/mastodon/actions/accounts'; import { apiDeleteFeaturedTag, @@ -26,13 +28,12 @@ import { createDataLoadingThunk, } from '@/mastodon/store/typed_functions'; import { hashObjectArray } from '@/mastodon/utils/hash'; -import type { SnakeToCamelCase } from '@/mastodon/utils/types'; type ProfileData = { [Key in keyof Omit< ApiProfileJSON, 'note' | 'fields' | 'featured_tags' - > as SnakeToCamelCase]: ApiProfileJSON[Key]; + > as CamelCase]: ApiProfileJSON[Key]; } & { bio: ApiProfileJSON['note']; fields: FieldData[]; @@ -45,7 +46,7 @@ export type TagData = { [Key in keyof Omit< ApiFeaturedTagJSON, 'statuses_count' - > as SnakeToCamelCase]: ApiFeaturedTagJSON[Key]; + > as CamelCase]: ApiFeaturedTagJSON[Key]; } & { statusesCount: number; }; diff --git a/app/javascript/mastodon/utils/objects.test.ts b/app/javascript/mastodon/utils/objects.test.ts index 5c08cd0561..2b1852edc7 100644 --- a/app/javascript/mastodon/utils/objects.test.ts +++ b/app/javascript/mastodon/utils/objects.test.ts @@ -2,13 +2,13 @@ import { getNestedProperty } from './objects'; describe('getNestedProperty', () => { + const obj = { a: { b: { c: 42 } } } as const; + test('returns the value of a nested property if it exists', () => { - const obj = { a: { b: { c: 42 } } }; expect(getNestedProperty(obj, 'a', 'b', 'c')).toBe(42); }); test('returns undefined if any part of the path does not exist', () => { - const obj = { a: { b: { c: 42 } } }; expect(getNestedProperty(obj, 'a', 'x', 'c')).toBeUndefined(); expect(getNestedProperty(obj, 'a', 'b', 'x')).toBeUndefined(); expect(getNestedProperty(obj, 'x', 'b', 'c')).toBeUndefined(); @@ -20,8 +20,7 @@ describe('getNestedProperty', () => { expect(getNestedProperty('string', 'a', 'b')).toBeUndefined(); }); - test('returns undefined if no keys are provided', () => { - const obj = { a: 1 }; - expect(getNestedProperty(obj)).toBeUndefined(); + test('returns the object if no keys are provided', () => { + expect(getNestedProperty({ a: 1 })).toStrictEqual({ a: 1 }); }); }); diff --git a/app/javascript/mastodon/utils/objects.ts b/app/javascript/mastodon/utils/objects.ts index 4430849c0c..7eca227643 100644 --- a/app/javascript/mastodon/utils/objects.ts +++ b/app/javascript/mastodon/utils/objects.ts @@ -1,52 +1,37 @@ import { isPlainObject } from '@reduxjs/toolkit'; -export type RecordObject = Record; +import type { Get, IsUnknown, UnknownRecord } from 'type-fest'; -export function isRecordObject(obj: unknown): obj is RecordObject { +export function isRecordObject(obj: unknown): obj is UnknownRecord { return isPlainObject(obj); } -type NestedProperty = K extends readonly [ - infer Head, - ...infer Tail, -] - ? Head extends keyof NonNullable - ? Tail extends readonly PropertyKey[] - ? NestedProperty[Head], Tail> - : NonNullable[Head] - : undefined - : T; +type NestedProperty = + IsUnknown extends true + ? unknown + : IsUnknown> extends true + ? undefined + : Get; +export function getNestedProperty(object: TObject): TObject; export function getNestedProperty< - TObject extends RecordObject, - const TKeys extends readonly PropertyKey[], ->(object: TObject, ...keys: TKeys): NestedProperty | undefined; -export function getNestedProperty( - object: unknown, - ...keys: PropertyKey[] -): unknown; -export function getNestedProperty( - object: unknown, - ...keys: PropertyKey[] -): unknown { - if (!isRecordObject(object) || keys.length === 0) { - return undefined; + TObject, + const TKeys extends readonly string[], +>(object: TObject, ...keys: TKeys): NestedProperty; +export function getNestedProperty(object: unknown, ...keys: readonly string[]) { + if (keys.length === 0) { + return object; } - const remainingKeys = [...keys]; - let currentObject: RecordObject = object; - while (remainingKeys.length > 0) { - const currentKey = remainingKeys.shift(); - if (currentKey !== undefined && currentKey in currentObject) { - const nextObject = currentObject[currentKey]; - if (isRecordObject(nextObject)) { - currentObject = nextObject; - continue; - } else if (remainingKeys.length === 0) { - return nextObject; - } + let currentValue = object; + + for (const key of keys) { + if (!isRecordObject(currentValue) || !(key in currentValue)) { + return undefined; } + + currentValue = currentValue[key]; } - return undefined; + return currentValue; } diff --git a/app/javascript/mastodon/utils/types.ts b/app/javascript/mastodon/utils/types.ts index c6922210b4..4da4368100 100644 --- a/app/javascript/mastodon/utils/types.ts +++ b/app/javascript/mastodon/utils/types.ts @@ -1,41 +1,5 @@ -/** - * Extend an existing type and make some of its properties required or optional. - * @example - * interface Person { - * name: string; - * age?: number; - * likesIceCream?: boolean; - * } - * - * type PersonWithSomeRequired = SomeRequired; - * type PersonWithSomeOptional = SomeOptional; - */ +import type { SetOptional } from 'type-fest'; -export type DeepPartial = T extends object - ? { - [K in keyof T]?: DeepPartial; - } - : T; - -export type SomeRequired = T & Required>; -export type SomeOptional = Pick> & - Partial>; - -export type RequiredExcept = SomeOptional, K>; - -export type OmitValueType = { - [K in keyof T as T[K] extends V ? never : K]: T[K]; -}; - -export type OmitUnion = TBase & Omit; - -export type PickValueType = { - [K in keyof T as T[K] extends V | undefined ? K : never]: T[K]; -}; +export type RequiredExcept = SetOptional, K>; export type AnyFunction = (...args: never) => unknown; - -export type SnakeToCamelCase = - S extends `${infer T}_${infer U}` - ? `${T}${Capitalize>}` - : S; diff --git a/app/javascript/styles/mastodon/components.scss b/app/javascript/styles/mastodon/components.scss index 3cde41242e..18effe35ab 100644 --- a/app/javascript/styles/mastodon/components.scss +++ b/app/javascript/styles/mastodon/components.scss @@ -1620,6 +1620,7 @@ body > [data-popover-placement] { content: ''; position: absolute; inset: 0; + z-index: -1; background: var(--color-bg-brand-softest); opacity: 0; animation: fade 0.7s reverse both 0.3s; diff --git a/app/javascript/testing/api.ts b/app/javascript/testing/api.ts index ad980a8da9..ec75098d29 100644 --- a/app/javascript/testing/api.ts +++ b/app/javascript/testing/api.ts @@ -4,13 +4,13 @@ import { action } from 'storybook/actions'; import { toSupportedLocale } from '@/mastodon/features/emoji/locale'; -import { customEmojiFactory, relationshipsFactory } from './factories'; +import { customEmojiFactory, relationshipsFactoryAPI } from './factories'; export const mockHandlers = { mute: http.post<{ id: string }>('/api/v1/accounts/:id/mute', ({ params }) => { action('muting account')(params); return HttpResponse.json( - relationshipsFactory({ id: params.id, muting: true }), + relationshipsFactoryAPI({ id: params.id, muting: true }), ); }), unmute: http.post<{ id: string }>( @@ -18,7 +18,7 @@ export const mockHandlers = { ({ params }) => { action('unmuting account')(params); return HttpResponse.json( - relationshipsFactory({ id: params.id, muting: false }), + relationshipsFactoryAPI({ id: params.id, muting: false }), ); }, ), @@ -27,7 +27,7 @@ export const mockHandlers = { ({ params }) => { action('blocking account')(params); return HttpResponse.json( - relationshipsFactory({ id: params.id, blocking: true }), + relationshipsFactoryAPI({ id: params.id, blocking: true }), ); }, ), @@ -36,7 +36,7 @@ export const mockHandlers = { ({ params }) => { action('unblocking account')(params); return HttpResponse.json( - relationshipsFactory({ + relationshipsFactoryAPI({ id: params.id, blocking: false, }), diff --git a/app/javascript/testing/factories.ts b/app/javascript/testing/factories.ts index bcd61e3065..77a7a719c9 100644 --- a/app/javascript/testing/factories.ts +++ b/app/javascript/testing/factories.ts @@ -1,5 +1,7 @@ import { fromJS } from 'immutable'; +import type { PartialDeep } from 'type-fest'; + import { normalizeStatus } from '@/mastodon/actions/importer/statuses'; import type { ApiAudioAttachmentJSON, @@ -10,25 +12,38 @@ import type { BaseApiMediaAttachmentJSON, } from '@/mastodon/api_types/media_attachments'; import type { ApiPollJSON } from '@/mastodon/api_types/polls'; +import type { ApiQuotedStatusJSON } from '@/mastodon/api_types/quotes'; import type { ApiRelationshipJSON } from '@/mastodon/api_types/relationships'; import type { ApiStatusJSON } from '@/mastodon/api_types/statuses'; import type { CustomEmojiData, UnicodeEmojiData, } from '@/mastodon/features/emoji/types'; -import { createAccountFromServerJSON } from '@/mastodon/models/account'; +import type { AccountShapeFull } from '@/mastodon/models/account'; +import { + accountDefaultValues, + createAccountFromServerJSON, +} from '@/mastodon/models/account'; import type { AnnualReport } from '@/mastodon/models/annual_report'; +import { CustomEmojiFactory } from '@/mastodon/models/custom_emoji'; +import type { Poll } from '@/mastodon/models/poll'; import type { Status } from '@/mastodon/models/status'; -import type { DeepPartial } from '@/mastodon/utils/types'; import type { ApiAccountJSON } from 'mastodon/api_types/accounts'; +/** + * Naming conventions for factories: + * - API responses should be `*FactoryAPI` + * - Plain JS objects in state should be `*FactoryState` + * - Immutable factories should be `*FactoryImmutable` + */ + type FactoryOptions = { id?: string; } & Partial; type FactoryFunction = (options?: FactoryOptions) => T; -export const accountFactory: FactoryFunction = ({ +export const accountFactoryAPI: FactoryFunction = ({ id, ...data } = {}) => ({ @@ -75,9 +90,35 @@ export const accountFactory: FactoryFunction = ({ export const accountFactoryState = ( options: FactoryOptions = {}, -) => createAccountFromServerJSON(accountFactory(options)); +): AccountShapeFull => { + const accountJSON = accountFactoryAPI(options); + return { + ...accountJSON, + ...accountDefaultValues, + moved: accountJSON.moved?.id ?? null, + display_name_html: accountJSON.display_name, + note_emojified: accountJSON.note, + note_plain: accountJSON.note, + emojis: accountJSON.emojis.map((emoji) => ({ + category: '', + featured: false, + ...emoji, + })), + fields: accountJSON.fields.map((field) => ({ + name_emojified: field.name, + value_emojified: field.value, + value_plain: field.value, + ...field, + })), + roles: accountJSON.roles ?? [], + }; +}; -export const statusFactory: FactoryFunction = ({ +export const accountFactoryImmutable = ( + options: FactoryOptions = {}, +) => createAccountFromServerJSON(accountFactoryAPI(options)); + +export const statusFactoryAPI: FactoryFunction = ({ id, ...data } = {}) => ({ @@ -92,7 +133,7 @@ export const statusFactory: FactoryFunction = ({ reblogs_count: 0, quotes_count: 0, favourites_count: 0, - account: accountFactory(), + account: accountFactoryAPI(), media_attachments: [], mentions: [], tags: [], @@ -108,7 +149,25 @@ export const statusFactory: FactoryFunction = ({ export const statusFactoryState = ( options: FactoryOptions = {}, -) => fromJS(normalizeStatus(statusFactory(options))) as unknown as Status; +) => normalizeStatus(statusFactoryAPI(options)); + +export const statusFactoryImmutable = ( + options: FactoryOptions = {}, +) => fromJS(statusFactoryState(options)) as unknown as Status; // Convert to unknown to avoid excessive type recursion + +export const statusQuotedFactoryAPI: FactoryFunction = ( + options = {}, +) => { + const { quote, ...status } = options; + return { + ...statusFactoryAPI(status), + quote: quote + ? { + ...quote, + } + : undefined, + }; +}; const baseAttachment = { id: '1', @@ -136,11 +195,11 @@ const colorsMeta = { } as const; type MediaFactoryArg = Omit< - DeepPartial, + PartialDeep, 'type' >; -export const imageAttachmentFactory = ( +export const imageAttachmentFactoryAPI = ( data: MediaFactoryArg = {}, ): ApiImageAttachmentJSON => ({ ...baseAttachment, @@ -152,7 +211,7 @@ export const imageAttachmentFactory = ( }, }); -export const videoAttachmentFactory = ( +export const videoAttachmentFactoryAPI = ( data: MediaFactoryArg = {}, ): ApiVideoAttachmentJSON => ({ ...baseAttachment, @@ -170,7 +229,7 @@ export const videoAttachmentFactory = ( }, }); -export const audioAttachmentFactory = ( +export const audioAttachmentFactoryAPI = ( data: MediaFactoryArg = {}, ): ApiAudioAttachmentJSON => ({ ...baseAttachment, @@ -183,7 +242,7 @@ export const audioAttachmentFactory = ( }, }); -export const gifvAttachmentFactory = ( +export const gifvAttachmentFactoryAPI = ( data: MediaFactoryArg = {}, ): ApiGifvAttachmentJSON => ({ ...baseAttachment, @@ -195,24 +254,26 @@ export const gifvAttachmentFactory = ( }, }); -export function mediaAttachmentFactory( - data: DeepPartial = {}, +export function mediaAttachmentFactoryAPI( + data: PartialDeep = {}, ): ApiMediaAttachmentJSON { switch (data.type ?? 'image') { case 'image': - return imageAttachmentFactory( - data as DeepPartial, + return imageAttachmentFactoryAPI( + data as PartialDeep, ); case 'video': - return videoAttachmentFactory( - data as DeepPartial, + return videoAttachmentFactoryAPI( + data as PartialDeep, ); case 'audio': - return audioAttachmentFactory( - data as DeepPartial, + return audioAttachmentFactoryAPI( + data as PartialDeep, ); case 'gifv': - return gifvAttachmentFactory(data as DeepPartial); + return gifvAttachmentFactoryAPI( + data as PartialDeep, + ); default: { return { ...baseAttachment, @@ -224,7 +285,7 @@ export function mediaAttachmentFactory( } } -export const pollFactory: FactoryFunction = (data = {}) => ({ +export const pollFactoryAPI: FactoryFunction = (data = {}) => ({ id: '1', expires_at: '', expired: false, @@ -246,7 +307,21 @@ export const pollFactory: FactoryFunction = (data = {}) => ({ ...data, }); -export const relationshipsFactory: FactoryFunction = ({ +export const pollFactoryImmutable = ( + data: FactoryOptions = {}, +): Poll => ({ + ...pollFactoryAPI(data), + emojis: data.emojis?.map(CustomEmojiFactory) ?? [], + options: + data.options?.map((option) => ({ + voted: false, + titleHtml: option.title, + translation: null, + ...option, + })) ?? [], +}); + +export const relationshipsFactoryAPI: FactoryFunction = ({ id, ...data } = {}) => ({ @@ -311,7 +386,7 @@ interface AnnualReportFactoryOptions { without_posts?: boolean; } -export function annualReportFactory({ +export function annualReportFactoryState({ account_id = '1', status_id = '1', archetype = 'lurker', diff --git a/app/models/keypair.rb b/app/models/keypair.rb index 891d8dca24..35cd801c9d 100644 --- a/app/models/keypair.rb +++ b/app/models/keypair.rb @@ -4,16 +4,17 @@ # # Table name: keypairs # -# id :bigint(8) not null, primary key -# expires_at :datetime -# private_key :string -# public_key :string not null -# revoked :boolean default(FALSE), not null -# type :integer not null -# uri :string not null -# created_at :datetime not null -# updated_at :datetime not null -# account_id :bigint(8) not null +# id :bigint(8) not null, primary key +# expires_at :datetime +# local_fragment :string +# private_key :string +# public_key :string not null +# revoked :boolean default(FALSE), not null +# type :integer not null +# uri :string +# created_at :datetime not null +# updated_at :datetime not null +# account_id :bigint(8) not null # class Keypair < ApplicationRecord @@ -32,7 +33,12 @@ class Keypair < ApplicationRecord attr_accessor :require_private_key - validates :uri, presence: true, uniqueness: true + validates :uri, presence: true, uniqueness: true, if: -> { account.remote? } + validates :uri, absence: true, if: -> { account.local? } + + validates :local_fragment, presence: true, uniqueness: { scope: :account_id }, format: { with: /\A#[A-Z0-9-]+\Z/i }, if: -> { account.local? } + validates :local_fragment, absence: true, if: -> { account.remote? } + validates :public_key, presence: true validates :private_key, presence: true, if: -> { account.local? } @@ -60,6 +66,8 @@ class Keypair < ApplicationRecord end def self.from_keyid(uri) + return if uri.blank? + keypair = find_by(uri: uri) return keypair unless keypair.nil? diff --git a/config/locales/be.yml b/config/locales/be.yml index 8bab4d36f7..3cb5ae81eb 100644 --- a/config/locales/be.yml +++ b/config/locales/be.yml @@ -2025,6 +2025,7 @@ be: next: Далей older: Старэйшае prev: Папярэдні + truncate_html: "…" polls: errors: already_voted: Вы ўжо прагаласавалі ў апытанні diff --git a/config/locales/da.yml b/config/locales/da.yml index d029c88709..273830e9dd 100644 --- a/config/locales/da.yml +++ b/config/locales/da.yml @@ -1935,6 +1935,7 @@ da: next: Næste older: Ældre prev: Foregående + truncate_html: "…" polls: errors: already_voted: Du har allerede stemt i denne afstemning diff --git a/config/locales/de.yml b/config/locales/de.yml index 9396bb7e28..712bf5132f 100644 --- a/config/locales/de.yml +++ b/config/locales/de.yml @@ -1936,6 +1936,7 @@ de: next: Weiter older: Älter prev: Zurück + truncate_html: "…" polls: errors: already_voted: An dieser Umfrage hast du bereits teilgenommen diff --git a/config/locales/es-AR.yml b/config/locales/es-AR.yml index c5aadfaafc..6f71f2a6b4 100644 --- a/config/locales/es-AR.yml +++ b/config/locales/es-AR.yml @@ -1935,6 +1935,7 @@ es-AR: next: Siguiente older: Más antiguos prev: Anterior + truncate_html: "…" polls: errors: already_voted: Ya votaste en esta encuesta diff --git a/config/locales/es-MX.yml b/config/locales/es-MX.yml index 316591d51f..e2d6d781ea 100644 --- a/config/locales/es-MX.yml +++ b/config/locales/es-MX.yml @@ -1935,6 +1935,7 @@ es-MX: next: Próximo older: Más antiguo prev: Anterior + truncate_html: "…" polls: errors: already_voted: Ya has votado en esta encuesta diff --git a/config/locales/es.yml b/config/locales/es.yml index 345c8f10d7..484e334086 100644 --- a/config/locales/es.yml +++ b/config/locales/es.yml @@ -1937,6 +1937,7 @@ es: next: Próximo older: Más antiguo prev: Anterior + truncate_html: "…" polls: errors: already_voted: Ya has votado en esta encuesta diff --git a/config/locales/fi.yml b/config/locales/fi.yml index 213ddc731c..5db313834e 100644 --- a/config/locales/fi.yml +++ b/config/locales/fi.yml @@ -724,6 +724,8 @@ fi: new: title: Luo uusi IP-⁠sääntö no_ip_block_selected: IP-sääntöjä ei muutettu, koska yhtään ei ollut valittuna + reset: Palauta + search: Hae title: IP-säännöt relationships: title: Tilin %{acct} seurantasuhteet @@ -1919,6 +1921,7 @@ fi: next: Seuraava older: Vanhemmat prev: Edellinen + truncate_html: "…" polls: errors: already_voted: Olet jo osallistunut tähän äänestykseen diff --git a/config/locales/fr-CA.yml b/config/locales/fr-CA.yml index ab3a1c955b..c82e76ee02 100644 --- a/config/locales/fr-CA.yml +++ b/config/locales/fr-CA.yml @@ -1935,6 +1935,7 @@ fr-CA: next: Suivant older: Plus ancien prev: Précédent + truncate_html: "…" polls: errors: already_voted: Vous avez déjà voté sur ce sondage diff --git a/config/locales/fr.yml b/config/locales/fr.yml index 742378bd9e..b91cef6864 100644 --- a/config/locales/fr.yml +++ b/config/locales/fr.yml @@ -1935,9 +1935,10 @@ fr: next: Suivant older: Plus ancien prev: Précédent + truncate_html: "…" polls: errors: - already_voted: Vous avez déjà voté sur ce sondage + already_voted: Vous avez déjà participé à ce sondage duplicate_options: contient des doublons duration_too_long: est trop loin dans le futur duration_too_short: est trop tôt diff --git a/config/locales/ga.yml b/config/locales/ga.yml index 46e4108a94..11300c8fc3 100644 --- a/config/locales/ga.yml +++ b/config/locales/ga.yml @@ -2072,6 +2072,7 @@ ga: next: An céad eile older: Níos sine prev: Ceann roimhe seo + truncate_html: "…" polls: errors: already_voted: Tá tú tar éis vótáil ar an vótaíocht seo cheana féin diff --git a/config/locales/gl.yml b/config/locales/gl.yml index c218a469ff..04cd7bf5ca 100644 --- a/config/locales/gl.yml +++ b/config/locales/gl.yml @@ -1935,6 +1935,7 @@ gl: next: Seguinte older: Máis antigo prev: Previo + truncate_html: "…" polls: errors: already_voted: Xa votaches nesta enquisa diff --git a/config/locales/he.yml b/config/locales/he.yml index 155373a88c..0b5e659115 100644 --- a/config/locales/he.yml +++ b/config/locales/he.yml @@ -2025,6 +2025,7 @@ he: next: הבא older: ישן יותר prev: הקודם + truncate_html: "…" polls: errors: already_voted: כבר הצבעת בסקר זה diff --git a/config/locales/it.yml b/config/locales/it.yml index e52242b585..d98eb3df40 100644 --- a/config/locales/it.yml +++ b/config/locales/it.yml @@ -1935,6 +1935,7 @@ it: next: Avanti older: Più vecchio prev: Indietro + truncate_html: "…" polls: errors: already_voted: Hai già votato in questo sondaggio diff --git a/config/locales/nan-TW.yml b/config/locales/nan-TW.yml index 3618bc1468..07ab500b3e 100644 --- a/config/locales/nan-TW.yml +++ b/config/locales/nan-TW.yml @@ -1890,6 +1890,7 @@ nan-TW: next: 後一頁 older: 較舊ê prev: 頂一頁 + truncate_html: "…" polls: errors: already_voted: Lí有投票ah @@ -2185,7 +2186,35 @@ nan-TW: follow_request: 跟tuè請求電子phue mention: 提起通知電子phue reblog: 轉送通知電子phue + show: + action: 取消訂 + email_subscription: + confirmation_html: 當tsit ê口座刊出新PO文ê時,汝bē koh收著電子phue。 + title: Kám beh取消訂 %{name}? + user: + confirmation_html: Lí ē停止收著對 %{domain} 來ê Mastodon ê %{type}。 + title: Kám beh取消訂 %{type}? user_mailer: + announcement_published: + description: "%{domain} ê管理員leh發布公告:" + subject: 服務公告 + title: "%{domain} 服務公告" + appeal_approved: + action: 口座ê設定 + explanation: Lí佇 %{appeal_date} 對kā lí ê口座佇 %{strike_date} 處份ê投訴已經受允准。Lí ê口座koh轉去好ê狀態。 + subject: Lí佇 %{date} ê投訴有受允准 + subtitle: Lí ê口座koh轉去好ê狀態。 + title: 申訴受批准 + appeal_rejected: + explanation: Lí佇 %{appeal_date} 對kā lí ê口座佇 %{strike_date} 處份ê投訴已經受拒絕。 + subject: Lí佇 %{date} ê投訴有受拒絕 + subtitle: Lí ê投訴已經受拒絕。 + title: 投訴受拒絕 + backup_ready: + explanation: Lí要求完整備份lí ê Mastodon口座。 + extra: 備辦好勢,通載落去! + subject: Lí ê備份檔案ē當載落去 + title: 輸出備份檔 terms_of_service_changed: description: Lí收著tsit張電子phue,是因為gún佇 %{domain} teh修改服務規定。Tsiah ê更新會佇 %{date} 施行。Gún鼓勵lí佇tsia讀kui篇更新ê規定: description_html: Lí收著tsit張電子phue,是因為gún佇 %{domain} teh修改服務規定。Tsiah ê更新會佇 %{date} 施行。Gún鼓勵lí佇tsia讀kui篇更新ê規定: diff --git a/config/locales/pt-BR.yml b/config/locales/pt-BR.yml index c6cc370367..6b9d8bdc27 100644 --- a/config/locales/pt-BR.yml +++ b/config/locales/pt-BR.yml @@ -1936,6 +1936,7 @@ pt-BR: next: Próximo older: Mais antigo prev: Anterior + truncate_html: "…" polls: errors: already_voted: Enquete votada diff --git a/config/locales/simple_form.sv.yml b/config/locales/simple_form.sv.yml index 0782838615..bd44e017b5 100644 --- a/config/locales/simple_form.sv.yml +++ b/config/locales/simple_form.sv.yml @@ -65,7 +65,7 @@ sv: setting_display_media_hide_all: Varna innan du visar alla medier setting_display_media_show_all: Visa alla medier utan varning, inklusive media markerad som känslig setting_emoji_style: Hur emojier visas. "Automatiskt" kommer att försöka använda webbläsarens emojier, men faller tillbaka till Twemoji för äldre webbläsare. - setting_quick_boosting_html: När aktiverad, klicka på %{boost_icon} Boost-ikonen för att omedelbart boosta istället för att öppna boost/citera-rullgardinsmenyn. Flyttar citering till %{options_icon} (Alternativ)-menyn. + setting_quick_boosting_html: När detta är aktiverat boostas inlägget direkt när du klickar på ikonen %{boost_icon} Boosta, i stället för att öppna rullgardinsmenyn för boost/citat. Citatåtgärden flyttas till menyn %{options_icon} (Alternativ). setting_use_blurhash: Gradienter är baserade på färgerna av de dolda objekten men fördunklar alla detaljer setting_use_pending_items: Dölj tidslinjeuppdateringar bakom ett klick istället för att automatiskt bläddra i flödet username: Du kan använda bokstäver, siffror och understreck @@ -89,7 +89,7 @@ sv: backups_retention_period: Användare har möjlighet att generera arkiv av sina inlägg för att ladda ned senare. När det sätts till ett positivt värde raderas dessa arkiv automatiskt från din lagring efter det angivna antalet dagar. bootstrap_timeline_accounts: Dessa konton kommer att fästas på toppen av nya användares följ-rekommendationer. Ange en kommaseparerad lista över konton. closed_registrations_message: Visas när nyregistreringar är avstängda - content_cache_retention_period: Alla inlägg från andra servrar (inklusive booster och svar) kommer att raderas efter det angivna antalet dagar, utan hänsyn till någon lokal användarinteraktion med dessa inlägg. Detta inkluderar inlägg där en lokal användare har markerat det som bokmärke eller favoriter. Privata omnämnanden mellan användare från olika instanser kommer också att gå förlorade och blir omöjliga att återställa. Användningen av denna inställning är avsedd för specialfall och bryter många användarförväntningar när de implementeras för allmänt bruk. + content_cache_retention_period: Alla inlägg från andra servrar (inklusive boostar och svar) raderas efter det angivna antalet dagar, utan hänsyn till lokal användarinteraktion med dessa inlägg. Det gäller även inlägg som en lokal användare har lagt till som bokmärke eller favorit. Privata omnämnanden mellan användare på olika instanser går också förlorade och kan inte återställas. Den här inställningen är avsedd för specialiserade instanser och bryter mot många användares förväntningar om den används på allmänna instanser. custom_css: Du kan använda anpassade stilar på webbversionen av Mastodon. email_footer_text: Valfri text som endast visas i sidfoten av e-post om nyhetsbrev. favicon: WEBP, PNG, GIF eller JPG. Används på mobila enheter istället för appens egen ikon. @@ -243,7 +243,7 @@ sv: setting_aggregate_reblogs: Gruppera boostar i tidslinjer setting_always_send_emails: Skicka alltid e-postnotiser setting_auto_play_gif: Spela upp GIF:ar automatiskt - setting_boost_modal: Kontrollera boost-synlighet + setting_boost_modal: Styr synligheten för boostar setting_color_scheme: Färgschema setting_contrast: Kontrast setting_default_language: Inläggsspråk @@ -261,7 +261,7 @@ sv: setting_expand_spoilers: Utöka alltid tutningar markerade med innehållsvarningar setting_hide_network: Göm ditt nätverk setting_missing_alt_text_modal: Varna mig innan jag gör mediainlägg utan alt-text - setting_quick_boosting: Aktivera snabb-boostande + setting_quick_boosting: Aktivera snabb boostning setting_reduce_motion: Minska rörelser i animationer setting_system_font_ui: Använd systemets standardfont setting_system_scrollbars_ui: Använd systemets standardrullningsfält diff --git a/config/locales/sv.yml b/config/locales/sv.yml index 5eaec623b0..c75ec0e803 100644 --- a/config/locales/sv.yml +++ b/config/locales/sv.yml @@ -954,7 +954,7 @@ sv: title: Undantag användare från sökmotorindexering som standard discovery: follow_recommendations: Följrekommendationer - preamble: Att visa intressant innehåll är avgörande för nya användare som kanske inte känner någon på Mastodon. Styr hur olika upptäcktsfunktioner fungerar på din Server. + preamble: Att visa intressant innehåll är viktigt för att introducera nya användare som kanske inte känner någon på Mastodon. Styr hur olika upptäcktsfunktioner fungerar på din server. privacy: Integritet profile_directory: Profilkatalog public_timelines: Offentliga tidslinjer @@ -1194,7 +1194,7 @@ sv: confirm_allow_account: Är du säker på att du vill tillåta valda konton? confirm_disallow: Är du säker på att du vill förbjuda valda statusar? confirm_disallow_account: Är du säker på att du vill förbjuda valda konton? - description_html: Detta är inlägg som din server vet om som för närvarande delas och favoriseras mycket just nu. Det kan hjälpa dina nya och återvändande användare att hitta fler människor att följa. Inga inlägg visas offentligt förrän du godkänner författaren, och författaren tillåter att deras konto föreslås till andra. Du kan också tillåta eller avvisa enskilda inlägg. + description_html: Detta är inlägg som din server vet om som för närvarande delas och favoritmarkeras mycket just nu. Det kan hjälpa dina nya och återvändande användare att hitta fler människor att följa. Inga inlägg visas offentligt förrän du godkänner författaren, och författaren tillåter att deras konto föreslås till andra. Du kan också tillåta eller avvisa enskilda inlägg. disallow: Tillåt inte inlägg disallow_account: Tillåt inte författare no_status_selected: Inga trendande inlägg ändrades eftersom inga valdes @@ -1322,7 +1322,7 @@ sv: advanced_settings: Avancerade inställningar animations_and_accessibility: Animationer och tillgänglighet boosting_preferences: Boostinställningar - boosting_preferences_info_html: "Tips: Oavsett inställningar kommer Skifttangenten + Klick på %{icon} boostikonen att boosta omedelbart." + boosting_preferences_info_html: "Tips: Oavsett inställningar kommer Skift + Klick på %{icon} Boosta-ikonen att boosta direkt." discovery: Upptäck localization: body: Mastodon översätts av volontärer. @@ -1801,7 +1801,7 @@ sv: media_attachments: validations: images_and_video: Det går inte att bifoga en video till ett inlägg som redan innehåller bilder - not_found: Media %{ids} hittades inte eller är redan anslutet till ett annat inlägg + not_found: Media %{ids} hittades inte eller har redan bifogats till ett annat inlägg not_ready: Kan inte bifoga filer som inte har behandlats färdigt. Försök igen om ett ögonblick! too_many: Det går inte att bifoga mer än 4 filer migrations: @@ -1935,6 +1935,7 @@ sv: next: Nästa older: Äldre prev: Tidigare + truncate_html: "…" polls: errors: already_voted: Du har redan röstat på den här undersökningen @@ -2068,7 +2069,7 @@ sv: delete: Konto radering development: Utveckling edit_profile: Redigera profil - export: Export + export: Exportera featured_tags: Utvalda hashtaggar import: Importera import_and_export: Import och export @@ -2150,7 +2151,7 @@ sv: ignore_favs: Bortse från favoriter ignore_reblogs: Ignorera boostar interaction_exceptions: Undantag baserat på interaktioner - interaction_exceptions_explanation: Inlägg som tillfälligt överskrider favorit- eller höjningströskeln kan behållas även om de senare minskas. + interaction_exceptions_explanation: Inlägg som tillfälligt överskrider favorit- eller boosttröskeln kan behållas även om de senare minskas. keep_direct: Behåll direktmeddelanden keep_direct_hint: Tar inte bort någon av dina direktmeddelanden keep_media: Behåll inlägg med mediebilagor @@ -2229,11 +2230,11 @@ sv: user: confirmation_html: Du får inte längre %{type} från Mastodon på %{domain}. notification_emails: - favourite: aviseringsmejl för favoriserade inlägg + favourite: aviseringsmejl om favoriter follow: aviseringsmejl för följda inlägg follow_request: aviseringsmejl för följdförfrågningar mention: aviseringsmejl för inlägg där du nämns - reblog: aviseringsmejl för förhöjda inlägg + reblog: aviseringsmejl om boostar show: action: Avprenumerera email_subscription: diff --git a/config/locales/vi.yml b/config/locales/vi.yml index e1a6567b4b..8e8a2c526a 100644 --- a/config/locales/vi.yml +++ b/config/locales/vi.yml @@ -1890,6 +1890,7 @@ vi: next: Kế tiếp older: Cũ hơn prev: Trước đó + truncate_html: "…" polls: errors: already_voted: Bạn đã vốt xong rồi diff --git a/config/locales/zh-CN.yml b/config/locales/zh-CN.yml index 66c48f0ec9..4d2d523f17 100644 --- a/config/locales/zh-CN.yml +++ b/config/locales/zh-CN.yml @@ -1890,6 +1890,7 @@ zh-CN: next: 下一页 older: 更早 prev: 上一页 + truncate_html: "…" polls: errors: already_voted: 你已经在这里投过票了 diff --git a/config/locales/zh-TW.yml b/config/locales/zh-TW.yml index afe9035a9e..1262af7b1c 100644 --- a/config/locales/zh-TW.yml +++ b/config/locales/zh-TW.yml @@ -1894,6 +1894,7 @@ zh-TW: next: 下一頁 older: 較舊 prev: 上一頁 + truncate_html: "…" polls: errors: already_voted: 您已經投過票了 diff --git a/db/migrate/20260629124055_add_new_index_on_uri_to_keypairs.rb b/db/migrate/20260629124055_add_new_index_on_uri_to_keypairs.rb new file mode 100644 index 0000000000..ba40bc0979 --- /dev/null +++ b/db/migrate/20260629124055_add_new_index_on_uri_to_keypairs.rb @@ -0,0 +1,9 @@ +# frozen_string_literal: true + +class AddNewIndexOnUriToKeypairs < ActiveRecord::Migration[8.1] + disable_ddl_transaction! + + def change + add_index :keypairs, :uri, name: :index_keypairs_on_non_null_uri, unique: true, where: 'uri IS NOT NULL', algorithm: :concurrently + end +end diff --git a/db/migrate/20260629124613_remove_old_index_on_uri_from_keypair.rb b/db/migrate/20260629124613_remove_old_index_on_uri_from_keypair.rb new file mode 100644 index 0000000000..42b507b4a9 --- /dev/null +++ b/db/migrate/20260629124613_remove_old_index_on_uri_from_keypair.rb @@ -0,0 +1,9 @@ +# frozen_string_literal: true + +class RemoveOldIndexOnUriFromKeypair < ActiveRecord::Migration[8.1] + disable_ddl_transaction! + + def change + remove_index :keypairs, :uri, name: :index_keypairs_on_uri, unique: true, algorithm: :concurrently + end +end diff --git a/db/migrate/20260629124918_change_keypair_uri_non_nullable.rb b/db/migrate/20260629124918_change_keypair_uri_non_nullable.rb new file mode 100644 index 0000000000..6c08577c7c --- /dev/null +++ b/db/migrate/20260629124918_change_keypair_uri_non_nullable.rb @@ -0,0 +1,7 @@ +# frozen_string_literal: true + +class ChangeKeypairUriNonNullable < ActiveRecord::Migration[8.1] + def change + change_column_null :keypairs, :uri, true + end +end diff --git a/db/migrate/20260629125635_add_local_fragment_to_keypair.rb b/db/migrate/20260629125635_add_local_fragment_to_keypair.rb new file mode 100644 index 0000000000..0a89e78f04 --- /dev/null +++ b/db/migrate/20260629125635_add_local_fragment_to_keypair.rb @@ -0,0 +1,7 @@ +# frozen_string_literal: true + +class AddLocalFragmentToKeypair < ActiveRecord::Migration[8.1] + def change + add_column :keypairs, :local_fragment, :string, null: true + end +end diff --git a/db/migrate/20260629125939_add_index_account_id_local_fragment_to_keypair.rb b/db/migrate/20260629125939_add_index_account_id_local_fragment_to_keypair.rb new file mode 100644 index 0000000000..7e25c6adde --- /dev/null +++ b/db/migrate/20260629125939_add_index_account_id_local_fragment_to_keypair.rb @@ -0,0 +1,9 @@ +# frozen_string_literal: true + +class AddIndexAccountIdLocalFragmentToKeypair < ActiveRecord::Migration[8.1] + disable_ddl_transaction! + + def change + add_index :keypairs, [:account_id, :local_fragment], unique: true, where: 'local_fragment IS NOT NULL', algorithm: :concurrently + end +end diff --git a/db/schema.rb b/db/schema.rb index a9ae30fba3..43ce595195 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema[8.1].define(version: 2026_06_18_114230) do +ActiveRecord::Schema[8.1].define(version: 2026_06_29_125939) do # These are extensions that must be enabled in order to support this database enable_extension "pg_catalog.plpgsql" @@ -705,14 +705,16 @@ ActiveRecord::Schema[8.1].define(version: 2026_06_18_114230) do t.bigint "account_id", null: false t.datetime "created_at", null: false t.datetime "expires_at" + t.string "local_fragment" t.string "private_key" t.string "public_key", null: false t.boolean "revoked", default: false, null: false t.integer "type", null: false t.datetime "updated_at", null: false - t.string "uri", null: false + t.string "uri" + t.index ["account_id", "local_fragment"], name: "index_keypairs_on_account_id_and_local_fragment", unique: true, where: "(local_fragment IS NOT NULL)" t.index ["account_id"], name: "index_keypairs_on_account_id" - t.index ["uri"], name: "index_keypairs_on_uri", unique: true + t.index ["uri"], name: "index_keypairs_on_non_null_uri", unique: true, where: "(uri IS NOT NULL)" end create_table "list_accounts", force: :cascade do |t| diff --git a/lib/mastodon/cli/media.rb b/lib/mastodon/cli/media.rb index 4a1e757406..2f076c714a 100644 --- a/lib/mastodon/cli/media.rb +++ b/lib/mastodon/cli/media.rb @@ -273,11 +273,12 @@ module Mastodon::CLI def lookup(url) path = Addressable::URI.parse(url).path - path_segments = path.split('/')[2..] - path_segments.delete('cache') + path_segments = path.split('/') + segment_count = VALID_PATH_SEGMENTS_SIZE.find { |n| n <= path_segments.length && PRELOADED_MODELS.include?(path_segments[-n].classify) } - fail_with_message 'Not a media URL' unless VALID_PATH_SEGMENTS_SIZE.include?(path_segments.size) + fail_with_message 'Not a media URL' unless segment_count + path_segments = path_segments[-segment_count..] model_name = path_segments.first.classify record_id = path_segments[2...-2].join.to_i diff --git a/package.json b/package.json index 992bee0f14..de22b2b284 100644 --- a/package.json +++ b/package.json @@ -181,6 +181,7 @@ "storybook": "^10.3.0", "stylelint": "^17.0.0", "stylelint-config-standard-scss": "^17.0.0", + "type-fest": "^5.7.0", "typescript": "~6.0.0", "typescript-eslint": "^8.55.0", "typescript-plugin-css-modules": "^5.2.0", diff --git a/spec/fabricators/keypair_fabricator.rb b/spec/fabricators/keypair_fabricator.rb index 5eae3872d2..a871f0dae1 100644 --- a/spec/fabricators/keypair_fabricator.rb +++ b/spec/fabricators/keypair_fabricator.rb @@ -12,7 +12,11 @@ Fabricator(:keypair) do revoked false after_build do |keypair| - keypair.uri ||= ActivityPub::TagManager.instance.key_uri_for(keypair.account) - keypair.private_key ||= private_key if keypair.account.local? + if keypair.account.local? + keypair.private_key ||= private_key + keypair.local_fragment ||= "##{Random.hex}" + else + keypair.uri ||= ActivityPub::TagManager.instance.key_uri_for(keypair.account) + end end end diff --git a/yarn.lock b/yarn.lock index 41810336de..b4f7f22629 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2428,15 +2428,6 @@ __metadata: languageName: node linkType: hard -"@floating-ui/core@npm:^1.4.2": - version: 1.5.0 - resolution: "@floating-ui/core@npm:1.5.0" - dependencies: - "@floating-ui/utils": "npm:^0.1.3" - checksum: 10c0/bca811cefd09c3f56c4cf58c3e94826c1ce4a0b40124e9030ddca2ef1cc68b4ddc5ba5b4d7cc94c9555aea6876d2428a77a2ae261fe5b39c79df247a9518b053 - languageName: node - linkType: hard - "@floating-ui/core@npm:^1.7.5": version: 1.7.5 resolution: "@floating-ui/core@npm:1.7.5" @@ -2446,17 +2437,7 @@ __metadata: languageName: node linkType: hard -"@floating-ui/dom@npm:^1.0.1": - version: 1.5.3 - resolution: "@floating-ui/dom@npm:1.5.3" - dependencies: - "@floating-ui/core": "npm:^1.4.2" - "@floating-ui/utils": "npm:^0.1.3" - checksum: 10c0/e5f30b911f939e40003851077bba441f269ae689bdc43c674bee43aa98fc6b7a5f59be432d27b7be599b1e4ab7b15c752875ea777a89cff01d157e593b78b25b - languageName: node - linkType: hard - -"@floating-ui/dom@npm:^1.7.6": +"@floating-ui/dom@npm:^1.0.1, @floating-ui/dom@npm:^1.7.6": version: 1.7.6 resolution: "@floating-ui/dom@npm:1.7.6" dependencies: @@ -2478,13 +2459,6 @@ __metadata: languageName: node linkType: hard -"@floating-ui/utils@npm:^0.1.3": - version: 0.1.6 - resolution: "@floating-ui/utils@npm:0.1.6" - checksum: 10c0/0a089db0e0526b89e83cb0a773a903517db5c9067cd473febfd8fa91a3a2ccbc3a835234796c1bb528def21dbb67be50e28d9c473cb58a6d90679d7e549b9c0c - languageName: node - linkType: hard - "@floating-ui/utils@npm:^0.2.11": version: 0.2.11 resolution: "@floating-ui/utils@npm:0.2.11" @@ -3065,6 +3039,7 @@ __metadata: tesseract.js: "npm:^7.0.0" tiny-queue: "npm:^0.2.1" twitter-text: "npm:3.1.0" + type-fest: "npm:^5.7.0" typescript: "npm:~6.0.0" typescript-eslint: "npm:^8.55.0" typescript-plugin-css-modules: "npm:^5.2.0" @@ -9476,13 +9451,13 @@ __metadata: linkType: hard "js-yaml@npm:^4.1.0": - version: 4.2.0 - resolution: "js-yaml@npm:4.2.0" + version: 4.3.0 + resolution: "js-yaml@npm:4.3.0" dependencies: argparse: "npm:^2.0.1" bin: js-yaml: bin/js-yaml.js - checksum: 10c0/1916456c118746603b067d74bbcbb0445d9a1d5e474ad4ae775e7b20525bed902e01d9d97dd0c81fcd8d4f596162309d0eb057f4aa38f3e9647f14075e9dea45 + checksum: 10c0/058b30473d6915ca5b4feb11e2f7d4d97242f98d00a798ed48dd90b46b7c640398afe9128c5db22c5300f8c6528fe2a174b9a93f351a70ebc28c6203938d8bff languageName: node linkType: hard @@ -14166,6 +14141,15 @@ __metadata: languageName: node linkType: hard +"type-fest@npm:^5.7.0": + version: 5.7.0 + resolution: "type-fest@npm:5.7.0" + dependencies: + tagged-tag: "npm:^1.0.0" + checksum: 10c0/f71ed17b753649421e419db8cc2e140f930333a1467b1d9cca2e0e4052900fd442f2360bae73f3a6bf9340d949ac46d9a1598c709b4c8089272e7624df9c8716 + languageName: node + linkType: hard + "type-is@npm:^2.0.1": version: 2.0.1 resolution: "type-is@npm:2.0.1"