Move isDefaultHeader and isDefaultAvatar to utils/accounts
Signed-off-by: marcin mikołajczak <git@mkljczk.pl>
This commit is contained in:
parent
761061c9a8
commit
6900b59697
9 changed files with 25 additions and 29 deletions
|
@ -21,7 +21,6 @@ import StillImage from 'soapbox/components/still-image';
|
||||||
import { Avatar, HStack, IconButton, Menu, MenuButton, MenuDivider, MenuItem, MenuLink, MenuList } from 'soapbox/components/ui';
|
import { Avatar, HStack, IconButton, Menu, MenuButton, MenuDivider, MenuItem, MenuLink, MenuList } from 'soapbox/components/ui';
|
||||||
import SvgIcon from 'soapbox/components/ui/icon/svg-icon';
|
import SvgIcon from 'soapbox/components/ui/icon/svg-icon';
|
||||||
import MovedNote from 'soapbox/features/account-timeline/components/moved-note';
|
import MovedNote from 'soapbox/features/account-timeline/components/moved-note';
|
||||||
import { isDefaultHeader } from 'soapbox/features/onboarding/steps/cover-photo-selection-step';
|
|
||||||
import ActionButton from 'soapbox/features/ui/components/action-button';
|
import ActionButton from 'soapbox/features/ui/components/action-button';
|
||||||
import SubscriptionButton from 'soapbox/features/ui/components/subscription-button';
|
import SubscriptionButton from 'soapbox/features/ui/components/subscription-button';
|
||||||
import { useAppDispatch, useFeatures, useOwnAccount } from 'soapbox/hooks';
|
import { useAppDispatch, useFeatures, useOwnAccount } from 'soapbox/hooks';
|
||||||
|
@ -29,7 +28,7 @@ import { normalizeAttachment } from 'soapbox/normalizers';
|
||||||
import { ChatKeys, useChats } from 'soapbox/queries/chats';
|
import { ChatKeys, useChats } from 'soapbox/queries/chats';
|
||||||
import { queryClient } from 'soapbox/queries/client';
|
import { queryClient } from 'soapbox/queries/client';
|
||||||
import { Account } from 'soapbox/types/entities';
|
import { Account } from 'soapbox/types/entities';
|
||||||
import { isRemote } from 'soapbox/utils/accounts';
|
import { isDefaultHeader, isRemote } from 'soapbox/utils/accounts';
|
||||||
|
|
||||||
import type { Menu as MenuType } from 'soapbox/components/dropdown-menu';
|
import type { Menu as MenuType } from 'soapbox/components/dropdown-menu';
|
||||||
|
|
||||||
|
|
|
@ -20,7 +20,6 @@ const messages = defineMessages({
|
||||||
delete: { id: 'column.aliases.delete', defaultMessage: 'Delete' },
|
delete: { id: 'column.aliases.delete', defaultMessage: 'Delete' },
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
const Aliases = () => {
|
const Aliases = () => {
|
||||||
const intl = useIntl();
|
const intl = useIntl();
|
||||||
const dispatch = useAppDispatch();
|
const dispatch = useAppDispatch();
|
||||||
|
|
|
@ -7,6 +7,7 @@ import { patchMe } from 'soapbox/actions/me';
|
||||||
import snackbar from 'soapbox/actions/snackbar';
|
import snackbar from 'soapbox/actions/snackbar';
|
||||||
import { Avatar, Button, Card, CardBody, Icon, Spinner, Stack, Text } from 'soapbox/components/ui';
|
import { Avatar, Button, Card, CardBody, Icon, Spinner, Stack, Text } from 'soapbox/components/ui';
|
||||||
import { useOwnAccount } from 'soapbox/hooks';
|
import { useOwnAccount } from 'soapbox/hooks';
|
||||||
|
import { isDefaultAvatar } from 'soapbox/utils/accounts';
|
||||||
import resizeImage from 'soapbox/utils/resize-image';
|
import resizeImage from 'soapbox/utils/resize-image';
|
||||||
|
|
||||||
import type { AxiosError } from 'axios';
|
import type { AxiosError } from 'axios';
|
||||||
|
@ -15,17 +16,6 @@ const messages = defineMessages({
|
||||||
error: { id: 'onboarding.error', defaultMessage: 'An unexpected error occurred. Please try again or skip this step.' },
|
error: { id: 'onboarding.error', defaultMessage: 'An unexpected error occurred. Please try again or skip this step.' },
|
||||||
});
|
});
|
||||||
|
|
||||||
/** Default avatar filenames from various backends */
|
|
||||||
const DEFAULT_AVATARS = [
|
|
||||||
'/avatars/original/missing.png', // Mastodon
|
|
||||||
'/images/avi.png', // Pleroma
|
|
||||||
];
|
|
||||||
|
|
||||||
/** Check if the avatar is a default avatar */
|
|
||||||
const isDefaultAvatar = (url: string) => {
|
|
||||||
return DEFAULT_AVATARS.every(avatar => url.endsWith(avatar));
|
|
||||||
};
|
|
||||||
|
|
||||||
const AvatarSelectionStep = ({ onNext }: { onNext: () => void }) => {
|
const AvatarSelectionStep = ({ onNext }: { onNext: () => void }) => {
|
||||||
const dispatch = useDispatch();
|
const dispatch = useDispatch();
|
||||||
const account = useOwnAccount();
|
const account = useOwnAccount();
|
||||||
|
|
|
@ -8,6 +8,7 @@ import snackbar from 'soapbox/actions/snackbar';
|
||||||
import StillImage from 'soapbox/components/still-image';
|
import StillImage from 'soapbox/components/still-image';
|
||||||
import { Avatar, Button, Card, CardBody, Icon, Spinner, Stack, Text } from 'soapbox/components/ui';
|
import { Avatar, Button, Card, CardBody, Icon, Spinner, Stack, Text } from 'soapbox/components/ui';
|
||||||
import { useOwnAccount } from 'soapbox/hooks';
|
import { useOwnAccount } from 'soapbox/hooks';
|
||||||
|
import { isDefaultHeader } from 'soapbox/utils/accounts';
|
||||||
import resizeImage from 'soapbox/utils/resize-image';
|
import resizeImage from 'soapbox/utils/resize-image';
|
||||||
|
|
||||||
import type { AxiosError } from 'axios';
|
import type { AxiosError } from 'axios';
|
||||||
|
@ -17,17 +18,6 @@ const messages = defineMessages({
|
||||||
error: { id: 'onboarding.error', defaultMessage: 'An unexpected error occurred. Please try again or skip this step.' },
|
error: { id: 'onboarding.error', defaultMessage: 'An unexpected error occurred. Please try again or skip this step.' },
|
||||||
});
|
});
|
||||||
|
|
||||||
/** Default header filenames from various backends */
|
|
||||||
const DEFAULT_HEADERS = [
|
|
||||||
'/headers/original/missing.png', // Mastodon
|
|
||||||
'/images/banner.png', // Pleroma
|
|
||||||
];
|
|
||||||
|
|
||||||
/** Check if the avatar is a default avatar */
|
|
||||||
export const isDefaultHeader = (url: string) => {
|
|
||||||
return DEFAULT_HEADERS.some(header => url.endsWith(header));
|
|
||||||
};
|
|
||||||
|
|
||||||
const CoverPhotoSelectionStep = ({ onNext }: { onNext: () => void }) => {
|
const CoverPhotoSelectionStep = ({ onNext }: { onNext: () => void }) => {
|
||||||
const intl = useIntl();
|
const intl = useIntl();
|
||||||
const dispatch = useDispatch();
|
const dispatch = useDispatch();
|
||||||
|
|
|
@ -45,7 +45,6 @@ const messages = defineMessages({
|
||||||
cancelEditing: { id: 'confirmations.cancel_editing.confirm', defaultMessage: 'Cancel editing' },
|
cancelEditing: { id: 'confirmations.cancel_editing.confirm', defaultMessage: 'Cancel editing' },
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
interface IAccount {
|
interface IAccount {
|
||||||
eventId: string,
|
eventId: string,
|
||||||
id: string,
|
id: string,
|
||||||
|
|
|
@ -56,7 +56,6 @@ const DirectMessageUpdates = () => {
|
||||||
</defs>
|
</defs>
|
||||||
</svg>
|
</svg>
|
||||||
|
|
||||||
|
|
||||||
<Text weight='bold'>Privacy Policy Updates</Text>
|
<Text weight='bold'>Privacy Policy Updates</Text>
|
||||||
</HStack>
|
</HStack>
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
import React, { useCallback, useEffect, useMemo, useState } from 'react';
|
import React, { useCallback, useEffect, useMemo, useState } from 'react';
|
||||||
import { defineMessages, FormattedMessage, useIntl } from 'react-intl';
|
import { defineMessages, FormattedMessage, useIntl } from 'react-intl';
|
||||||
|
|
||||||
|
|
||||||
import { blockAccount } from 'soapbox/actions/accounts';
|
import { blockAccount } from 'soapbox/actions/accounts';
|
||||||
import { submitReport, submitReportSuccess, submitReportFail } from 'soapbox/actions/reports';
|
import { submitReport, submitReportSuccess, submitReportFail } from 'soapbox/actions/reports';
|
||||||
import { expandAccountTimeline } from 'soapbox/actions/timelines';
|
import { expandAccountTimeline } from 'soapbox/actions/timelines';
|
||||||
|
|
|
@ -7,7 +7,6 @@ import { play, soundCache } from 'soapbox/utils/sounds';
|
||||||
import type { ThunkMiddleware } from 'redux-thunk';
|
import type { ThunkMiddleware } from 'redux-thunk';
|
||||||
import type { Sounds } from 'soapbox/utils/sounds';
|
import type { Sounds } from 'soapbox/utils/sounds';
|
||||||
|
|
||||||
|
|
||||||
interface Action extends AnyAction {
|
interface Action extends AnyAction {
|
||||||
meta: {
|
meta: {
|
||||||
sound: Sounds
|
sound: Sounds
|
||||||
|
|
|
@ -32,3 +32,25 @@ export const isLocal = (account: Account): boolean => {
|
||||||
};
|
};
|
||||||
|
|
||||||
export const isRemote = (account: Account): boolean => !isLocal(account);
|
export const isRemote = (account: Account): boolean => !isLocal(account);
|
||||||
|
|
||||||
|
/** Default header filenames from various backends */
|
||||||
|
const DEFAULT_HEADERS = [
|
||||||
|
'/headers/original/missing.png', // Mastodon
|
||||||
|
'/images/banner.png', // Pleroma
|
||||||
|
];
|
||||||
|
|
||||||
|
/** Check if the avatar is a default avatar */
|
||||||
|
export const isDefaultHeader = (url: string) => {
|
||||||
|
return DEFAULT_HEADERS.some(header => url.endsWith(header));
|
||||||
|
};
|
||||||
|
|
||||||
|
/** Default avatar filenames from various backends */
|
||||||
|
const DEFAULT_AVATARS = [
|
||||||
|
'/avatars/original/missing.png', // Mastodon
|
||||||
|
'/images/avi.png', // Pleroma
|
||||||
|
];
|
||||||
|
|
||||||
|
/** Check if the avatar is a default avatar */
|
||||||
|
export const isDefaultAvatar = (url: string) => {
|
||||||
|
return DEFAULT_AVATARS.some(avatar => url.endsWith(avatar));
|
||||||
|
};
|
||||||
|
|
Loading…
Reference in a new issue