Groups: make "share with followers" button work
This commit is contained in:
parent
a976b542e1
commit
5720d396fc
4 changed files with 44 additions and 9 deletions
|
@ -48,6 +48,7 @@ const COMPOSE_UPLOAD_FAIL = 'COMPOSE_UPLOAD_FAIL';
|
|||
const COMPOSE_UPLOAD_PROGRESS = 'COMPOSE_UPLOAD_PROGRESS';
|
||||
const COMPOSE_UPLOAD_UNDO = 'COMPOSE_UPLOAD_UNDO';
|
||||
const COMPOSE_GROUP_POST = 'COMPOSE_GROUP_POST';
|
||||
const COMPOSE_SET_GROUP_TIMELINE_VISIBLE = 'COMPOSE_SET_GROUP_TIMELINE_VISIBLE';
|
||||
|
||||
const COMPOSE_SUGGESTIONS_CLEAR = 'COMPOSE_SUGGESTIONS_CLEAR';
|
||||
const COMPOSE_SUGGESTIONS_READY = 'COMPOSE_SUGGESTIONS_READY';
|
||||
|
@ -292,7 +293,10 @@ const submitCompose = (composeId: string, routerHistory?: History, force = false
|
|||
to,
|
||||
};
|
||||
|
||||
if (compose.privacy === 'group') params.group_id = compose.group_id;
|
||||
if (compose.privacy === 'group') {
|
||||
params.group_id = compose.group_id;
|
||||
params.group_timeline_visible = compose.group_timeline_visible; // Truth Social
|
||||
}
|
||||
|
||||
dispatch(createStatus(params, idempotencyKey, statusId)).then(function(data) {
|
||||
if (!statusId && data.visibility === 'direct' && getState().conversations.mounted <= 0 && routerHistory) {
|
||||
|
@ -483,6 +487,12 @@ const groupCompose = (composeId: string, groupId: string) =>
|
|||
});
|
||||
};
|
||||
|
||||
const setGroupTimelineVisible = (composeId: string, groupTimelineVisible: boolean) => ({
|
||||
type: COMPOSE_SET_GROUP_TIMELINE_VISIBLE,
|
||||
id: composeId,
|
||||
groupTimelineVisible,
|
||||
});
|
||||
|
||||
const clearComposeSuggestions = (composeId: string) => {
|
||||
if (cancelFetchComposeSuggestionsAccounts) {
|
||||
cancelFetchComposeSuggestionsAccounts();
|
||||
|
@ -792,6 +802,7 @@ export {
|
|||
COMPOSE_ADD_TO_MENTIONS,
|
||||
COMPOSE_REMOVE_FROM_MENTIONS,
|
||||
COMPOSE_SET_STATUS,
|
||||
COMPOSE_SET_GROUP_TIMELINE_VISIBLE,
|
||||
setComposeToStatus,
|
||||
changeCompose,
|
||||
replyCompose,
|
||||
|
@ -818,6 +829,7 @@ export {
|
|||
uploadComposeFail,
|
||||
undoUploadCompose,
|
||||
groupCompose,
|
||||
setGroupTimelineVisible,
|
||||
clearComposeSuggestions,
|
||||
fetchComposeSuggestions,
|
||||
readyComposeSuggestionsEmojis,
|
||||
|
|
|
@ -63,9 +63,10 @@ interface IComposeForm<ID extends string> {
|
|||
clickableAreaRef?: React.RefObject<HTMLDivElement>
|
||||
event?: string
|
||||
group?: string
|
||||
extra?: React.ReactNode
|
||||
}
|
||||
|
||||
const ComposeForm = <ID extends string>({ id, shouldCondense, autoFocus, clickableAreaRef, event, group }: IComposeForm<ID>) => {
|
||||
const ComposeForm = <ID extends string>({ id, shouldCondense, autoFocus, clickableAreaRef, event, group, extra }: IComposeForm<ID>) => {
|
||||
const history = useHistory();
|
||||
const intl = useIntl();
|
||||
const dispatch = useAppDispatch();
|
||||
|
@ -333,6 +334,8 @@ const ComposeForm = <ID extends string>({ id, shouldCondense, autoFocus, clickab
|
|||
|
||||
<QuotedStatusContainer composeId={id} />
|
||||
|
||||
{extra && <div className={clsx({ 'hidden': condensed })}>{extra}</div>}
|
||||
|
||||
<div
|
||||
className={clsx('flex flex-wrap items-center justify-between', {
|
||||
'hidden': condensed,
|
||||
|
|
|
@ -2,12 +2,12 @@ import React, { useEffect } from 'react';
|
|||
import { FormattedMessage } from 'react-intl';
|
||||
import { Link } from 'react-router-dom';
|
||||
|
||||
import { groupCompose } from 'soapbox/actions/compose';
|
||||
import { groupCompose, setGroupTimelineVisible } from 'soapbox/actions/compose';
|
||||
import { connectGroupStream } from 'soapbox/actions/streaming';
|
||||
import { expandGroupTimeline } from 'soapbox/actions/timelines';
|
||||
import { Avatar, HStack, Icon, Stack, Text } from 'soapbox/components/ui';
|
||||
import { Avatar, HStack, Icon, Stack, Text, Toggle } from 'soapbox/components/ui';
|
||||
import ComposeForm from 'soapbox/features/compose/components/compose-form';
|
||||
import { useAppDispatch, useOwnAccount } from 'soapbox/hooks';
|
||||
import { useAppDispatch, useAppSelector, useOwnAccount } from 'soapbox/hooks';
|
||||
import { useGroup } from 'soapbox/hooks/api';
|
||||
|
||||
import Timeline from '../ui/components/timeline';
|
||||
|
@ -26,16 +26,21 @@ const GroupTimeline: React.FC<IGroupTimeline> = (props) => {
|
|||
|
||||
const { group } = useGroup(groupId);
|
||||
|
||||
const composeId = `group:${groupId}`;
|
||||
const canComposeGroupStatus = !!account && group?.relationship?.member;
|
||||
const groupTimelineVisible = useAppSelector((state) => !!state.compose.get(composeId)?.group_timeline_visible);
|
||||
|
||||
const handleLoadMore = (maxId: string) => {
|
||||
dispatch(expandGroupTimeline(groupId, { maxId }));
|
||||
};
|
||||
|
||||
const handleToggleChange = () => {
|
||||
dispatch(setGroupTimelineVisible(composeId, !groupTimelineVisible));
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
dispatch(expandGroupTimeline(groupId));
|
||||
|
||||
dispatch(groupCompose(`group:${groupId}`, groupId));
|
||||
dispatch(groupCompose(composeId, groupId));
|
||||
|
||||
const disconnect = dispatch(connectGroupStream(groupId));
|
||||
|
||||
|
@ -58,10 +63,21 @@ const GroupTimeline: React.FC<IGroupTimeline> = (props) => {
|
|||
</Link>
|
||||
|
||||
<ComposeForm
|
||||
id={`group:${groupId}`}
|
||||
id={composeId}
|
||||
shouldCondense
|
||||
autoFocus={false}
|
||||
group={groupId}
|
||||
extra={(
|
||||
<HStack alignItems='center' space={4}>
|
||||
<div className='ml-auto'>
|
||||
<Text theme='muted'>Share with my followers</Text>
|
||||
</div>
|
||||
<Toggle
|
||||
checked={groupTimelineVisible}
|
||||
onChange={handleToggleChange}
|
||||
/>
|
||||
</HStack>
|
||||
)}
|
||||
/>
|
||||
</HStack>
|
||||
</div>
|
||||
|
@ -69,7 +85,7 @@ const GroupTimeline: React.FC<IGroupTimeline> = (props) => {
|
|||
|
||||
<Timeline
|
||||
scrollKey='group_timeline'
|
||||
timelineId={`group:${groupId}`}
|
||||
timelineId={composeId}
|
||||
onLoadMore={handleLoadMore}
|
||||
emptyMessage={
|
||||
<Stack space={4} className='py-6' justifyContent='center' alignItems='center'>
|
||||
|
|
|
@ -51,6 +51,7 @@ import {
|
|||
COMPOSE_REMOVE_FROM_MENTIONS,
|
||||
COMPOSE_SET_STATUS,
|
||||
COMPOSE_EVENT_REPLY,
|
||||
COMPOSE_SET_GROUP_TIMELINE_VISIBLE,
|
||||
} from '../actions/compose';
|
||||
import { ME_FETCH_SUCCESS, ME_PATCH_SUCCESS } from '../actions/me';
|
||||
import { SETTING_CHANGE, FE_NAME } from '../actions/settings';
|
||||
|
@ -103,6 +104,7 @@ export const ReducerCompose = ImmutableRecord({
|
|||
tagHistory: ImmutableList<string>(),
|
||||
text: '',
|
||||
to: ImmutableOrderedSet<string>(),
|
||||
group_timeline_visible: false, // TruthSocial
|
||||
});
|
||||
|
||||
type State = ImmutableMap<string, Compose>;
|
||||
|
@ -493,6 +495,8 @@ export default function compose(state = initialState, action: AnyAction) {
|
|||
return updateCompose(state, action.id, compose => compose.update('to', mentions => mentions!.add(action.account)));
|
||||
case COMPOSE_REMOVE_FROM_MENTIONS:
|
||||
return updateCompose(state, action.id, compose => compose.update('to', mentions => mentions!.delete(action.account)));
|
||||
case COMPOSE_SET_GROUP_TIMELINE_VISIBLE:
|
||||
return updateCompose(state, action.id, compose => compose.set('group_timeline_visible', action.groupTimelineVisible));
|
||||
case ME_FETCH_SUCCESS:
|
||||
return updateCompose(state, 'default', compose => importAccount(compose, action.me));
|
||||
case ME_PATCH_SUCCESS:
|
||||
|
|
Loading…
Reference in a new issue