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_PROGRESS = 'COMPOSE_UPLOAD_PROGRESS';
|
||||||
const COMPOSE_UPLOAD_UNDO = 'COMPOSE_UPLOAD_UNDO';
|
const COMPOSE_UPLOAD_UNDO = 'COMPOSE_UPLOAD_UNDO';
|
||||||
const COMPOSE_GROUP_POST = 'COMPOSE_GROUP_POST';
|
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_CLEAR = 'COMPOSE_SUGGESTIONS_CLEAR';
|
||||||
const COMPOSE_SUGGESTIONS_READY = 'COMPOSE_SUGGESTIONS_READY';
|
const COMPOSE_SUGGESTIONS_READY = 'COMPOSE_SUGGESTIONS_READY';
|
||||||
|
@ -292,7 +293,10 @@ const submitCompose = (composeId: string, routerHistory?: History, force = false
|
||||||
to,
|
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) {
|
dispatch(createStatus(params, idempotencyKey, statusId)).then(function(data) {
|
||||||
if (!statusId && data.visibility === 'direct' && getState().conversations.mounted <= 0 && routerHistory) {
|
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) => {
|
const clearComposeSuggestions = (composeId: string) => {
|
||||||
if (cancelFetchComposeSuggestionsAccounts) {
|
if (cancelFetchComposeSuggestionsAccounts) {
|
||||||
cancelFetchComposeSuggestionsAccounts();
|
cancelFetchComposeSuggestionsAccounts();
|
||||||
|
@ -792,6 +802,7 @@ export {
|
||||||
COMPOSE_ADD_TO_MENTIONS,
|
COMPOSE_ADD_TO_MENTIONS,
|
||||||
COMPOSE_REMOVE_FROM_MENTIONS,
|
COMPOSE_REMOVE_FROM_MENTIONS,
|
||||||
COMPOSE_SET_STATUS,
|
COMPOSE_SET_STATUS,
|
||||||
|
COMPOSE_SET_GROUP_TIMELINE_VISIBLE,
|
||||||
setComposeToStatus,
|
setComposeToStatus,
|
||||||
changeCompose,
|
changeCompose,
|
||||||
replyCompose,
|
replyCompose,
|
||||||
|
@ -818,6 +829,7 @@ export {
|
||||||
uploadComposeFail,
|
uploadComposeFail,
|
||||||
undoUploadCompose,
|
undoUploadCompose,
|
||||||
groupCompose,
|
groupCompose,
|
||||||
|
setGroupTimelineVisible,
|
||||||
clearComposeSuggestions,
|
clearComposeSuggestions,
|
||||||
fetchComposeSuggestions,
|
fetchComposeSuggestions,
|
||||||
readyComposeSuggestionsEmojis,
|
readyComposeSuggestionsEmojis,
|
||||||
|
|
|
@ -63,9 +63,10 @@ interface IComposeForm<ID extends string> {
|
||||||
clickableAreaRef?: React.RefObject<HTMLDivElement>
|
clickableAreaRef?: React.RefObject<HTMLDivElement>
|
||||||
event?: string
|
event?: string
|
||||||
group?: 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 history = useHistory();
|
||||||
const intl = useIntl();
|
const intl = useIntl();
|
||||||
const dispatch = useAppDispatch();
|
const dispatch = useAppDispatch();
|
||||||
|
@ -333,6 +334,8 @@ const ComposeForm = <ID extends string>({ id, shouldCondense, autoFocus, clickab
|
||||||
|
|
||||||
<QuotedStatusContainer composeId={id} />
|
<QuotedStatusContainer composeId={id} />
|
||||||
|
|
||||||
|
{extra && <div className={clsx({ 'hidden': condensed })}>{extra}</div>}
|
||||||
|
|
||||||
<div
|
<div
|
||||||
className={clsx('flex flex-wrap items-center justify-between', {
|
className={clsx('flex flex-wrap items-center justify-between', {
|
||||||
'hidden': condensed,
|
'hidden': condensed,
|
||||||
|
|
|
@ -2,12 +2,12 @@ import React, { useEffect } from 'react';
|
||||||
import { FormattedMessage } from 'react-intl';
|
import { FormattedMessage } from 'react-intl';
|
||||||
import { Link } from 'react-router-dom';
|
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 { connectGroupStream } from 'soapbox/actions/streaming';
|
||||||
import { expandGroupTimeline } from 'soapbox/actions/timelines';
|
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 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 { useGroup } from 'soapbox/hooks/api';
|
||||||
|
|
||||||
import Timeline from '../ui/components/timeline';
|
import Timeline from '../ui/components/timeline';
|
||||||
|
@ -26,16 +26,21 @@ const GroupTimeline: React.FC<IGroupTimeline> = (props) => {
|
||||||
|
|
||||||
const { group } = useGroup(groupId);
|
const { group } = useGroup(groupId);
|
||||||
|
|
||||||
|
const composeId = `group:${groupId}`;
|
||||||
const canComposeGroupStatus = !!account && group?.relationship?.member;
|
const canComposeGroupStatus = !!account && group?.relationship?.member;
|
||||||
|
const groupTimelineVisible = useAppSelector((state) => !!state.compose.get(composeId)?.group_timeline_visible);
|
||||||
|
|
||||||
const handleLoadMore = (maxId: string) => {
|
const handleLoadMore = (maxId: string) => {
|
||||||
dispatch(expandGroupTimeline(groupId, { maxId }));
|
dispatch(expandGroupTimeline(groupId, { maxId }));
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const handleToggleChange = () => {
|
||||||
|
dispatch(setGroupTimelineVisible(composeId, !groupTimelineVisible));
|
||||||
|
};
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
dispatch(expandGroupTimeline(groupId));
|
dispatch(expandGroupTimeline(groupId));
|
||||||
|
dispatch(groupCompose(composeId, groupId));
|
||||||
dispatch(groupCompose(`group:${groupId}`, groupId));
|
|
||||||
|
|
||||||
const disconnect = dispatch(connectGroupStream(groupId));
|
const disconnect = dispatch(connectGroupStream(groupId));
|
||||||
|
|
||||||
|
@ -58,10 +63,21 @@ const GroupTimeline: React.FC<IGroupTimeline> = (props) => {
|
||||||
</Link>
|
</Link>
|
||||||
|
|
||||||
<ComposeForm
|
<ComposeForm
|
||||||
id={`group:${groupId}`}
|
id={composeId}
|
||||||
shouldCondense
|
shouldCondense
|
||||||
autoFocus={false}
|
autoFocus={false}
|
||||||
group={groupId}
|
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>
|
</HStack>
|
||||||
</div>
|
</div>
|
||||||
|
@ -69,7 +85,7 @@ const GroupTimeline: React.FC<IGroupTimeline> = (props) => {
|
||||||
|
|
||||||
<Timeline
|
<Timeline
|
||||||
scrollKey='group_timeline'
|
scrollKey='group_timeline'
|
||||||
timelineId={`group:${groupId}`}
|
timelineId={composeId}
|
||||||
onLoadMore={handleLoadMore}
|
onLoadMore={handleLoadMore}
|
||||||
emptyMessage={
|
emptyMessage={
|
||||||
<Stack space={4} className='py-6' justifyContent='center' alignItems='center'>
|
<Stack space={4} className='py-6' justifyContent='center' alignItems='center'>
|
||||||
|
|
|
@ -51,6 +51,7 @@ import {
|
||||||
COMPOSE_REMOVE_FROM_MENTIONS,
|
COMPOSE_REMOVE_FROM_MENTIONS,
|
||||||
COMPOSE_SET_STATUS,
|
COMPOSE_SET_STATUS,
|
||||||
COMPOSE_EVENT_REPLY,
|
COMPOSE_EVENT_REPLY,
|
||||||
|
COMPOSE_SET_GROUP_TIMELINE_VISIBLE,
|
||||||
} from '../actions/compose';
|
} from '../actions/compose';
|
||||||
import { ME_FETCH_SUCCESS, ME_PATCH_SUCCESS } from '../actions/me';
|
import { ME_FETCH_SUCCESS, ME_PATCH_SUCCESS } from '../actions/me';
|
||||||
import { SETTING_CHANGE, FE_NAME } from '../actions/settings';
|
import { SETTING_CHANGE, FE_NAME } from '../actions/settings';
|
||||||
|
@ -103,6 +104,7 @@ export const ReducerCompose = ImmutableRecord({
|
||||||
tagHistory: ImmutableList<string>(),
|
tagHistory: ImmutableList<string>(),
|
||||||
text: '',
|
text: '',
|
||||||
to: ImmutableOrderedSet<string>(),
|
to: ImmutableOrderedSet<string>(),
|
||||||
|
group_timeline_visible: false, // TruthSocial
|
||||||
});
|
});
|
||||||
|
|
||||||
type State = ImmutableMap<string, Compose>;
|
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)));
|
return updateCompose(state, action.id, compose => compose.update('to', mentions => mentions!.add(action.account)));
|
||||||
case COMPOSE_REMOVE_FROM_MENTIONS:
|
case COMPOSE_REMOVE_FROM_MENTIONS:
|
||||||
return updateCompose(state, action.id, compose => compose.update('to', mentions => mentions!.delete(action.account)));
|
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:
|
case ME_FETCH_SUCCESS:
|
||||||
return updateCompose(state, 'default', compose => importAccount(compose, action.me));
|
return updateCompose(state, 'default', compose => importAccount(compose, action.me));
|
||||||
case ME_PATCH_SUCCESS:
|
case ME_PATCH_SUCCESS:
|
||||||
|
|
Loading…
Reference in a new issue