Merge branch 'madge' into 'main'
Resolve some circular imports See merge request soapbox-pub/soapbox!3171
This commit is contained in:
commit
b3dd9865ad
|
@ -0,0 +1,38 @@
|
||||||
|
import { AppDispatch, RootState } from 'soapbox/store';
|
||||||
|
import { getFeatures, parseVersion } from 'soapbox/utils/features';
|
||||||
|
|
||||||
|
import type { Status } from 'soapbox/types/entities';
|
||||||
|
|
||||||
|
export const COMPOSE_SET_STATUS = 'COMPOSE_SET_STATUS' as const;
|
||||||
|
|
||||||
|
export interface ComposeSetStatusAction {
|
||||||
|
type: typeof COMPOSE_SET_STATUS;
|
||||||
|
id: string;
|
||||||
|
status: Status;
|
||||||
|
rawText: string;
|
||||||
|
explicitAddressing: boolean;
|
||||||
|
spoilerText?: string;
|
||||||
|
contentType?: string | false;
|
||||||
|
v: ReturnType<typeof parseVersion>;
|
||||||
|
withRedraft?: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
|
export const setComposeToStatus = (status: Status, rawText: string, spoilerText?: string, contentType?: string | false, withRedraft?: boolean) =>
|
||||||
|
(dispatch: AppDispatch, getState: () => RootState) => {
|
||||||
|
const { instance } = getState();
|
||||||
|
const { explicitAddressing } = getFeatures(instance);
|
||||||
|
|
||||||
|
const action: ComposeSetStatusAction = {
|
||||||
|
type: COMPOSE_SET_STATUS,
|
||||||
|
id: 'compose-modal',
|
||||||
|
status,
|
||||||
|
rawText,
|
||||||
|
explicitAddressing,
|
||||||
|
spoilerText,
|
||||||
|
contentType,
|
||||||
|
v: parseVersion(instance.version),
|
||||||
|
withRedraft,
|
||||||
|
};
|
||||||
|
|
||||||
|
dispatch(action);
|
||||||
|
};
|
|
@ -11,8 +11,9 @@ import { selectAccount, selectOwnAccount } from 'soapbox/selectors';
|
||||||
import { tagHistory } from 'soapbox/settings';
|
import { tagHistory } from 'soapbox/settings';
|
||||||
import toast from 'soapbox/toast';
|
import toast from 'soapbox/toast';
|
||||||
import { isLoggedIn } from 'soapbox/utils/auth';
|
import { isLoggedIn } from 'soapbox/utils/auth';
|
||||||
import { getFeatures, parseVersion } from 'soapbox/utils/features';
|
import { getFeatures } from 'soapbox/utils/features';
|
||||||
|
|
||||||
|
import { ComposeSetStatusAction } from './compose-status';
|
||||||
import { chooseEmoji } from './emojis';
|
import { chooseEmoji } from './emojis';
|
||||||
import { importFetchedAccounts } from './importer';
|
import { importFetchedAccounts } from './importer';
|
||||||
import { uploadFile, updateMedia } from './media';
|
import { uploadFile, updateMedia } from './media';
|
||||||
|
@ -85,8 +86,6 @@ const COMPOSE_SCHEDULE_REMOVE = 'COMPOSE_SCHEDULE_REMOVE' as const;
|
||||||
const COMPOSE_ADD_TO_MENTIONS = 'COMPOSE_ADD_TO_MENTIONS' as const;
|
const COMPOSE_ADD_TO_MENTIONS = 'COMPOSE_ADD_TO_MENTIONS' as const;
|
||||||
const COMPOSE_REMOVE_FROM_MENTIONS = 'COMPOSE_REMOVE_FROM_MENTIONS' as const;
|
const COMPOSE_REMOVE_FROM_MENTIONS = 'COMPOSE_REMOVE_FROM_MENTIONS' as const;
|
||||||
|
|
||||||
const COMPOSE_SET_STATUS = 'COMPOSE_SET_STATUS' as const;
|
|
||||||
|
|
||||||
const COMPOSE_EDITOR_STATE_SET = 'COMPOSE_EDITOR_STATE_SET' as const;
|
const COMPOSE_EDITOR_STATE_SET = 'COMPOSE_EDITOR_STATE_SET' as const;
|
||||||
|
|
||||||
const COMPOSE_CHANGE_MEDIA_ORDER = 'COMPOSE_CHANGE_MEDIA_ORDER' as const;
|
const COMPOSE_CHANGE_MEDIA_ORDER = 'COMPOSE_CHANGE_MEDIA_ORDER' as const;
|
||||||
|
@ -102,38 +101,6 @@ const messages = defineMessages({
|
||||||
replyMessage: { id: 'confirmations.reply.message', defaultMessage: 'Replying now will overwrite the message you are currently composing. Are you sure you want to proceed?' },
|
replyMessage: { id: 'confirmations.reply.message', defaultMessage: 'Replying now will overwrite the message you are currently composing. Are you sure you want to proceed?' },
|
||||||
});
|
});
|
||||||
|
|
||||||
interface ComposeSetStatusAction {
|
|
||||||
type: typeof COMPOSE_SET_STATUS;
|
|
||||||
id: string;
|
|
||||||
status: Status;
|
|
||||||
rawText: string;
|
|
||||||
explicitAddressing: boolean;
|
|
||||||
spoilerText?: string;
|
|
||||||
contentType?: string | false;
|
|
||||||
v: ReturnType<typeof parseVersion>;
|
|
||||||
withRedraft?: boolean;
|
|
||||||
}
|
|
||||||
|
|
||||||
const setComposeToStatus = (status: Status, rawText: string, spoilerText?: string, contentType?: string | false, withRedraft?: boolean) =>
|
|
||||||
(dispatch: AppDispatch, getState: () => RootState) => {
|
|
||||||
const { instance } = getState();
|
|
||||||
const { explicitAddressing } = getFeatures(instance);
|
|
||||||
|
|
||||||
const action: ComposeSetStatusAction = {
|
|
||||||
type: COMPOSE_SET_STATUS,
|
|
||||||
id: 'compose-modal',
|
|
||||||
status,
|
|
||||||
rawText,
|
|
||||||
explicitAddressing,
|
|
||||||
spoilerText,
|
|
||||||
contentType,
|
|
||||||
v: parseVersion(instance.version),
|
|
||||||
withRedraft,
|
|
||||||
};
|
|
||||||
|
|
||||||
dispatch(action);
|
|
||||||
};
|
|
||||||
|
|
||||||
const changeCompose = (composeId: string, text: string) => ({
|
const changeCompose = (composeId: string, text: string) => ({
|
||||||
type: COMPOSE_CHANGE,
|
type: COMPOSE_CHANGE,
|
||||||
id: composeId,
|
id: composeId,
|
||||||
|
@ -952,11 +919,9 @@ export {
|
||||||
COMPOSE_SCHEDULE_REMOVE,
|
COMPOSE_SCHEDULE_REMOVE,
|
||||||
COMPOSE_ADD_TO_MENTIONS,
|
COMPOSE_ADD_TO_MENTIONS,
|
||||||
COMPOSE_REMOVE_FROM_MENTIONS,
|
COMPOSE_REMOVE_FROM_MENTIONS,
|
||||||
COMPOSE_SET_STATUS,
|
|
||||||
COMPOSE_EDITOR_STATE_SET,
|
COMPOSE_EDITOR_STATE_SET,
|
||||||
COMPOSE_SET_GROUP_TIMELINE_VISIBLE,
|
COMPOSE_SET_GROUP_TIMELINE_VISIBLE,
|
||||||
COMPOSE_CHANGE_MEDIA_ORDER,
|
COMPOSE_CHANGE_MEDIA_ORDER,
|
||||||
setComposeToStatus,
|
|
||||||
changeCompose,
|
changeCompose,
|
||||||
replyCompose,
|
replyCompose,
|
||||||
cancelReplyCompose,
|
cancelReplyCompose,
|
||||||
|
|
|
@ -4,7 +4,7 @@ import { shouldHaveCard } from 'soapbox/utils/status';
|
||||||
|
|
||||||
import api, { getNextLink } from '../api';
|
import api, { getNextLink } from '../api';
|
||||||
|
|
||||||
import { setComposeToStatus } from './compose';
|
import { setComposeToStatus } from './compose-status';
|
||||||
import { fetchGroupRelationships } from './groups';
|
import { fetchGroupRelationships } from './groups';
|
||||||
import { importFetchedStatus, importFetchedStatuses } from './importer';
|
import { importFetchedStatus, importFetchedStatuses } from './importer';
|
||||||
import { openModal } from './modals';
|
import { openModal } from './modals';
|
||||||
|
|
|
@ -7,7 +7,6 @@ import { useAppDispatch } from 'soapbox/hooks';
|
||||||
import RelativeTimestamp from '../relative-timestamp';
|
import RelativeTimestamp from '../relative-timestamp';
|
||||||
import { Button, HStack, Stack, Text, Tooltip } from '../ui';
|
import { Button, HStack, Stack, Text, Tooltip } from '../ui';
|
||||||
|
|
||||||
import type { Selected } from './poll';
|
|
||||||
import type { Poll as PollEntity } from 'soapbox/types/entities';
|
import type { Poll as PollEntity } from 'soapbox/types/entities';
|
||||||
|
|
||||||
const messages = defineMessages({
|
const messages = defineMessages({
|
||||||
|
@ -18,7 +17,7 @@ const messages = defineMessages({
|
||||||
interface IPollFooter {
|
interface IPollFooter {
|
||||||
poll: PollEntity;
|
poll: PollEntity;
|
||||||
showResults: boolean;
|
showResults: boolean;
|
||||||
selected: Selected;
|
selected: Record<number, boolean>;
|
||||||
}
|
}
|
||||||
|
|
||||||
const PollFooter: React.FC<IPollFooter> = ({ poll, showResults, selected }): JSX.Element => {
|
const PollFooter: React.FC<IPollFooter> = ({ poll, showResults, selected }): JSX.Element => {
|
||||||
|
|
|
@ -10,8 +10,6 @@ import { Stack, Text } from '../ui';
|
||||||
import PollFooter from './poll-footer';
|
import PollFooter from './poll-footer';
|
||||||
import PollOption from './poll-option';
|
import PollOption from './poll-option';
|
||||||
|
|
||||||
export type Selected = Record<number, boolean>;
|
|
||||||
|
|
||||||
interface IPoll {
|
interface IPoll {
|
||||||
id: string;
|
id: string;
|
||||||
status?: string;
|
status?: string;
|
||||||
|
@ -28,7 +26,7 @@ const Poll: React.FC<IPoll> = ({ id, status }): JSX.Element | null => {
|
||||||
const isLoggedIn = useAppSelector((state) => state.me);
|
const isLoggedIn = useAppSelector((state) => state.me);
|
||||||
const poll = useAppSelector((state) => state.polls.get(id));
|
const poll = useAppSelector((state) => state.polls.get(id));
|
||||||
|
|
||||||
const [selected, setSelected] = useState({} as Selected);
|
const [selected, setSelected] = useState<Record<number, boolean>>({});
|
||||||
|
|
||||||
const openUnauthorizedModal = () =>
|
const openUnauthorizedModal = () =>
|
||||||
dispatch(openModal('UNAUTHORIZED', {
|
dispatch(openModal('UNAUTHORIZED', {
|
||||||
|
@ -49,7 +47,7 @@ const Poll: React.FC<IPoll> = ({ id, status }): JSX.Element | null => {
|
||||||
}
|
}
|
||||||
setSelected(tmp);
|
setSelected(tmp);
|
||||||
} else {
|
} else {
|
||||||
const tmp: Selected = {};
|
const tmp: Record<number, boolean> = {};
|
||||||
tmp[value] = true;
|
tmp[value] = true;
|
||||||
setSelected(tmp);
|
setSelected(tmp);
|
||||||
handleVote(value);
|
handleVote(value);
|
||||||
|
|
|
@ -14,8 +14,7 @@ import PlaceholderAccount from 'soapbox/features/placeholder/components/placehol
|
||||||
import { useAppDispatch, useFeatures } from 'soapbox/hooks';
|
import { useAppDispatch, useFeatures } from 'soapbox/hooks';
|
||||||
import { GroupRoles } from 'soapbox/schemas/group-member';
|
import { GroupRoles } from 'soapbox/schemas/group-member';
|
||||||
import toast from 'soapbox/toast';
|
import toast from 'soapbox/toast';
|
||||||
|
import { MAX_ADMIN_COUNT } from 'soapbox/utils/groups';
|
||||||
import { MAX_ADMIN_COUNT } from '../group-members';
|
|
||||||
|
|
||||||
import type { Menu as IMenu } from 'soapbox/components/dropdown-menu';
|
import type { Menu as IMenu } from 'soapbox/components/dropdown-menu';
|
||||||
import type { Group, GroupMember } from 'soapbox/types/entities';
|
import type { Group, GroupMember } from 'soapbox/types/entities';
|
||||||
|
|
|
@ -6,6 +6,7 @@ import { PendingItemsRow } from 'soapbox/components/pending-items-row';
|
||||||
import ScrollableList from 'soapbox/components/scrollable-list';
|
import ScrollableList from 'soapbox/components/scrollable-list';
|
||||||
import { useFeatures } from 'soapbox/hooks';
|
import { useFeatures } from 'soapbox/hooks';
|
||||||
import { GroupRoles } from 'soapbox/schemas/group-member';
|
import { GroupRoles } from 'soapbox/schemas/group-member';
|
||||||
|
import { MAX_ADMIN_COUNT } from 'soapbox/utils/groups';
|
||||||
|
|
||||||
import PlaceholderAccount from '../placeholder/components/placeholder-account';
|
import PlaceholderAccount from '../placeholder/components/placeholder-account';
|
||||||
|
|
||||||
|
@ -18,8 +19,6 @@ interface IGroupMembers {
|
||||||
params: { groupId: string };
|
params: { groupId: string };
|
||||||
}
|
}
|
||||||
|
|
||||||
export const MAX_ADMIN_COUNT = 5;
|
|
||||||
|
|
||||||
const GroupMembers: React.FC<IGroupMembers> = (props) => {
|
const GroupMembers: React.FC<IGroupMembers> = (props) => {
|
||||||
const { groupId } = props.params;
|
const { groupId } = props.params;
|
||||||
|
|
||||||
|
|
|
@ -29,5 +29,3 @@ const NostrSignUpModal: React.FC<INostrSignupModal> = ({ onClose }) => {
|
||||||
};
|
};
|
||||||
|
|
||||||
export default NostrSignUpModal;
|
export default NostrSignUpModal;
|
||||||
|
|
||||||
export type { Step };
|
|
||||||
|
|
|
@ -7,10 +7,9 @@ import { Button, Stack, Modal, Text, Divider } from 'soapbox/components/ui';
|
||||||
import { useAppDispatch } from 'soapbox/hooks';
|
import { useAppDispatch } from 'soapbox/hooks';
|
||||||
|
|
||||||
import NostrExtensionIndicator from '../../nostr-login-modal/components/nostr-extension-indicator';
|
import NostrExtensionIndicator from '../../nostr-login-modal/components/nostr-extension-indicator';
|
||||||
import { Step } from '../nostr-signup-modal';
|
|
||||||
|
|
||||||
interface IKeyStep {
|
interface IKeyStep {
|
||||||
setStep(step: Step): void;
|
setStep(step: 'extension' | 'key' | 'keygen'): void;
|
||||||
onClose(): void;
|
onClose(): void;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
import { List as ImmutableList, Record as ImmutableRecord, fromJS } from 'immutable';
|
import { List as ImmutableList, Record as ImmutableRecord, fromJS } from 'immutable';
|
||||||
|
|
||||||
import * as actions from 'soapbox/actions/compose';
|
import * as actions from 'soapbox/actions/compose';
|
||||||
|
import { COMPOSE_SET_STATUS } from 'soapbox/actions/compose-status';
|
||||||
import { ME_FETCH_SUCCESS, ME_PATCH_SUCCESS } from 'soapbox/actions/me';
|
import { ME_FETCH_SUCCESS, ME_PATCH_SUCCESS } from 'soapbox/actions/me';
|
||||||
import { SETTING_CHANGE } from 'soapbox/actions/settings';
|
import { SETTING_CHANGE } from 'soapbox/actions/settings';
|
||||||
import { TIMELINE_DELETE } from 'soapbox/actions/timelines';
|
import { TIMELINE_DELETE } from 'soapbox/actions/timelines';
|
||||||
|
@ -43,7 +44,7 @@ describe('compose reducer', () => {
|
||||||
const status = await import('soapbox/__fixtures__/pleroma-status-deleted.json');
|
const status = await import('soapbox/__fixtures__/pleroma-status-deleted.json');
|
||||||
|
|
||||||
const action = {
|
const action = {
|
||||||
type: actions.COMPOSE_SET_STATUS,
|
type: COMPOSE_SET_STATUS,
|
||||||
id: 'compose-modal',
|
id: 'compose-modal',
|
||||||
status: normalizeStatus(fromJS(status)),
|
status: normalizeStatus(fromJS(status)),
|
||||||
v: { software: 'Pleroma' },
|
v: { software: 'Pleroma' },
|
||||||
|
@ -58,7 +59,7 @@ describe('compose reducer', () => {
|
||||||
const status = await import('soapbox/__fixtures__/pleroma-status-deleted.json');
|
const status = await import('soapbox/__fixtures__/pleroma-status-deleted.json');
|
||||||
|
|
||||||
const action = {
|
const action = {
|
||||||
type: actions.COMPOSE_SET_STATUS,
|
type: COMPOSE_SET_STATUS,
|
||||||
id: 'compose-modal',
|
id: 'compose-modal',
|
||||||
status: normalizeStatus(fromJS(status)),
|
status: normalizeStatus(fromJS(status)),
|
||||||
};
|
};
|
||||||
|
@ -73,7 +74,7 @@ describe('compose reducer', () => {
|
||||||
const action = {
|
const action = {
|
||||||
id: 'compose-modal',
|
id: 'compose-modal',
|
||||||
withRedraft: false,
|
withRedraft: false,
|
||||||
type: actions.COMPOSE_SET_STATUS,
|
type: COMPOSE_SET_STATUS,
|
||||||
status: normalizeStatus(fromJS(status)),
|
status: normalizeStatus(fromJS(status)),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -87,7 +88,7 @@ describe('compose reducer', () => {
|
||||||
const action = {
|
const action = {
|
||||||
id: 'compose-modal',
|
id: 'compose-modal',
|
||||||
withRedraft: true,
|
withRedraft: true,
|
||||||
type: actions.COMPOSE_SET_STATUS,
|
type: COMPOSE_SET_STATUS,
|
||||||
status: normalizeStatus(fromJS(status)),
|
status: normalizeStatus(fromJS(status)),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -48,13 +48,13 @@ import {
|
||||||
COMPOSE_POLL_SETTINGS_CHANGE,
|
COMPOSE_POLL_SETTINGS_CHANGE,
|
||||||
COMPOSE_ADD_TO_MENTIONS,
|
COMPOSE_ADD_TO_MENTIONS,
|
||||||
COMPOSE_REMOVE_FROM_MENTIONS,
|
COMPOSE_REMOVE_FROM_MENTIONS,
|
||||||
COMPOSE_SET_STATUS,
|
|
||||||
COMPOSE_EVENT_REPLY,
|
COMPOSE_EVENT_REPLY,
|
||||||
COMPOSE_EDITOR_STATE_SET,
|
COMPOSE_EDITOR_STATE_SET,
|
||||||
COMPOSE_SET_GROUP_TIMELINE_VISIBLE,
|
COMPOSE_SET_GROUP_TIMELINE_VISIBLE,
|
||||||
ComposeAction,
|
ComposeAction,
|
||||||
COMPOSE_CHANGE_MEDIA_ORDER,
|
COMPOSE_CHANGE_MEDIA_ORDER,
|
||||||
} from '../actions/compose';
|
} from '../actions/compose';
|
||||||
|
import { COMPOSE_SET_STATUS } from '../actions/compose-status';
|
||||||
import { EVENT_COMPOSE_CANCEL, EVENT_FORM_SET, type EventsAction } from '../actions/events';
|
import { EVENT_COMPOSE_CANCEL, EVENT_FORM_SET, type EventsAction } from '../actions/events';
|
||||||
import { ME_FETCH_SUCCESS, ME_PATCH_SUCCESS, MeAction } from '../actions/me';
|
import { ME_FETCH_SUCCESS, ME_PATCH_SUCCESS, MeAction } from '../actions/me';
|
||||||
import { SETTING_CHANGE, FE_NAME, SettingsAction } from '../actions/settings';
|
import { SETTING_CHANGE, FE_NAME, SettingsAction } from '../actions/settings';
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
import { groupSearchHistory } from 'soapbox/settings';
|
import { groupSearchHistory } from 'soapbox/settings';
|
||||||
|
|
||||||
|
export const MAX_ADMIN_COUNT = 5;
|
||||||
|
|
||||||
const RECENT_SEARCHES_KEY = 'soapbox:recent-group-searches';
|
const RECENT_SEARCHES_KEY = 'soapbox:recent-group-searches';
|
||||||
|
|
||||||
const clearRecentGroupSearches = (currentUserId: string) => groupSearchHistory.remove(currentUserId);
|
const clearRecentGroupSearches = (currentUserId: string) => groupSearchHistory.remove(currentUserId);
|
||||||
|
|
Loading…
Reference in New Issue