[Glitch] Compose side fixes

Port 9830f6d361 to glitch-soc

Signed-off-by: Claire <claire.github-309c@sitedethib.com>
This commit is contained in:
Echo authored and Claire committed 2026-07-30 21:58:33 +02:00
1 parent cca2302f0d
commit 29bc678141
7 files changed
+31 -20

No files matched your search

@@ -24,6 +24,7 @@ export interface ApiImageAttachmentJSON extends BaseApiMediaAttachmentJSON {
meta: {
original: ApiImageAttachmentMetaJSON;
small: ApiImageAttachmentMetaJSON;
focus?: ApiFocusAttachmentMetaJSON;
};
}
@@ -42,10 +43,7 @@ export interface ApiVideoAttachmentJSON extends BaseApiMediaAttachmentJSON {
colors: ApiColorsAttachmentMetaJSON;
original: ApiVideoAttachmentMetaJSON;
small: ApiImageAttachmentMetaJSON;
focus: {
x: number;
y: number;
};
focus?: ApiFocusAttachmentMetaJSON;
};
}
@@ -54,6 +52,7 @@ export interface ApiGifvAttachmentJSON extends BaseApiMediaAttachmentJSON {
meta: {
original: ApiVideoAttachmentMetaJSON;
small: ApiImageAttachmentMetaJSON;
focus?: ApiFocusAttachmentMetaJSON;
};
}
@@ -89,3 +88,8 @@ export interface ApiColorsAttachmentMetaJSON {
foreground: string;
accent: string;
}
export interface ApiFocusAttachmentMetaJSON {
x: number;
y: number;
}
@@ -23,12 +23,12 @@ export const textAtCursorMatchesToken = (
word = word.trim();
if (word.length < 3 || (word[0] && !searchTokens.includes(word[0]))) {
return [null, null];
return [null, null] as const;
}
if (word.length > 0) {
return [left + 1, word];
return [left + 1, word] as const;
} else {
return [null, null];
return [null, null] as const;
}
};
@@ -153,7 +153,7 @@ const AutosuggestTextarea = forwardRef(({
}
}, [lang]);
const renderSuggestion = (suggestion, i) => {
const renderSuggestion = useCallback((suggestion, i) => {
let inner, key;
if (suggestion.type === 'emoji') {
@@ -172,7 +172,7 @@ const AutosuggestTextarea = forwardRef(({
{inner}
</div>
);
};
}, [selectedSuggestion, handleSuggestionClick]);
const handleRef = useCallback((element) => {
textareaRef.current = element;
@@ -95,13 +95,18 @@ export interface PopoverProps {
* enable it to be sized and positioned. The `ref` prop
* is not passed when the `popoverElement` prop is provided.
*/
props: Record<string, unknown> & {
ref?: React.RefCallback<HTMLElement>;
style: React.CSSProperties;
};
props: PopoverChildProps;
}) => React.ReactNode;
}
export interface PopoverChildProps {
ref?: React.RefCallback<HTMLElement>;
style: React.CSSProperties;
'data-popover-placement': Placement;
'data-popover-reference-hidden'?: boolean;
'data-popover-escaped'?: boolean;
}
export const Popover: React.FC<PopoverProps> = ({
isOpen,
onClose,
@@ -56,13 +56,15 @@ const getFrequentlyUsedLanguages = createSelector(
const isTextLongEnoughForGuess = (text: string) => text.length > 20;
const LanguageDropdownMenu: React.FC<{
const emptyArray: Language[] = [];
export const LanguageDropdownMenu: React.FC<{
value: string;
guess?: string;
guess: string;
onClose: () => void;
onChange: (arg0: string) => void;
}> = ({ value, guess, onClose, onChange }) => {
const languages = preloadedLanguages as Language[];
const languages = preloadedLanguages ?? emptyArray;
const intl = useIntl();
const [searchValue, setSearchValue] = useState('');
const nodeRef = useRef<HTMLDivElement>(null);
@@ -317,7 +319,7 @@ export const LanguageDropdown: React.FC = () => {
const text = useAppSelector((state) => state.compose.get('text') as string);
const current =
(preloadedLanguages as Language[]).find((lang) => lang[0] === value) ?? [];
(preloadedLanguages ?? []).find((lang) => lang[0] === value) ?? [];
const handleMouseDown = useCallback(() => {
if (!open && document.activeElement instanceof HTMLElement) {
@@ -1,9 +1,9 @@
import { Map as ImmutableMap } from 'immutable';
import { Map as ImmutableMap, List as ImmutableList } from 'immutable';
import { STORE_HYDRATE } from '../actions/store';
const initialState = ImmutableMap({
accept_content_types: [],
accept_content_types: ImmutableList(),
});
export default function meta(state = initialState, action) {
@@ -30,7 +30,7 @@ export const selectPlainStatus = createAppSelector(
export const selectAccountStatus = createAppSelector(
[
selectPlainStatus,
(state, statusId: string) => {
(state, statusId?: string | null) => {
const accountId = state.statuses.getIn([statusId, 'account']);
if (typeof accountId !== 'string') {
return null;