Skip to content

Commit 3932362

Browse files
committed
Merge remote-tracking branch 'mastodon/main' into hota/master
2 parents 37f752d + 8e00f7c commit 3932362

37 files changed

Lines changed: 582 additions & 509 deletions

app/controllers/severed_relationships_controller.rb

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,13 @@ def index
1313

1414
def following
1515
respond_to do |format|
16-
format.csv { send_data following_data, filename: "following-#{@event.target_name}-#{@event.created_at.to_date.iso8601}.csv" }
16+
format.csv { send_data following_data, filename: }
1717
end
1818
end
1919

2020
def followers
2121
respond_to do |format|
22-
format.csv { send_data followers_data, filename: "followers-#{@event.target_name}-#{@event.created_at.to_date.iso8601}.csv" }
22+
format.csv { send_data followers_data, filename: }
2323
end
2424
end
2525

@@ -48,4 +48,8 @@ def followers_data
4848
def acct(account)
4949
account.local? ? account.local_username_and_domain : account.acct
5050
end
51+
52+
def filename
53+
"#{action_name}-#{@event.identifier}.csv"
54+
end
5155
end

app/javascript/mastodon/components/account/index.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ interface AccountProps {
7575
withMenu?: boolean;
7676
withBorder?: boolean;
7777
extraAccountInfo?: React.ReactNode;
78+
className?: string;
7879
children?: React.ReactNode;
7980
}
8081

@@ -88,6 +89,7 @@ export const Account: React.FC<AccountProps> = ({
8889
withMenu = true,
8990
withBorder = true,
9091
extraAccountInfo,
92+
className,
9193
children,
9294
}) => {
9395
const intl = useIntl();
@@ -290,7 +292,7 @@ export const Account: React.FC<AccountProps> = ({
290292

291293
return (
292294
<div
293-
className={classNames('account', {
295+
className={classNames('account', className, {
294296
'account--minimal': minimal,
295297
'account--without-border': !withBorder,
296298
})}

app/javascript/mastodon/components/callout/styles.module.css

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
background-color: var(--color-bg-brand-softest);
77
color: var(--color-text-primary);
88
border-radius: 12px;
9+
font-size: 15px;
910
}
1011

1112
.icon {

app/javascript/mastodon/components/callout_inline/index.tsx

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,11 @@ import ErrorIcon from '@/material-icons/400-24px/error.svg?react';
77
import InfoIcon from '@/material-icons/400-24px/info.svg?react';
88
import WarningIcon from '@/material-icons/400-24px/warning.svg?react';
99

10+
import type { FieldStatus } from '../form_fields/form_field_wrapper';
1011
import { Icon } from '../icon';
1112

1213
import classes from './styles.module.css';
1314

14-
export interface FieldStatus {
15-
variant: 'error' | 'warning' | 'info' | 'success';
16-
message?: string;
17-
}
18-
1915
const iconMap: Record<FieldStatus['variant'], React.FunctionComponent> = {
2016
error: ErrorIcon,
2117
warning: WarningIcon,

app/javascript/mastodon/components/character_counter/index.tsx

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
import { useMemo } from 'react';
2-
31
import { FormattedMessage } from 'react-intl';
42

53
import classNames from 'classnames';
64

5+
import { length } from 'stringz';
6+
77
import { polymorphicForwardRef } from '@/types/polymorphic';
88

99
import classes from './styles.module.scss';
@@ -14,8 +14,6 @@ interface CharacterCounterProps {
1414
recommended?: boolean;
1515
}
1616

17-
const segmenter = new Intl.Segmenter();
18-
1917
export const CharacterCounter = polymorphicForwardRef<
2018
'span',
2119
CharacterCounterProps
@@ -31,10 +29,7 @@ export const CharacterCounter = polymorphicForwardRef<
3129
},
3230
ref,
3331
) => {
34-
const currentLength = useMemo(
35-
() => [...segmenter.segment(currentString)].length,
36-
[currentString],
37-
);
32+
const currentLength = length(currentString);
3833
return (
3934
<Component
4035
{...props}

app/javascript/mastodon/components/counters.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ export const StatusesCounter = (
1313
count: pluralReady,
1414
counter: <strong>{displayNumber}</strong>,
1515
}}
16+
tagName='span'
1617
/>
1718
);
1819

@@ -27,6 +28,7 @@ export const FollowingCounter = (
2728
count: pluralReady,
2829
counter: <strong>{displayNumber}</strong>,
2930
}}
31+
tagName='span'
3032
/>
3133
);
3234

@@ -41,6 +43,7 @@ export const FollowersCounter = (
4143
count: pluralReady,
4244
counter: <strong>{displayNumber}</strong>,
4345
}}
46+
tagName='span'
4447
/>
4548
);
4649

@@ -55,5 +58,6 @@ export const FollowersYouKnowCounter = (
5558
count: pluralReady,
5659
counter: <strong>{displayNumber}</strong>,
5760
}}
61+
tagName='span'
5862
/>
5963
);

app/javascript/mastodon/components/form_fields/emoji_text_field.tsx

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,9 @@ import type {
22
ChangeEvent,
33
ChangeEventHandler,
44
ComponentPropsWithoutRef,
5-
Dispatch,
65
FC,
76
ReactNode,
87
RefObject,
9-
SetStateAction,
108
} from 'react';
119
import { useCallback, useId, useRef } from 'react';
1210

@@ -25,7 +23,7 @@ import { TextInput } from './text_input_field';
2523

2624
export type EmojiInputProps = {
2725
value?: string;
28-
onChange?: Dispatch<SetStateAction<string>>;
26+
onChange?: (newValue: string) => void;
2927
counterMax?: number;
3028
recommended?: boolean;
3129
} & Omit<CommonFieldWrapperProps, 'wrapperClassName'>;
@@ -138,12 +136,15 @@ const EmojiFieldWrapper: FC<
138136

139137
const handlePickEmoji = useCallback(
140138
(emoji: string) => {
141-
onChange?.((prev) => {
142-
const position = inputRef.current?.selectionStart ?? prev.length;
143-
return insertEmojiAtPosition(prev, emoji, position);
144-
});
139+
if (!value) {
140+
onChange?.('');
141+
return;
142+
}
143+
const position = inputRef.current?.selectionStart ?? value.length;
144+
const newValue = insertEmojiAtPosition(value, emoji, position);
145+
onChange?.(newValue);
145146
},
146-
[onChange, inputRef],
147+
[inputRef, value, onChange],
147148
);
148149

149150
const handleChange = useCallback(

app/javascript/mastodon/components/form_fields/fieldset.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@ import type { ReactNode, FC } from 'react';
44
import { createContext, useId } from 'react';
55

66
import { A11yLiveRegion } from 'mastodon/components/a11y_live_region';
7-
import type { FieldStatus } from 'mastodon/components/callout_inline';
87
import { CalloutInline } from 'mastodon/components/callout_inline';
98

109
import classes from './fieldset.module.scss';
10+
import type { FieldStatus } from './form_field_wrapper';
1111
import { getFieldStatus } from './form_field_wrapper';
1212
import formFieldWrapperClasses from './form_field_wrapper.module.scss';
1313

app/javascript/mastodon/components/form_fields/form_field_wrapper.tsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import { FormattedMessage } from 'react-intl';
88
import classNames from 'classnames';
99

1010
import { A11yLiveRegion } from 'mastodon/components/a11y_live_region';
11-
import type { FieldStatus } from 'mastodon/components/callout_inline';
1211
import { CalloutInline } from 'mastodon/components/callout_inline';
1312

1413
import { FieldsetNameContext } from './fieldset';
@@ -20,11 +19,16 @@ export interface InputProps {
2019
'aria-describedby'?: string;
2120
}
2221

22+
export interface FieldStatus {
23+
variant: 'error' | 'warning' | 'info' | 'success';
24+
message?: string;
25+
}
26+
2327
interface FieldWrapperProps {
2428
label: ReactNode;
2529
hint?: ReactNode;
2630
required?: boolean;
27-
status?: FieldStatus['variant'] | FieldStatus;
31+
status?: FieldStatus['variant'] | FieldStatus | null;
2832
inputId?: string;
2933
describedById?: string;
3034
inputPlacement?: 'inline-start' | 'inline-end';

app/javascript/mastodon/components/form_fields/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
export type { FieldStatus } from './form_field_wrapper';
12
export { FormFieldWrapper } from './form_field_wrapper';
23
export { FormStack } from './form_stack';
34
export { Fieldset } from './fieldset';

0 commit comments

Comments
 (0)