Move isDefaultHeader and isDefaultAvatar to utils/accounts

Signed-off-by: marcin mikołajczak <git@mkljczk.pl>
This commit is contained in:
marcin mikołajczak 2022-12-13 00:08:33 +01:00
parent 761061c9a8
commit 6900b59697
9 changed files with 25 additions and 29 deletions

View file

@ -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 SvgIcon from 'soapbox/components/ui/icon/svg-icon';
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 SubscriptionButton from 'soapbox/features/ui/components/subscription-button';
import { useAppDispatch, useFeatures, useOwnAccount } from 'soapbox/hooks';
@ -29,7 +28,7 @@ import { normalizeAttachment } from 'soapbox/normalizers';
import { ChatKeys, useChats } from 'soapbox/queries/chats';
import { queryClient } from 'soapbox/queries/client';
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';

View file

@ -20,7 +20,6 @@ const messages = defineMessages({
delete: { id: 'column.aliases.delete', defaultMessage: 'Delete' },
});
const Aliases = () => {
const intl = useIntl();
const dispatch = useAppDispatch();

View file

@ -7,6 +7,7 @@ import { patchMe } from 'soapbox/actions/me';
import snackbar from 'soapbox/actions/snackbar';
import { Avatar, Button, Card, CardBody, Icon, Spinner, Stack, Text } from 'soapbox/components/ui';
import { useOwnAccount } from 'soapbox/hooks';
import { isDefaultAvatar } from 'soapbox/utils/accounts';
import resizeImage from 'soapbox/utils/resize-image';
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.' },
});
/** 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 dispatch = useDispatch();
const account = useOwnAccount();

View file

@ -8,6 +8,7 @@ import snackbar from 'soapbox/actions/snackbar';
import StillImage from 'soapbox/components/still-image';
import { Avatar, Button, Card, CardBody, Icon, Spinner, Stack, Text } from 'soapbox/components/ui';
import { useOwnAccount } from 'soapbox/hooks';
import { isDefaultHeader } from 'soapbox/utils/accounts';
import resizeImage from 'soapbox/utils/resize-image';
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.' },
});
/** 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 intl = useIntl();
const dispatch = useDispatch();

View file

@ -45,7 +45,6 @@ const messages = defineMessages({
cancelEditing: { id: 'confirmations.cancel_editing.confirm', defaultMessage: 'Cancel editing' },
});
interface IAccount {
eventId: string,
id: string,

View file

@ -56,7 +56,6 @@ const DirectMessageUpdates = () => {
</defs>
</svg>
<Text weight='bold'>Privacy Policy Updates</Text>
</HStack>

View file

@ -1,7 +1,6 @@
import React, { useCallback, useEffect, useMemo, useState } from 'react';
import { defineMessages, FormattedMessage, useIntl } from 'react-intl';
import { blockAccount } from 'soapbox/actions/accounts';
import { submitReport, submitReportSuccess, submitReportFail } from 'soapbox/actions/reports';
import { expandAccountTimeline } from 'soapbox/actions/timelines';

View file

@ -7,7 +7,6 @@ import { play, soundCache } from 'soapbox/utils/sounds';
import type { ThunkMiddleware } from 'redux-thunk';
import type { Sounds } from 'soapbox/utils/sounds';
interface Action extends AnyAction {
meta: {
sound: Sounds

View file

@ -32,3 +32,25 @@ export const isLocal = (account: Account): boolean => {
};
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));
};